將Oracle數(shù)據(jù)庫改為歸檔模式并啟用RMAN備份
如下Linux環(huán)境下對Oracle單節(jié)點(diǎn)數(shù)據(jù)庫采用文件系統(tǒng)情況的配置歸檔模式過程。首先查看數(shù)據(jù)庫歸檔模式和磁盤使用情況,確定歸檔文件放到什么位置:
- [oracle@gisdbserver ~]$ sqlplus / as sysdba
 - SQL> archive log list
 - Database log mode No Archive Mode
 - Automatic archival Disabled
 - Archive destination /dbback/archivelog
 - Oldest online log sequence 92
 - Current log sequence 97
 
根據(jù)如下磁盤使用情況,在相應(yīng)的目錄下建立相關(guān)歸檔和備份目錄:
- [root@gisdbserver ~]# df -h
 - Filesystem Size Used Avail Use% Mounted on
 - /dev/mapper/vg_gisdbserver-lv_root 99G 3.8G 90G 4% /
 - tmpfs 16G 76K 16G 1% /dev/shm
 - /dev/sda2 485M 39M 421M 9% /boot
 - /dev/sda1 200M 260K 200M 1% /boot/efi
 - /dev/mapper/vg_gisdbserver-LogVol03 481G 198M 457G 1% /dbback
 - /dev/mapper/vg_gisdbserver-LogVol04 407G 9.3G 377G 3% /home
 - /dev/mapper/vg_gisdbserver-LogVol02 99G 4.5G 89G 5% /opt
 - dev/sdb 441G 72G 347G 18% /oradata
 
創(chuàng)建相關(guān)歸檔日志存放目錄:
- [root@gisdbserver ~]# cd /dbback/
 - [root@gisdbserver dbback]# mkdir archivelog
 - [root@gisdbserver dbback]# chown -R oracle:oinstall archivelog/
 - [root@gisdbserver dbback]# mkdir rman
 - [root@gisdbserver dbback]# chown oracle:oinstall rman/
 - [root@gisdbserver rman]# mkdir fullback
 - [root@gisdbserver rman]# mkdir archiveback
 - [root@gisdbserver rman]# chown oracle:oinstall archiveback/
 - [root@gisdbserver rman]# chown oracle:oinstall fullback/
 
登錄數(shù)據(jù)庫指定歸檔存放目錄:
- [oracle@gisdbserver ~]$ sqlplus / as sysdba
 - SQL> alter system set log_archive_dest_1='location=/dbback/archivelog';
 - System altered.
 - SQL> show parameter log_archive_dest_1
 - NAME TYPE VALUE
 - ------------------------------------ ----------- ------------------------------
 - log_archive_dest_1 string location=/dbback/archivelog
 
要將非歸檔數(shù)據(jù)庫模式改為歸檔模式,需要在mount狀態(tài)下執(zhí)行alter database archivelog命令才行,如下:
- SQL> archive log list
 - Database log mode No Archive Mode
 - Automatic archival Disabled
 - Archive destination /dbback/archivelog
 - Oldest online log sequence 92
 - Current log sequence 97
 - SQL> alter database archivelog;
 - alter database archivelog
 - *
 - ERROR at line 1:
 - ORA-01126: database must be mounted in this instance and not open in any
 - instance
 
因此需要在合適的時間關(guān)閉數(shù)據(jù)庫,重新啟動到mount狀態(tài)下才能改變?yōu)闅w檔模式。
- SQL> shutdown immediate;
 - SQL> startup mount;
 - SQL> alter database archivelog;
 
要開啟rman備份,需要對配置rman相關(guān)的一些參數(shù),具體如下:
- oracle@gisdbserver ~]$ rman target /
 - RMAN> backup DATABASE include CURRENT controlfile format '/dbback/rman/fullback/data_%d_%T_%s_%p' plus archivelog format '+/dbback/rman/archiveback/arch_%d_%T_%s';
 
以上語句也可以通過linux的crontab 和 bash腳本方式進(jìn)行自動化運(yùn)行。
- run{
 - DELETE NOPROMPT expired archivelog ALL;
 - allocate channel d1 TYPE disk maxpiecesize=30G;
 - allocate channel d2 TYPE disk maxpiecesize=30G;
 - backup DATABASE include CURRENT controlfile format '/dbback/rman/fullback/data_%d_%T_%s_%p' plus archivelog format '+/dbback/rman/archiveback/arch_%d_%T_%s';
 - release channel d1;
 - release channel d2;
 - crosscheck backup;
 - DELETE noprompt obsolete REDUNDANCY 1;
 - }
 















 
 
 

 
 
 
 