2013
全部博文(65)
分类: Oracle
2013-01-22 14:14:32
1.在主库上生成pfile文件,并将pfile文件copy到从库
create pfile='/home/oracle/tmp/initwjldb20130121.ora' from spfile;
2.在standby上创建相关的目录
mkdir -p /home/oracle/app/oracle/flash_recovery_area
mkdir -p /home/oracle/app/oracle/admin/wjldb/udump
cd /home/oracle/app/oracle/admin/wjldb/
mkdir adump bdump cdump dpdump
mkdir -p /home/oracle/oradata/wjldb/
3.将数据库启动到nomount
create spfile from pfile='/home/oracle/tmp/initwjldb20130121.ora';
startup nomount;
4.用rman还原控制文件
rman target /
restore controlfile from '/home/oracle/backup/wjldb/wjldb_CTL_20130116_11963_1.bak'
5.启动到mount
startup mount;
6.还原数据库
list backup;
restore database;
recover database;
如果rman显示expire时,可以用:
RMAN> crosscheck backup;
用crosscheck backup后状态改为AVAILABLE了.
至此,数据库文件已恢复。
(另外,在这步时配置好primary、standby上的tnsnames.ora,后面的配置需要用到)
7.在primary 上重新创建控制文件,替换standby
alter database create standby controlfile as '/home/oracle/tmp/test0118/control01.ctl'
8.在primary上设置参数
alter system set log_archive_config='DG_CONFIG=(wjldb,stdb1)' scope=both;
alter system set log_archive_dest_4='SERVICE=stdb1 VALID_FOR=(ONLINE_LOGFILES, PRIMARY_ROLE) DB_UNIQUE_NAME=stdb1 REOPEN=60 lgwr async' scope=both;
9.在standby 上设置
*.db_unique_name='stdb1'
*.fal_client='stdb1'
*.fal_server='wjldb'
*.local_listener='stdb1'
*.log_archive_config='DG_CONFIG=(wjldb,stdb1)'
*.log_archive_dest_1='LOCATION=/home/oracle/app/oracle/archivelog/wjldb VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=stdb1 REOPEN=30'
*.log_archive_dest_2='SERVICE=wjldb VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=wjldb REOPEN=60 lgwr async'
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.log_file_name_convert='/home/oracle/oradata/wjldb/','/home/oracle/oradata/wjldb/' # 虽然目录可能相同,但最好加上这个参数。
10.将primary 中的密码文件orapwwjldb copy到standby上
11.将standby启动到mount
create pfile='/home/oracle/tmp/initwjldb20130121.ora' from spfile;
startup nomount;
alter database mount standby database;
12.在standby上添加standby log
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/oradata/wjldb/std_redo4.log') SIZE 50M reuse;
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/oradata/wjldb/std_redo5.log') SIZE 50M reuse;
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/oradata/wjldb/std_redo6.log') SIZE 50M reuse;
ALTER DATABASE ADD STANDBY LOGFILE ('/home/oracle/oradata/wjldb/std_redo7.log') SIZE 50M reuse;
13.启动到日志应用
alter database recover managed standby database disconnect from session;