一、E-HR数据库(全备)恢复
目录
一、E-HR数据库(全备)恢复... 1
1. 使用bplist 命令读取备份文件... 1
2. 启动到nomount状态... 2
3. 利用rman还原控制文件... 2
4. 进行数据库还原... 3
5. 恢复数据库。... 4
6. 用resetlogs打开... 6
7. 删除掉所有JOB.. 7
二、E-HR数据库(差异)恢复... 7
1. 使用bplist 命令读取备份文件... 7
2. 启动到nomount状态... 7
3. 利用rman还原控制文件... 8
4. 进行数据库还原... 8
5. 用resetlogs打开... 10
6. 删除掉所有JOB.. 10
1.使用bplist 命令读取备份文件(注意时间格式,可用bplist -h获取)在127中获取备份集名
bplist -C nsdzhncdb01 -s 2018-05-04 -e 2018-05-05 -k oracle_NSDZHNCDB01_0_68_full -t 4 -R -b -l /
注意箭头处,-C后面加的是客户端名称(此处配置的是0.68的主机名),无论你在哪台机做恢复,-C后面的名称都加原客户端主机名称,即数据库所在服务器的主机名称,而不是加当前的
读取完备份文件后,根据需求将数据库还原到2018年5月3日23点
2.首先自己新建pfile文件或直接从原数据库服务器拷贝参数文件并修改相关路劲和参数,接着起到nomount状态
Export ORACLE_SID=orcl 在1.53上做备份测试
3.利用rman恢复管理器还原控制文件
run{
allocate channel ch00 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=nsdzhncdb01';
restore controlfile from 'cntrl_6341_1_975198222';
release channel ch00;
}
还原后,开到mount状态
RMAN> alter database mount;
4.进行数据库还原
Select file#,name from v$datafile;
Select file#,name from v$tempfile;
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=nsdzhncdb01';
set newname for datafile 1 to '+data2/ORCL/datafile/system01.dbf';
set newname for datafile 2 to '+data2/ORCL/datafile/sysaux01.dbf';
set newname for datafile 3 to '+data2/ORCL/datafile/undotbs01.dbf';
set newname for datafile 4 to '+data2/ORCL/datafile/users01.dbf';
set newname for datafile 5 to '+data2/ORCL/datafile/nnc_data01.dbf';
set newname for datafile 6 to '+data2/ORCL/datafile/nnc_index01.dbf';
set newname for datafile 7 to '+data2/ORCL/datafile/nnc_data02.dbf';
set newname for datafile 8 to '+data2/ORCL/datafile/nnc_index02.dbf';
set newname for datafile 9 to '+data2/ORCL/datafile/nnc_data03.dbf';
set newname for datafile 10 to '+data2/ORCL/datafile/nnc_index03.dbf';
set newname for datafile 11 to '+data2/ORCL/datafile/nnc_data001.dbf';
set newname for datafile 12 to '+data2/ORCL/datafile/nnc_data01s.dbf';
set newname for datafile 13 to '+data2/ORCL/datafile/nnc_data1.dbf';
set newname for datafile 14 to '+data2/ORCL/datafile/nnc_data20180306.dbf';
set newname for datafile 15 to '+data2/ORCL/datafile/nnc_index04.dbf';
set newname for tempfile 1 to '+data2/ORCL/datafile/temp01.dbf';
restore database;
switch datafile all;
switch tempfile all;
release channel ch00;
release channel ch01;
}
5.恢复数据库。
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=nsdzhncdb01';
recover database;
release channel ch00;
release channel ch01;
}
报如下错误时,继续恢复:
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=nsdzhncdb01';
recover database until scn 40219596656;
release channel ch00;
release channel ch01;
}
6.完成介质恢复,用resetlogs打开 如报错使用startup upgrade打开:
alter database clear logfile group 5;
alter database clear logfile group 4;
alter database clear logfile group 6;
由于版本不一样,需要如下操作:
startup upgrade;
@$ORACLE_HOME/rdbms/admin/catupgrd.sql;
@$ORACLE_HOME/rdbms/admin/utlrp.sql;
Shutdown immediate
Startup
7.删除掉所有JOB
Select * from dba_jobs; --查看现有JOB
BEGIN
FOR job_id in(select job,log_user,priv_user,schema_user from dba_jobs)
LOOP
IF(job_id.log_user not LIKE '%SYS%') THEN
BEGIN
dbms_ijob.remove(job_id.job);
commit;
end;
end if;
end loop;
end;
/
二、E-HR数据库(差异)恢复
1.使用bplist 命令读取备份文件(注意时间格式,可用bplist -h获取)在127中获取备份集名
bplist -C nsdzhncdb01 -s 2018-05-04 -e 2018-05-05 -k oracle_NSDZHNCDB01_0_68_arch -t 4 -R -b -l /
2.首先自己新建pfile文件或直接从原数据库服务器拷贝参数文件并修改相关路劲和参数,接着起到nomount状态
Export ORACLE_SID=orcl 在1.53上做备份测试
3.利用rman恢复管理器还原控制文件
run{
allocate channel ch00 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=nsdzhncdb01';
restore controlfile from 'cntrl_6384_1_975377266';
release channel ch00;
}
还原后,开到mount状态
RMAN> alter database mount;
4.进行数据库还原
Select file#,name from v$datafile;
Select file#,name from v$tempfile;
run{
allocate channel ch00 type 'SBT_TAPE';
allocate channel ch01 type 'SBT_TAPE';
send 'nb_ora_serv=nbumaster01';
send 'nb_ora_client=nsdzhncdb01';
set newname for datafile 1 to '+data2/ORCL/datafile/system01.dbf';
set newname for datafile 2 to '+data2/ORCL/datafile/sysaux01.dbf';
set newname for datafile 3 to '+data2/ORCL/datafile/undotbs01.dbf';
set newname for datafile 4 to '+data2/ORCL/datafile/users01.dbf';
set newname for datafile 5 to '+data2/ORCL/datafile/nnc_data01.dbf';
set newname for datafile 6 to '+data2/ORCL/datafile/nnc_index01.dbf';
set newname for datafile 7 to '+data2/ORCL/datafile/nnc_data02.dbf';
set newname for datafile 8 to '+data2/ORCL/datafile/nnc_index02.dbf';
set newname for datafile 9 to '+data2/ORCL/datafile/nnc_data03.dbf';
set newname for datafile 10 to '+data2/ORCL/datafile/nnc_index03.dbf';
set newname for datafile 11 to '+data2/ORCL/datafile/nnc_data001.dbf';
set newname for datafile 12 to '+data2/ORCL/datafile/nnc_data01s.dbf';
set newname for datafile 13 to '+data2/ORCL/datafile/nnc_data1.dbf';
set newname for datafile 14 to '+data2/ORCL/datafile/nnc_data20180306.dbf';
set newname for datafile 15 to '+data2/ORCL/datafile/nnc_index04.dbf';
set newname for tempfile 1 to '+data2/ORCL/datafile/temp01.dbf';
set until time ="to_date('2018/05/05 23:00:00','yyyy/mm/dd hh24:mi:ss')";
restore database;
switch datafile all;
switch tempfile all;
recover database;
release channel ch00;
release channel ch01;
}
5.完成介质恢复,用resetlogs打开 如报错使用startup upgrade打开:
alter database clear logfile group 5;
alter database clear logfile group 4;
alter database clear logfile group 6;
由于版本不一样,需要如下操作:
startup upgrade;
@$ORACLE_HOME/rdbms/admin/catupgrd.sql;
@$ORACLE_HOME/rdbms/admin/utlrp.sql;
Shutdown immediate
Startup
6.删除掉所有JOB
Select * from dba_jobs; --查看现有JOB
BEGIN
FOR job_id in(select job,log_user,priv_user,schema_user from dba_jobs)
LOOP
IF(job_id.log_user not LIKE '%SYS%') THEN
BEGIN
dbms_ijob.remove(job_id.job);
commit;
end;
end if;
end loop;
end;
/