RMAN异地还原
RMAN
在没有
catalog
的条件下还原是比较复杂的,哎!麻烦咱也要做啊。
先来说说前提条件
1
两台机器
OS
和
Oracle
版本相同,要对新
Server
的
Oracle_Home,Oracle_BASE
,
SID
都要相同才行。最后
OS
的名字最好也相同,这样
Enterprise Manager
才可以使用。
2
在恢复主机上建立与主服务器相同的目录结构,用以存放数据文件,后台日志等
3
将备份
集
COPY
到第二台机器,目录相同
4
core_dump_dest
,
log_archive_dest
,
audit_file_dest
,
user_dump_dest
,
background_dump_dest
这几个参数路径相同。这个工作在安装完成新的数据库后做调整,我在后面会详细描叙。
再描述一下我需要还原的那台
oracle
数据库的环境
OS
版本
linux RHEL AS4
Oracle
版本
10.2.0.3
安装路径为
/home/app/oracle
(
新oracle安装的路径也必须是这个,Oracle_Home,Oracle_BASE ,SID相同)
Spfile
文件
(
这些参数是需要在新oracle上调整的参数)
*.core_dump_dest='/oradb/S1MES/admin/cdump'
*.log_archive_dest='/oradb/S1MES/archivelog'
*.audit_file_dest='/oradb/S1MES/admin/adump'
*.user_dump_dest='/oradb/S1MES/admin/udump'
*.background_dump_dest='/oradb/S1MES/admin/bdump'
Oracle
安装就不说了,诸位看官比我熟悉,安装完成把
rman
备份集
copy
到新
server
上。
Ps
:
这里还需要
copy
当前的归档日志
到新server上,路径保持不变。这样才能将数据库还原到当前的时间点。我们的生产库每天rman后会删除过期的归档日志,所以直接copy所有的归档日志即可。
调整参数
先建立如下目录
mkdir -p /oradb/S1MES/admin/
mkdir /oradb/S1MES/archivelog
mkdir /oradb/S1MES/admin/adump
mkdir /oradb/S1MES/admin/bdump
mkdir /oradb/S1MES/admin/cdump
mkdir /oradb/S1MES/admin/udump
安装完成后调整参数
alter system set core_dump_dest = '/oradb/S1MES/admin/cdump' scope=spfile
alter system set log_archive_dest = '/oradb/S1MES/archivelog' scope=spfile
alter system set audit_file_dest = '/oradb/S1MES/admin/adump' scope=spfile
alter system set user_dump_dest = '/oradb/S1MES/admin/udump' scope=spfile
alter system set background_dump_dest = '/oradb/S1MES/admin/bdump' scope=spfile
关闭数据库,现在两个
oracle
的环境已经相同了
Hoho,下面开始还原咯
下面的操作全部是在新的server完成
Startup
打开数据库
Create pfile= ‘/home/oracle/initS1MES.ora’ from spfile
Shutdown immediate
关闭数据库
RMAN> set DBID=3572473887
executing command: SET DBID
RMAN> connect target /
connected to target database: (not mounted)
RMAN> startup force nomount pfile='/home/oracle/initS1MES.ora';
Oracle instance started
Total System Global Area 285212672 bytes
Fixed Size 1218968 bytes
Variable Size 88082024 bytes
Database Buffers 188743680 bytes
Redo Buffers 7168000 bytes
RMAN> restore spfile from
2> '/home/app/oracle/product/10.2.0/db_1/dbs/S1-c-3572473887-20081030-00';
Starting restore at 30-OCT-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: autobackup found: /home/app/oracle/product/10.2.0/db_1/dbs/S1-c-3572473887-20081028-00
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 30-OCT-08
RMAN> startup force nomount
RMAN> restore controlfile from
'/home/app/oracle/product/10.2.0/db_1/dbs/S1-c-3572473887-20081030-00'
RMAN> startup force mount
RMAN> list backup;
RMAN> restore database;
RMAN> recover database;
RMAN> alter database open resetlogs;
路漫漫其修远兮,吾将还原进行到底!漫长的等待还原终于完成了。
Satrtup
打开还原出来的数据库,
Sqlplus
、
toad
、
oracle client
端连接皆正常。本以为大功告成,
Enterprise Manager
打开居然是显示的是原来
server
的信息。现在我们再来想一下,我们现在的控制文件还是原来的控制文件啊,显示的信息假如不是原来
server
的信息才是不正常的。怎样才能显示正确的信息呢,当然是重建控制文件啊!
重建控制文件
重建控制文件:
将数据库打开到
mount
下,
Alter database backup controlfile to trace as
‘
/tmp/cnt.ctl
’
,
Shutdown immediate
对
cnt.ctl
进行修改数据库名称
运行
cnt.ctl
重新创建数据库
control file.
Ps
:
如果数据库
Server
名被改后,则
OMS,Dbconsole
都将不能用
:
因为这些都是通过
机器名来创建的服务。之前我已经提到
server
名最好改成和原来的
server
相同
具体来说说这个cnt.ctl
Alter database backup controlfile to trace as
‘
/tmp/cnt.ctl
’
,
此时的
cnt.ctl
是不能直接运行的。需要做一些修改才能使用。
可以看一下,
cnt.ctl
中
有两个重复的内容,保留一份就可以了。
然后修改 :
把
reuse
去掉,把
archive log
去掉
,
中间不能有空行
,
不要用recover database。
中间空行去掉:
不要下面语句:
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP', .');
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE','DISK TO ''S1-%F''');
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('DEVICE TYPE','DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1');
RECOVER DATABASE USING BACKUP CONTROLFILE
下面附上我修改好的文件,以备参考
STARTUP NOMOUNT
CREATE CONTROLFILE DATABASE "S1MES" NORESETLOGS
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 300
MAXINSTANCES 8
MAXLOGHISTORY 2920
LOGFILE
GROUP 1 (
'/oradb/S1MES/oradata/redo01a.log',
'/oradb/S1MES/oradata/redo01b.log'
) SIZE 50M,
GROUP 2 (
'/oradb/S1MES/oradata/redo02a.log',
'/oradb/S1MES/oradata/redo02b.log'
) SIZE 50M,
GROUP 3 (
'/oradb/S1MES/oradata/redo03a.log',
'/oradb/S1MES/oradata/redo03b.log'
) SIZE 50M,
GROUP 4 (
'/oradb/S1MES/oradata/redo04a.log',
'/oradb/S1MES/oradata/redo04b.log'
) SIZE 50M,
DATAFILE
'/oradb/S1MES/oradata/system01.dbf',
'/oradb/S1MES/oradata/undotbs01.dbf',
'/oradb/S1MES/oradata/sysaux01.dbf',
'/oradb/S1MES/oradata/users01.dbf',
'/oradb/S1MES/oradata/EMES.dbf',
'/oradb/S1MES/oradata/EMES200801_02.DBF',
'/oradb/S1MES/oradata/emes200802_01.dbf',
'/oradb/S1MES/oradata/INDX03.DFS',
'/oradb/S1MES/oradata/indx04.dbf',
'/oradb/S1MES/oradata/INDX05.DBF',
'/oradb/S1MES/oradata/emes200802_02.dbf',
'/oradb/S1MES/oradata/EMES200801_03.DBF',
'/oradb/S1MES/oradata/emes200803_01.dbf',
'/oradb/S1MES/oradata/emes200803_02.dbf',
'/oradb/S1MES/oradata/indx_01.dbf',
'/oradb/S1MES/oradata/indx_02.dbf',
'/oradb/S1MES/oradata/indx_03.dbf',
'/oradb/S1MES/oradata/indx06.dbf',
'/oradb/S1MES/oradata/indx07.dbf',
'/oradb/S1MES/oradata/indx08.dbf',
'/oradb/S1MES/oradata/indx09.dbf',
'/oradb/S1MES/oradata/indx10.dbf',
'/oradb/S1MES/oradata/emes200804_01.dbf',
'/oradb/S1MES/oradata/emes200804_02.dbf',
'/oradb/S1MES/oradata/emes200804_03.dbf',
'/oradb/S1MES/oradata/bbsc.dbf',
'/oradb/S1MES/oradata/EMES200805_01.dbf',
'/oradb/S1MES/oradata/EMES200805_02.dbf',
'/oradb/S1MES/oradata/indx_11.dbf',
'/oradb/S1MES/oradata/EMES200806_01.dbf',
'/oradb/S1MES/oradata/EMES200806_02.dbf',
'/oradb/S1MES/oradata/indx_12.dbf',
'/oradb/S1MES/oradata/EMES200807_01.dbf',
'/oradb/S1MES/oradata/EMES200807_02.dbf',
'/oradb/S1MES/oradata/EMES200808_01.dbf',
'/oradb/S1MES/oradata/EMES200808_02.dbf',
'/oradb/S1MES/oradata/EMES200809_01.dbf',
'/oradb/S1MES/oradata/EMES200809_02.dbf',
'/oradb/S1MES/oradata/EMES200810_01.dbf',
'/oradb/S1MES/oradata/EMES200810_02.dbf',
'/oradb/S1MES/oradata/ndx_13.dbf',
'/oradb/S1MES/oradata/indx_14.dbf',
'/oradb/S1MES/oradata/indx_15.dbf',
'/oradb/S1MES/oradata/indx_16.dbf',
'/oradb/S1MES/oradata/indx_17.dbf',
'/oradb/S1MES/oradata/indx_18.dbf',
'/oradb/S1MES/oradata/indx_19.dbf',
'/oradb/S1MES/oradata/indx_20.dbf',
'/oradb/S1MES/oradata/EMES200811_01.dbf',
'/oradb/S1MES/oradata/EMES200811_02.dbf',
'/oradb/S1MES/oradata/indx01.dbf',
'/oradb/S1MES/oradata/indx02.dbf',
'/oradb/S1MES/oradata/users02.dbf',
'/oradb/S1MES/oradata/users03.dbf',
'/oradb/S1MES/oradata/EMES200801_01.DBF'
CHARACTER SET ZHS16CGB231280
;
ALTER DATABASE OPEN;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oradb/S1MES/oradata/temp02.dbf'
Size 2097160192 REUSE AUTOEXTEND . NEXT 655360 MAXSIZE 2548M;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oradb/S1MES/oradata/temp01.dbf'
Size 50979712 REUSE AUTOEXTEND . NEXT 655360 MAXSIZE 767M;
控制文件新建完成了,但是你的
Enterprise manger
还是不能正常显示的。这也太折腾人了吧,不急不急,我们就要大功告成了啊。
配置dbconsole
重新配置
dbconsole
的步骤
emca -repos drop
emca -repos create
emca -config dbcontrol db
emctl start dbconsole
到了这里,恭喜恭喜,大功告成!