ORACLE DATAGUARD重建備庫(利用主庫備份進行恢復)
Oracle Dataguard備庫重建
1、添加oracle目錄
mkdir /ora_data_1
mkdir /ora_data_2
mkdir /ora_data_3
2、修改目錄權限
chown oracle:dba /ora_data_1
chown oracle:dba /ora_data_2
chown oracle:dba /ora_data_3
3、在創建的目錄下添加數據文件
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、主庫對數據庫進行全備
backup database format '/tmp/full_backup_%T_%t.bak';
6、對備庫參數文件進行修改,添加數據文件映射關系
*.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,提供給備庫恢復使用
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恢復控制文件
rman target /
startup nomount
restore controlfile from '/dbbak/control.ctl;
10、mount數據庫,并注冊恢復目錄
alter database mount;
catalog start with '/dbbak/full_backup_20170720_949796538.bak'
11、還原數據庫
restore database;
12、打開數據庫(如果主庫之前沒有standby logfile,還需要創建standby logfile)
alter database open
13、應用日志
alter database recover managed standby database using current logfile disconnect;
14、主庫建表插入數據,切換日志進行測試。