MIDDB集群数据库恢复
目录
MIDDB集群数据库恢复... 1
1.安装 NBUcilent 1
2.修改hosts文件... 2
3.修改hosts文件... 2
4.使用bplis读取备份文件... 2
5.起到nomount状态... 3
6.restore controlfile. 3
7.restore database. 3
8.restore archivelog. 4
9.recover database . 5
10.开启集群... 6
1.linux centos 6.6 oracle 11.2.0.3 集群环境:1.53 oraclea 1.54 oracleb
在linux操作系统root用户下安装好NBUcilent ,Linux安装软件包NetBackup_8.0_CLIENTS2.tar.gz
2.在master备份服务器的hosts表上解析客户端的主机名称和IP:
10.10.1.53 oraclea
10.10.1.54 oracleb
3.在10.10.1.53的hosts表上解析备份服务器的主机名称和IP
切换到oracle用户下,执行该脚本,并且在.bash_profile文件下添加环境变量:PATH=$PATH:/usr/openv/netbackup/bin/:/usr/openv/netbackup/bin/goodies:/usr/openv/netbackup/bin/admincmd:/usr/openv/volmgr/bin:/usr/openv/pdde/pdcr/bin
[root@oraclea ~]# su - oracle
[oracle@oraclea
~]$ /usr/openv/netbackup/bin/oracle_link
Sun Jul 9 11:52:15 CST 2017
All Oracle instances should be shutdown before running this script.
Please log
into the Unix system as the Oracle owner for running this script
Do you want to
continue? (y/n) [n] y
LIBOBK path: /usr/openv/netbackup/bin
ORACLE_HOME: /home/u01/app/oracle/product/11.2.0/db_1
Oracle version: 11.2.0.3.0
Platform type: x86_64
Linking LIBOBK:
Moving 64-bit libobk.so to libobk.so.back
ln -s /usr/openv/netbackup/bin/libobk.so64
/home/u01/app/oracle/product/11.2.0/db_1/lib/libobk.so
Done
Please check
the trace file located in /tmp/make_trace.14473
to make sure the linking process was successful.
4.使用bplist 命令读取相关备份文件(注意时间格式,可用bplist -h获取)(在54这部机上操作)
bplist -C
oracle-db2 -s 05/05/2018 -e 10/05/2018 -k oracle_oracle-db2_0_18_middb2__full
-t 4 -R -b -l /
注意箭头处,-C后面加的是客户端名称(此处配置的是0.18的主机名),无论你在哪台机做恢复,-C后面的名称都加原客户端主机名称,即数据库所在服务器的主机名称,而不是加当前的
读取完备份文件后,根据需求将数据库还原到2018年5月5日早上的0点钟
5.新建pfile文件或从原数据库服务器拷贝参数文件参数,接着起到nomount状态
6.利用rman恢复管理器还原控制文件
run{
allocate channel ch00 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=oracle-db2';
restore controlfile from 'cntrl_3751_1_975284099';
release channel ch00;
}
还原后,开到mount状态
RMAN>alter database
mount;
7.进行数据库还原
获取文件路径和ID:
select file#,name from v$datafile;
确定本机存放的ASM磁盘组:
su - gird
asmcmd
ls data2
确定目录后的脚本如下:
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=oracle-db2';
set newname for datafile 1 to
'+data2/middb/datafile/system.268.970705001';
set newname for datafile 2 to
'+data2/middb/datafile/sysaux.260.970705001';
set newname for datafile 3 to '+data2/middb/datafile/undotbs1.256.970705003';
set newname for datafile 4 to '+data2/middb/datafile/users.258.970705003';
set newname for datafile 5 to
'+data2/middb/datafile/undotbs2.262.970705003';
set newname for datafile 6 to '+data2/middb/datafile/mid_data.dbf';
set newname for datafile 7 to '+data2/middb/datafile/mid_index.dbf';
set newname for datafile 8 to '+data2/middb/datafile/mds.258.946840155';
set newname for tempfile 1 to '+data2/middb/tempfile/ydzk_data01.dbf';
restore database until time
"to_date('2018/05/05','yyyy/mm/dd')";
switch datafile all;
switch tempfile all;
release channel ch00;
release channel ch01;
}
8.查询及恢复归档日志
在恢复主机(10.10.1.54)查询归档日志。根据数据库备份的时间点和恢复的时间点确定需要恢复归档日志的最大和最小2个序列号:
alter session set nls_date_format='yyyymmdd hh24:mi:ss';
select max(sequence#),min(sequence#) from v$archived_log where
completion_time>to_date('20180504 22:00:00','yyyymmdd hh24:mi:ss') and
completion_time<to_date('20180505 12:00:00','yyyymmdd hh24:mi:ss') ;
从显示结果来看,我们要恢复的时间点包含在这里面,所以我们还原这部分的归档文件:
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=oracle-db2';
restore archivelog sequence between
509 and 702 thread 1;
restore archivelog sequence between
509 and 702 thread 2;
release channel ch00;
release channel ch01;
}
这里要注意一下,因为是集群所以要双线程恢复归档日志
9.还原的时候报错指示要#481这个归档,继续还原归档编号为:#481-#508:
alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss';
recover database until time '2018/05/04 23:00:00' using backup
controlfile;
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=oracle-db2';
restore archivelog sequence between
481 and 508 thread 1;
restore archivelog sequence between
481 and
508 thread 2;
release channel ch00;
release channel ch01;
}
还原好归档后继续recover:
完成介质恢复,用resetlogs打开
到这里就完成恢复了
10.因为在是集群环境,所以我们要把恢复好的数据库和实例添加到集群环境中去,即用srvctl集中管理
关闭数据库shutdown
immediate
[oracle@oraclea
dbs]$ srvctl add
database -d middb -o /home/u01/app/oracle/product/11.2.0/db_1 -p
+DATA2/middb/spfilemiddb.ora
[oracle@oraclea dbs]$ srvctl add instance -d middb -i middb1 -n oraclea
[oracle@oraclea dbs]$ srvctl add instance -d middb -i middb2 -n oracleb
[oracle@oraclea
dbs]$ srvctl start
database -d middb