实验参考
http://blog.csdn.net/tianlesoftware/article/details/6232292#
http://kyle.xlau.org/posts/oracle-data-guard-part1.html
有疑问可以查看以上两个网址。
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
1,开启归档(需要关库)
2,alter database force logging; --开启强制归档(不需要单独关库)
3, 创建tnsname.ora 主库建立到orcldg的,备库建立到orcl的。
4,检查监听
4,orcl spfile (主库不要修改db_unique_name的值,备库必须设定)
alter system set db_unique_name='orcl' scope=spfile;
alter system set log_archive_config='DG_CONFIG=(orcl,orcldg)' scope=spfile;
alter system set log_archive_dest_2='SERVICE=orcldg LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,primary_ROLE) DB_UNIQUE_NAME=orcldg' scope=spfile;
alter system set log_archive_dest_state_1= enable scope=spfile;
alter system set log_archive_dest_state_2= enable scope=spfile;
alter system set fal_server=orcldg scope=spfile;
alter system set fal_client=orcl scope=spfile;
alter system set standby_file_management=auto scope=spfile;
alter system set db_file_name_convert='/u01/oradata/','/u01/app/oracle/oradata/ORCL/datafile/' scope=spfile;
alter system set log_file_name_convert='/u01/redolog/','/u01/app/oracle/fast_recovery_area/ORCL/onlinelog/' scope=spfile;
6,创建备库库pfile,并修改
*.audit_file_dest='/u01/app/oracle/admin/orcldg/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/o1_mf_89co5bbm_.ctl','/u01/app/oracle/fast_recovery_area/o1_mf_89co5bjs_.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/oradata'
*.db_domain=''
*.db_file_name_convert='/u01/app/oracle/oradata/ORCL/datafile/','/u01/oradata/'
*.db_name='orcl'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='orcldg'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fal_client='orcldg'
*.fal_server='orcl'
*.log_archive_config='DG_CONFIG=(orcldg,orcl)'
*.log_archive_dest_2='SERVICE=orcl LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,primary_ROLE) DB_UNIQUE_NAME=orcl'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_file_name_convert='/u01/app/oracle/fast_recovery_area/ORCL/onlinelog/','/u01/redolog/'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
7,备库创建创建环境变量
export PATH
export ORACLE_SID=orcldg
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/11.2.0/db_1
export PATH=$ORACLE_HOME/bin:$PATH
7,备库创建pfile pfiledg.ora
8,创建ump文件夹 mkdir -p /u01/app/oracle/admin/orcldg/{a,b,c,u}dump (以及controlfile路径)
9,starup nomount pfile='/tmp/pfiledg.ora' ; --备库
ORA-00845: MEMORY_TARGET not supported on this system --删除 *.memory_target=842006528 参数。
10,主库创建orcldg log,比rendolog多一组,且和redo log大小一样,路径在参数文件的转换目录参数里log_file_name_convert (dupilitry 后standby redolog 也会自动转换到备库上)
alter database add orcldg logfile group 4('/u01/app/oracle/fast_recovery_area/ORCL/onlinelog/stdby_redo04.log') size 50M;
alter database add orcldg logfile group 5('/u01/app/oracle/fast_recovery_area/ORCL/onlinelog/stdby_redo05.log') size 50M;
alter database add orcldg logfile group 6('/u01/app/oracle/fast_recovery_area/ORCL/onlinelog/stdby_redo06.log') size 50M;
alter database add orcldg logfile group 7('/u01/app/oracle/fast_recovery_area/ORCL/onlinelog/stdby_redo07.log') size 50M;
11,检查两者监听是否互相都可以tnsping通
12,重启主库 shutdown immediate ,startup
13, 备库执行(连接的当,主库备库都可以执行)11g可以直接将主库恢复到备库。
rman auxiliary sys/oracle@orcldg target sys/oracle@orcl nocatalog
duplicate target database for standby from active database;
--多通道
run
{
allocate channel chan1 type disk;
allocate channel chan2 type disk;
allocate channel chan3 type disk;
allocate channel chan4 type disk;
allocate auxiliary channel aux1 type disk;
allocate auxiliary channel aux2 type disk;
allocate auxiliary channel aux3 type disk;
allocate auxiliary channel aux4 type disk;
duplicate target database for orcldg from active database;
}
14,
alter database open read only;
15,--应用归档
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
--注明:using current logfile
( alter database recover managed standby database disconnect from session;
也可以使用alter database recover managed standby database using current logfile disconnect from session;应用日志。
没有using current logfile是去apply standby archived log.
有using current logfile是当日志传到standby redo log的时候就去应用,是real-time的,必须要有standby redo log.)
--停止应用归档 alter database recover managed standby database cancel;
16,--检查
Standby:
SQL> select open_mode from v$database;
select * from v$dataguard_config;
问题:
0,RMAN-04006: error from auxiliary database: ORA-12528: TNS:listener: all appropriate instances are blocking new connections
--备库静态注册监听
1,ORA-17628: Oracle error 19505 returned by remote Oracle server
--the dest on standby for controlfile must be exited
2, ORA-01103: database name 'ORCL' in control file is not 'ORCLDG'
--备库db_name和主库应该一至
3.PLS-00201: identifier 'DBMS_RCVCAT.GETDBID' must be declared
--如果使用的是非catalog,在rman 连接时,加上nocatalog关键字
4,RMAN-05001: auxiliary file name/u01/app/oracle/oradata/dg/users01.dbf conflicts with a file used by the targetdatabase
-- 在执行duplicate的时候,如果源库和目标库目录相同,那么在duplicate 时,需要加上nofilenamecheck。
--或者检查db_file_name_convert 、log_file_name_convert参数设置是否正确(注意是对方服务器路径在前面)
5,dg nomount和mount状态 sqlplus不能访问dg,rman可以连接。