ORACLE DATAGUARD重建備庫(利用主庫備份進行恢復(fù))
Oracle Dataguard備庫重建
1、添加oracle目錄
mkdir /ora_data_1
mkdir /ora_data_2
mkdir /ora_data_3
2、修改目錄權(quán)限
chown oracle:dba /ora_data_1
chown oracle:dba /ora_data_2
chown oracle:dba /ora_data_3
3、在創(chuàng)建的目錄下添加數(shù)據(jù)文件
alter tablespace users add datafile '/ora_data_1/users02.dbf' size 1M autoextend off;
alter tablespace test add datafile '/ora_data_2/test02.dbf' size 1M autoextend off;
alter tablespace test add datafile '/ora_data_3/test03.dbf' size 1M autoextend off;
4、主庫備份生成備庫控制文件
backup current controlfile for standby format '/tmp/control.ctl';
5、主庫對數(shù)據(jù)庫進行全備
backup database format '/tmp/full_backup_%T_%t.bak';
6、對備庫參數(shù)文件進行修改,添加數(shù)據(jù)文件映射關(guān)系
*.db_file_name_convert='/opt/oracle/oradata/orcl','/opt/oracle/oradata/standby','/ora_data_1','/opt/oracle/oradata/standby','/ora_data_2','/opt/oracle/oradata/standby','/ora_data_3','/opt/oracle/oradata/standby'
7、在主庫配置NFS,提供給備庫恢復(fù)使用
vi /etc/exports
/tmp 192.168.56.*(rw)
service nfs restart
8、在備庫掛載NFS目錄,并查看是否正常掛載
mount -o rw,noac,hard,rsize=32768,wsize=32768,nolock 192.168.56.103:/tmp /dbbak
9、進入RMAN恢復(fù)控制文件
rman target /
startup nomount
restore controlfile from '/dbbak/control.ctl;
10、mount數(shù)據(jù)庫,并注冊恢復(fù)目錄
alter database mount;
catalog start with '/dbbak/full_backup_20170720_949796538.bak'
11、還原數(shù)據(jù)庫
restore database;
12、打開數(shù)據(jù)庫(如果主庫之前沒有standby logfile,還需要創(chuàng)建standby logfile)
alter database open
13、應(yīng)用日志
alter database recover managed standby database using current logfile disconnect;
14、主庫建表插入數(shù)據(jù),切換日志進行測試。