该文档是hunter生产环境实施成功版本,按该文档搭建物理DG高可用环境,没有任何问题!原创文档,禁止转载!

DG架构图:

Duplicate搭建physical dataguard实施文档 _Duplicate搭建physical

Standby端:

1、建立相应目录:

mkdir/opt/oracle/oradata/qg_st -p

mkdir/opt/oracle/admin/qg_st –p

mkdir{a,b,c,u,dp}dump

mkdirpfile

mkdir /opt/oracle/flash_recovery_area/QG_ST –p

2、备库端的密码文件:

拷贝主库端的密码文件,修改SID

scp orapwqg_stroot@192.168.1.182: /opt/oracle/product/10g/dbs

3、配置listenertns:

listener配置:

(SID_DESC =

(GLOBAL_DBNAME = qg_st)

(ORACLE_HOME =/opt/oracle/product/10g)

(SID_NAME = qg_st)

)

tns配置(主备库两端都要配):

qgresearch=

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.102)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = research.country)

)

)

qg_st =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.182)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = qg_st)

)

)

4准备备库端参数文件(由于目录不一致,需要指定db_file_name_convertlog_file_name_convertstandby_file_management三个初始化参数):

qg_st.__db_cache_size=1509949440

qg_st.__java_pool_size=33554432

qg_st.__large_pool_size=16777216

qg_st.__shared_pool_size=536870912

qg_st.__streams_pool_size=33554432

*.audit_file_dest='/opt/oracle/admin/qg_st/adump'

*.background_dump_dest='/opt/oracle/admin/qg_st/bdump'

*.compatible='10.2.0.1.0'

*.control_files='/opt/oracle/oradata/qg_st/control01.ctl','/opt/oracle/oradata/qg_st/control02.ctl','/opt/oracle/oradata/qg_st/control03.ctl'#RestoreControlfile

*.core_dump_dest='/opt/oracle/admin/qg_st/cdump'

*.db_block_size=8192

*.db_domain=''

*.db_file_multiblock_read_count=16

*.db_file_name_convert='/u01/oracle/oradata/research/','/opt/oracle/oradata/qg_st/'

*.db_name='research'

*.db_recovery_file_dest='/opt/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=21474836480

*.DB_UNIQUE_NAME='qg_st'

*.dispatchers='(PROTOCOL=TCP)(SERVICE=qg_stXDB)'

*.fal_client='qg_st'

*.fal_server='qgresearch'

*.job_queue_processes=10

*.log_archive_config='DG_CONFIG=(qg_st,research)'

*.log_archive_dest_1='LOCATION=/rman/arch/qg_st/VALID_FOR=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=qg_st'

*.log_archive_dest_2='SERVICE=qgresearchLGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)DB_UNIQUE_NAME=reserach'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='DEFER'

*.log_file_name_convert='/u01/oracle/oradata/research/','/opt/oracle/oradata/qg_st/'

*.open_cursors=300

*.pga_aggregate_target=1671430144

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.sga_target=2147483648

*.standby_file_management='AUTO'

*.undo_management='AUTO'

*.undo_tablespace='UNDOTBS1'

*.user_dump_dest='/opt/oracle/admin/qg_st/udump'

5、将备库端启动到nomount状态:

startup nomount

Primary :

1、检查主库开启归档和forcelogging

2、配置主库端的参数文件

altersystem set LOG_ARCHIVE_CONFIG='DG_CONFIG=(research,qg_st)';

altersystem set LOG_ARCHIVE_DEST_1='LOCATION=/rman/archivelog/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES)DB_UNIQUE_NAME=research';

altersystem set LOG_ARCHIVE_DEST_2='SERVICE=qg_st LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)DB_UNIQUE_NAME=qg_st';

altersystem set LOG_ARCHIVE_DEST_STATE_1=ENABLE;

altersystem set LOG_ARCHIVE_DEST_STATE_2=defer;

altersystem set FAL_SERVER='qg_st';

altersystem set FAL_CLIENT='qgresearch';

altersystem set STANDBY_FILE_MANAGEMENT='AUTO';

3、配置主库的TNS,使primarystandby能相互ping

qgresearch=

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.102)(PORT = 1521))

)

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = research.country)

)

)

qg_st =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.1.182)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = qg_st)

)

)

4、主库进行全库的备份,将备份集拷贝到备库相同的目录下

RUN { 

allocatechannel c1 type disk;

allocatechannel c2 type disk;

sql'alter system archive log current';

backupcurrent controlfile for standby format='/rman/backup/dgbackup_control_%U';

BACKUPFORMAT '/rman/backup/dgbackup_%U_%T' skip inaccessible filesperset 5 DATABASE ;

sql'alter system archive log current';

BACKUPFORMAT '/rman/backup/dgbackup_arch_%U_%T' skip inaccessible filesperset 5ARCHIVELOG ALL ; 

releasechannel c2;

releasechannel c1;

}

过程省略,然后把备份文件SCP  standby相同的目录下,如果不同会出现ORA-19505

5Rmanduplicate数据库,恢复备库

rmantarget / auxiliary sys/mycosoracle@qg_st

duplicatetarget database for standby nofilenamecheck dorecover;

selectopen_mode,database_role from v$database;

6、创建standbyredo,打开主库的日志传输,备库端接收应用redo.

ALTERDATABASE ADD STANDBY LOGFILE GROUP 4 ('/opt/oracle/oradata/qg_st/redo04.log')size 50M;

ALTERDATABASE ADD STANDBY LOGFILE GROUP 5 ('/opt/oracle/oradata/qg_st/redo05.log')size 50M;

ALTERDATABASE ADD STANDBY LOGFILE GROUP 6 ('/opt/oracle/oradata/qg_st/redo06.log')size 50M;

ALTERDATABASE ADD STANDBY LOGFILE GROUP 7 ('/opt/oracle/oradata/qg_st/redo07.log')size 50M;

altersystem set log_archive_dest_state_2=enable;

alter database recover managed standby database disconnectfrom session;

 

7、检查DG搭建成功后的状态

selectmax(sequence#),APPLIED from v$archived_log;

:我们的192.168.1.182上面已经部署了133协议库的物理备库,ORACLE_SID也是research,所以在全国库和协议库主库上增加数据文件时,如果standby_file_management设置为自动,并且没有配置db_file_name_convert时,则都将备库端在与主库相同的目录/u01/oracle/oradata/research下增加数据文件,这将产生数据文件名重名的冲突。