文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Oracle 12C Rac到Rac搭建ADG

2024-04-02 19:55

关注

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 <<EOF
run
{
allocate channel cl1 type disk;
allocate auxiliary channel c1 type disk;
duplicate target database for standby from active database nofilenamecheck;
release channel c1;
release channel cl1;
}
EOF
给脚本授予执行权限并执行脚本:
chmod +x dg.sh
nohup ./dg.sh &

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
阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯