run{
allocate channel ch1 device type disk ;
sql 'alter system switch logfile';
backup database tag 'fulbak_dbf' format ' /home1/zz/bak/FULLBAK_%d_%T_%s_%p.dbf'
include current controlfile;
sql 'alter system switch logfile';
backup archivelog all delete all input tag 'fulbak_arch' format ' /home1/zz/bak/FULLBAK_%d_%T_%s.arch';
release channel ch1;
crosscheck backup;
delete noprompt obsolete;
delete noprompt expired backup;
crosscheck archivelog all;
delete noprompt expired archivelog all;
}
alter database create standby controlfile as '/home1/zz/bak/standby.ctl'
4,创建跟踪目录
mkdir adump bdump cdump udump dpdump
5,配置网络,保证主备库之间正常通信
6,创建密码文件
文件名字一定规范,且密码得一致
否则会出现错误:ORA-01031: insufficient privileges
orapwd file='/home/oracle/product/10.2.0/db_1/dbs/orapwddg2' password=xxx entries=5
7,创建备库初始化参数文件
将主库的pfile文件修改并添加以下参数
db_unique_name=dg2
log_archive_config='dg_config=(dg1,dg2)'
*.log_archive_dest_1='location=/home1/zz/arch_dg2
valid_for=(all_logfiles,all_roles)
db_unique_name=dg2'
log_archive_dest_2='service=dg1 lgwr async
valid_for=(online_logfiles,primary_role)
db_unique_name=dg1'
log_archive_dest_state_1=enable
log_archive_dest_state_2=enable
fal_server=dg1
fal_client=dg2
db_file_name_convert='/home/oracle/oradata/dg1','/home/oracle/oradata/dg2'
log_file_name_convert='/home/oracle/oradata/dg1','/home/oracle/oradata/dg2'
8,将第三步创建的备库控制文件移动到初始化参数文件指定的位置
9,使用rman生成standby 数据库
备库必须启动到nomout状态
rman target sys/xxx@dg1 auxiliary /
RMAN> duplicate target database for standby;
10,修改主库的参数
alter system set db_unique_name=dg1 scope=spfile;
alter system set log_archive_config='dg_config=(dg1,dg2)';
alter system set log_archive_dest_1 ='location=/home1/zz/arch_dg1 valid_for=(all_logfiles,all_roles) db_unique_name=dg1';
alter system set log_archive_dest_2='service=dg2 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=dg2';
alter system set fal_client=dg1;
alter system set fal_server=dg2;
alter system set db_file_name_convert='/home/oracle/oradata/dg1','/home/oracle/oradata/dg2' scope=spfile
alter system set log_file_name_convert='/home/oracle/oradata/dg1','/home/oracle/oradata/dg2' scope=spfile
由于前面备份主库的时候将11,12号归档文件删除了,而备库需要这两个归档文件,
使用rman将其恢复restore archivelog from sequence 11;
11, 将备库启动redo 应用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
此时物理备库搭建完毕!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23073818/viewspace-710475/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23073818/viewspace-710475/