189 8069 5689

Oracle12CRac到Rac搭建ADG

1、环境介绍
搭建一套ADG灾备环境。主库环境为12.1.2.0 RAC,备库同主库,软件补丁均已安装。
2、配置步骤
2.1 归档

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名与空间、网页空间、营销软件、网站建设、乌海网站维护、网站推广。

 select log_mode from v$database;  #####是否为归档模式
 alter database force logging;           #####强制归档

2.2 主库standby log

alter database add standby logfile thread 1 group 5  ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 6  ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 7  ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 8  ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 9  ('+DATADG') size 2048M;
alter database add standby logfile thread 1 group 10 ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 11    ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 12    ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 13    ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 14    ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 15    ('+DATADG') size 2048M;
alter database add standby logfile thread 2 group 16    ('+DATADG') size 2048M;

3、文件
3.1 密码文件

拷贝主库密码文件到备库,最开始放在$ORACLE_HOME/dbs目录下,后续配置完成后,需要将密码文件存放在ASM磁盘组中并进行改名。
 scp orapwbmacdb IP: $ORACLE_HOME/dbs1
 ASMCMD> pwcopy /u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwbmacdb1 +datadg/bmacdbdg/password/orapwbmacdb
copying /u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapwbmacdb1 -> +datadg/bmacdbdg/password/orapwbmacdb

3.2 参数文件

拷贝主库参数文件到备库,放在$ORACLE_HOME/dbs目录下,恢复完成后,需要将参数文件存放在ASM磁盘组中,并通过pfile指定其位置。参数文件内容如下:
*.audit_file_dest='/u01/app/oracle/admin/bmacdb/adump'
*.control_files='+DATADG/BMACDB/control01.ctl','+DATADG/BMACDB/control02.ctl'
*.db_file_name_convert='+DATADG/BMACDB/DATAFILE/','+DATADG/BMACDB/DATAFILE/','+SSDDG/BMACDB/DATAFILE/','+DATADG/BMACDB/DATAFILE/','+DATADG/bmacdb/','+DATADG/BMACDB/DATAFILE/'
*.db_unique_name='bmacdbdg'
*.log_archive_config='DG_CONFIG=(bmacdb,bmacdbdg)'
*.log_archive_dest_1='LOCATION=+ARCHDG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=bmacdbdg'
*.log_archive_dest_2='SERVICE=BMACDB1 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=BMACDB'
*.log_file_name_convert='+SSDDG/bmacdb/','+LOGDG/BMACDB/ONLINELOG/'
*.fal_server='BMACDB'
以上参数时我们需要修改的地方。

3.3 目录结构

mkdir -p /u01/app/oracle/admin/bmacdb/adump
ASM:
+DATADG/BMACDB/DATAFILE
+LOGDG/BMACDB/ONLINELOG
创建完目录结构后,启动数据库到nomount状态。
startup nomount

3.4 配置监听

在配置ADG开始阶段,需要在备库静态注册监听,搭建完成后,可以将静态注册信息删掉。静态注册信息如下:/u01/app/12.1.0/grid/network/admin/listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = bmacdbdg)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
      (SID_NAME = bmacdb1)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
    )
  )
配置完监听后启动监听,静态监听信息如下:
Service "bmacdbdg" has 1 instance(s).
  Instance "bmacdb1", status UNKNOWN, has 1 handler(s) for this service...
主库连接串配置
主库tnsnames.ora新增到备库的连接串,并且在RAC两个节点同时新增:
BMACDBDG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bmacdbdg)
    )
  )
配置完成后,进行连通性测试:
sqlplus sys/password@BMACDBDG as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 18 14:28:16 2019
Copyright (c) 1982, 2014, Oracle.  All rights reserved.

备库连接串配置
备库tnsnames.ora新增到主库的连接串,并且在RAC两个节点同时新增:
BMACDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = IP地址)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bmacdb)
    )
  )
配置完成后,进行连通性测试:
sqlplus sys/password@BMACDB as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 18 14:29:29 2019
Copyright (c) 1982, 2014, Oracle.  All rights reserved.

4、恢复备库

source /home/oracle/.profile 
rman target sys/password@BMACDB auxiliary sys/password@BMACDBDG <

5、修改主库参数

alter system set log_archive_config='dg_config=(bmacdb,bmacadg,bmacdg,bmacdbdg)';
alter system set log_archive_dest_4='service=BMACDBDG async valid_for=(online_logfiles,primary_role) db_unique_name=bmacdbdg';

6、备库spfile

SQL> create spfile ='+datadg/bmacdbdg/spfilebmacdb.ora' from pfile;

File created.
oracle@bmacdrdb1:/home/oracle>cd $ORACLE_HOME/dbs
oracle@bmacdrdb1:/u01/app/oracle/product/12.1.0/dbhome_1/dbs>cat initbmacdb1.ora
spfile ='+datadg/bmacdbdg/spfilebmacdb.ora'

7、备库RAC添加资源

srvctl add database -db bmacdbdg -dbname bmacdb -oraclehome /u01/app/oracle/product/12.1.0/dbhome_1 -dbtype RAC -role PHYSICAL_STANDBY
srvctl add instance -db bmacdbdg -instance bmacdb1 -node bmacdrdb1 
srvctl add instance -db bmacdbdg -instance bmacdb2 -node bmacdrdb2 
srvctl modify database -db bmacdbdg -spfile '+datadg/bmacdbdg/spfilebmacdb.ora' -pwfile '+datadg/bmacdbdg/password/orapwbmacdb'
srvctl modify database -db bmacdbdg -diskgroup DATADG,LOGDG
备库配置信息:
oracle@bmacdrdb1:/home/oracle>srvctl config database -d bmacdbdg
Database unique name: bmacdbdg
Database name: bmacdb
Oracle home: /u01/app/oracle/product/12.1.0/dbhome_1
Oracle user: oracle
Spfile: +datadg/bmacdbdg/spfilebmacdb.ora
Password file: +datadg/bmacdbdg/password/orapwbmacdb
Domain: 
Start options: open
Stop options: immediate
Database role: PHYSICAL_STANDBY
Management policy: AUTOMATIC
Server pools: 
Disk Groups: DATADG,LOGDG
Mount point paths: 
Services: 
Type: RAC
Start concurrency: 
Stop concurrency: 
OSDBA group: dba
OSOPER group: oper
Database instances: bmacdb1,bmacdb2
Configured nodes: bmacdrdb1,bmacdrdb2
Database is administrator managed

8、应用日志

alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect;
select open_Mode,DATABASE_ROLE from v$database;

OPEN_MODE            DATABASE_ROLE
-------------------- ----------------
READ ONLY WITH APPLY PHYSICAL STANDBY

网页题目:Oracle12CRac到Rac搭建ADG
文章位置:http://cdxtjz.com/article/isgedp.html