1.主库在线改动spfile參数
alter database force logging;
alter system set log_archive_config='DG_CONFIG=(dg,dgdg)';alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=dg';
alter system set log_archive_dest_2='SERVICE=dgdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dgdg';
alter system set log_archive_dest_state_1='ENABLE';
alter system set log_archive_dest_state_2='ENABLE';
alter system set standby_file_management='AUTO';
alter system set fal_server='DGDG';
需重新启动參数:
alter system set db_file_name_convert='C:appadministratororadatadg','+data/dg/datafile' scope=spfile;alter system set log_file_name_convert='C:appadministratororadatadg','+data/dg/onlinelog' scope=spfile;
2.创建pfile
SQL> create pfile from spfile;
3.改动备库用的pfile
*.__db_cache_size=0
*.__java_pool_size=0*.__large_pool_size=0
*.__oracle_base='C:appadministrator'#ORACLE_BASE set from environment
*.__pga_aggregate_target=0
*.__sga_target=0
*.__shared_io_pool_size=0
*.__shared_pool_size=0
*.__streams_pool_size=0
*.audit_file_dest='C:appadministratoradmindgadump'
*.audit_trail='db'
*.cluster_database=false --说明是单实例数据库,否则启动会报错
*.compatible='11.2.0.0.0'
*.control_files='C:appadministratororadatadgcontrol01.ctl','C:appadministratororadatadgcontrol02.ctl'
*.db_block_size=8192
*.db_create_file_dest='C:appadministratororadata'
*.db_domain=''
*.db_name='dg'
*.db_recovery_file_dest='C:appadministratorflash_recovery_area'
*.db_recovery_file_dest_size=3908042752
*.diagnostic_dest='C:appadministrator'
*.dispadghers='(PROTOCOL=TCP) (SERVICE=DGXDB)'
*.fal_server='dg'
*.instance_number=1
*.log_archive_config='DG_CONFIG=(dg,dgdg)'
*.log_archive_dest_1='LOCATION=c:archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=dgdg'
*.log_archive_dest_2='SERVICE=dg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dg'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='ARC%S_%R.%T'
*.memory_target=8577351680
*.nls_language='SIMPLIFIED CHINESE'
*.nls_territory='CHINA'
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.db_file_name_convert='+data/dg/datafile','C:appadministratororadatadg'
*.log_file_name_convert='+data/dg/onlinelog','C:appadministratororadatadg'
*.db_unique_name=dgdg --复制过来的pfile假设不设置这个參数。默认的值是dg
4.改动tnsnamesl.ora
# tnsnames.ora Network Configuration File: C:appadministratorproduct11.2.0dbhome_1 etworkadmin nsnames.ora
# Generated by Oracle configuration tools.dg =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dg)
)
)
DGDG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = dgP)(HOST = dgdg)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dg)
)
)
5.改动listener.ora(仅仅给备库用,主库能够不配置静态监听)
# listener.ora Network Configuration File: C:appadministratorproduct11.2.0dbhome_1NETWORKADMINlistener.ora# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = dg)
(ORACLE_HOME = C:appadministratorproduct11.2.0dbhome_1)
(SID_NAME = dg)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgdg)(PORT = 1521))
)
ADR_BASE_LISTENER = C:appadministratorproduct11.2.0dbhome_1log
6.备库创建相关文件夹
c:archivelog --指定一个本地归档路径,备库接收到的归档日志和自己生成的归档日志都放在这里c:appadministratoradmindgadump
c:appadministratoradmindgdpdump
c:appadministratoradmindghdump
c:appadministratoradmindgpfile
c:appadministratorflash_recovery_area
c:appadministratororadatadg
7.主库做rman全备
RMAN> backup as compressed backupset full database format 'c:akfull_%d_%I_%T_%U'8.主库创建备库控制文件
SQL> alter database create standby controlfile as 'c:control01.ctl';SQL> alter database create standby controlfile as 'c:control02.ctl';
9.复制备份文件、password文件、pfile文件、tnsnames.ora、listener.ora到备库对应位置
10.备库创建实例
oradim -new -sid dg -startmode manual -spfile;11.启动监听
lsntrctl start12.启动实例到mount
set oracle_sid=dgsqlplus / as sysdba
SQL> startup mount
13.恢复数据库
RMAN> catalog start with 'd:ak'; --不指定会提示无法恢复数据库RMAN> restore database;
14.备库加入standby redo logfile
SQL> alter database add standby logfile 'C:appadministratororadatadgstd_05.log' size 50m;SQL> alter database add standby logfile 'C:appadministratororadatadgstd_06.log' size 50m;
SQL> alter database add standby logfile 'C:appadministratororadatadgstd_07.log' size 50m;
SQL> alter database add standby logfile 'C:appadministratororadatadgstd_08.log' size 50m;
SQL> alter database add standby logfile 'C:appadministratororadatadgstd_09.log' size 50m;
15.启用redo apply
SQL> alter database recover managed standby database disconnect from session;16.给备库创建spfile(可选)
SQL> create spfile from pfile;以下记录几个在整个配置过程中遇到的问题:
1.用opatch apply命令无法打patch
出现原因:11.2.0.3默认装完后的opatch版本号是11.2.0.1.7,我要打的patch 27须要在这个版本号之上才干够
解决方法:解压高版本号的opatch安装包后覆盖原opatch文件夹
2.备库alert.log报警提示无法找到控制文件自己主动备份路径
出现原因:RAC主库之前部署过自己主动RMAN备份脚本,指定了控制文件自己主动备份路径。但备库并没有此路径
解决方法:进入RMAN,改动该项參数为备库存在的文件夹3.參数设置错误而引起GAP,导致自己主动备份脚本停止执行
alter system set log_archive_dest_1='LOCATION=C:archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=dg';
作为RAC。归档路径在本地的话。其它节点就无法读取。发现后又一次设置为USE_DB_RECOVERY_FILE_DEST后,那些在本地的归档日志就成为GAP而无法传递到备库
解决方法:手工复制全部提示缺失的xxx归档到指定位置,再手动运行RMAN自己主动备份脚本说明:因为RMAN自己主动备份脚本里配置了冗余7份,而之搭建DG时手动运行了全库备份,这些手动备份也是算在7份冗余之内的,为了不占用正常备份的配额。DG搭建完毕后建议物理删除。然后再crossecheck并清理掉
4.主、备库的alert.log常常会出现TNS错误
fatal NI connect error 12547
TNS-12547 TNS : 丢失连接
ns secondary err code : 12560
ns main err code : 517
TNS-00517 TNS : 丢失连接
nt secondary err code : 54
nt OS err code : 0
出现原因:节点2没有配置tnsnames.ora,造成thread 2的归档日志无法传递到备库,同一时候也会造成主库日志能传递过去,但无法应用。
解决方法: 把节点1的tnsnames.ora直接复制一个到节点2说明:事实上这个也是造成备库应用出现GAP的最大原因,因为节点2日志传递不到备库,尽管之前的几个归档日志序列对应的applied列的属性值都是YES,可是会造成节点1的日志也不应用,哪怕在节点1切了非常多次归档。applied列始终会显示NO,但日志都是能够正常传递过去的
版权声明:本文博主原创文章,博客,未经同意不得转载。