1.PRIMARY
原来的主库,新增新备库的配置信息。
SQL> alter system set log_archive_dest_state_3=defer;
SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORA11G_PRIM,ORA11G_STBY,ORA11G_STBY2)';
SQL> alter system set LOG_ARCHIVE_DEST_3='SERVICE=ORA11G_STBY2 ASYNC DELAY=60 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORA11G_STBY2';
2.FIRST STANDBY
第一套备库调整配置信息。
SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORA11G_PRIM,ORA11G_STBY,ORA11G_STBY2)';
3.SECOND STANDBY
配置第二套备库。由于第一套备库和第二套备库在同一台物理机上,因此需要注意目录隔离,避免新备库破坏就备库的文件。
3.1 参数文件
[oracle@oradb2 ~]$ export ORACLE_SID=ora11g
SQL> create pfile='/home/oracle/11g2.pfile' from spfile;
[oracle@oradb2 ~]$ vi 11g2.pfile
*.audit_file_dest='/oracle/app/oracle/admin/ora11g2/adump'
*.control_files='/oradata/database/11g/ora11g2/control01.ctl','/oradata/database/11g/ora11g2/control02.ctl'
*.DB_UNIQUE_NAME='ORA11G_STBY2'
*.fal_server='ORA11G_PRIM'
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(ORA11G_PRIM,ORA11G_STBY,ORA11G_STBY2)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/oradata/archive/11g2 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ORA11G_STBY2'
*.LOG_ARCHIVE_DEST_2='SERVICE=ORA11G_PRIM ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORA11G_PRIM'
*.dg_broker_start=false
*.db_file_name_convert='/oradata/database/11g/ora11g/','/oradata/database/11g/ora11g2/'
*.log_file_name_convert='/oradata/database/11g/ora11g/','/oradata/database/11g/ora11g2/'
通过参数文件启动新备库到nomount状态
[oracle@oradb2 ~]$ export ORACLE_SID=ora11g2
SQL> startup nomount pfile='/home/oracle/11g2.pfile';
SQL> create spfile from pfile='/home/oracle/11g2.pfile';
SQL> startup force nomount;
3.2 口令文件
[oracle@oradb2 ~]$ cd $ORACLE_HOME/dbs
[oracle@oradb2 dbs]$ cp orapwora11g orapwora11g2
3.3 网络配置
[oracle@oradb2 dbs]$ cd $ORACLE_HOME/network/admin
[oracle@oradb2 admin]$ vi listener.ora
新增新备库的配置信息,注册到静态监听中。
(SID_DESC =
(GLOBAL_DBNAME = ORA11G_STBY2)
(ORACLE_HOME = /oracle/app/oracle/product/database/11g)
(SID_NAME = ora11g2)
)
(SID_DESC =
(GLOBAL_DBNAME = ORA11G_STBY2_DGMGRL)
(ORACLE_HOME = /oracle/app/oracle/product/database/11g)
(SID_NAME = ora11g2)
)
重启监听,使配置生效,检查所有配置的静态监听生效
[oracle@oradb2 ~]$ lsnrctl stop
[oracle@oradb2 ~]$ lsnrctl start
[oracle@oradb2 ~]$ lsnrctl status
Services Summary...
Service "ORA11G_STBY" has 2 instance(s).
Instance "ora11g", status UNKNOWN, has 1 handler(s) for this service...
Service "ORA11G_STBY2" has 2 instance(s).
Instance "ora11g2", status UNKNOWN, has 1 handler(s) for this service...
Service "ORA11G_STBY2_DGMGRL" has 1 instance(s).
Instance "ora11g2", status UNKNOWN, has 1 handler(s) for this service...
Service "ORA11G_STBY_DGMGRL" has 1 instance(s).
Instance "ora11g", status UNKNOWN, has 1 handler(s) for this service...
新增新备库tns配置信息。
[oracle@oradb2 admin]$ vi tnsnames.ora [主库也需要新增该配置]
ORA11G_STBY2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = oradb2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORA11G_STBY2)
)
)
3.4 测试数据库连接 [主库和新备库都需要进行测试]
[oracle@oradb2 ~]$ sqlplus sys/oracle@ORA11G_STBY2 as sysdba
[oracle@oradb2 ~]$ sqlplus sys/oracle@ORA11G_PRIM as sysdba
3.5 新备库进行复制主库操作
注意此处连接到新的备库。
[oracle@oradb2 ~]$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS';
[oracle@oradb2 ~]$ rman target sys/oracle@ORA11G_PRIM auxiliary sys/oracle@ORA11G_STBY2
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 4;
RMAN> DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE DORECOVER NOFILENAMECHECK;
3.6 启动新备库数据库并启动实时恢复
[oracle@oradb2 ~]$ export ORACLE_SID=ora11g2
SQL> alter database open;
SQL> alter database recover managed standby database using current logfile disconnect from session;
4.将新备库添加到dg broker中
[oracle@oradb2 ~]$ export ORACLE_SID=ora11g2
SQL> alter system set dg_broker_start=true;
[oracle@oradb2 ~]$ dgmgrl /
DGMGRL> show configuration;
DGMGRL> ADD DATABASE 'ORA11G_STBY2' AS CONNECT IDENTIFIER IS 'ORA11G_STBY2' MAINTAINED AS PHYSICAL;
DGMGRL> ENABLE DATABASE 'ORA11G_STBY2';
5. 进行主备切换操作
通过DG Broker管理的DG环境,在进行主备切换过程中,参数会自动进行维护,例如fal_server,log_archive_dest_2,log_archive_dest_3等。
DGMGRL> show configuration;
Configuration - ora11g_dg
Protection Mode: MaxPerformance
Databases:
ORA11G_PRIM - Primary database
ORA11G_STBY - Physical standby database
ORA11G_STBY2 - Physical standby database
DGMGRL> connect sys/oracle@ORA11G_STBY
DGMGRL> SWITCHOVER TO 'ORA11G_STBY';
切记在switchover时,使用用户名和口令连接到dgmgrl,否则会造成切换后,无法启动远程数据库,导致切换失败。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。