写在前面:

最终实现环境:11.2.0.4版本 2节点RAC + 1节点DG

本文旨在弄清楚整个搭建过程中涉及到的基础概念;

本文安装maximum performance mode(最大性能模式)也是DG默认的数据保护模式;

前提环境:

1).主库已安装11.2.0.4版本 RAC数据库

#public ip
192.168.56.150 jyrac1
192.168.56.152 jyrac2
#private ip
10.10.10.11 jyrac1-priv
10.10.10.12 jyrac2-priv
#virtual ip
192.168.56.151 jyrac1-vip
192.168.56.153 jyrac2-vip
#scan ip
192.168.56.160 jyrac-scan

2).备库已安装同版本软件、监听程序

192.168.56.158 jydg

1.主库准备工作

数据库设置为force logging模式

SQL> alter database force logging;

数据库设置为归档模式(RAC数据库更改归档模式参见文档:How To Enable/Disable Archive Logging In RAC Environment for 10.2 and higher version (文档 ID 1186764.1))

SQL> alter database archivelog;

检查

SQL> select inst_id, name, open_mode, log_mode, force_logging from gv$database;

2.物理备库准备工作

确保已成功安装同版本数据库软件、监听程序;
配置静态监听,这里的ORACLE_HOME是 /u01/app/oracle/product/11.2.0/dbhome_1

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = jyzhao_s)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = jyzhao_s)
)
)

3.创建物理备库

**3.1 配置tnsnames.ora**
主库上配置【@all rac nodes 】:

JYZHAO_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.158)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao_s)
)
) JYZHAO1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.151)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao)
)
) JYZHAO2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.153)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao)
)
)

备库上配置:

JYZHAO_S =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.158)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao_s)
)
) JYZHAO =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.160)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao)
)
) JYZHAO1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.151)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao)
)
) JYZHAO2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.153)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jyzhao)
)
)

3.2 修改主库参数

FAL_CLIENT(确定11g dg官方安装文档中这个参数没有再提,因此只需要设定fal_server)

FAL_CLIENT specifies the FAL (fetch archive log) client name that is used by the FAL service, configured through the FAL_SERVER initialization parameter, to refer to the FAL client. The value is an Oracle Net service name, which is assumed to be configured properly on the FAL server system to point to the FAL client (standby database).

FAL_SERVER specifies the FAL (fetch archive log) server for a standby database. The value is an Oracle Net service name, which is assumed to be configured properly on the standby database system to point to the desired FAL server.

log_archive_config

LOG_ARCHIVE_CONFIG enables or disables the sending of redo logs to remote destinations and the receipt of remote redo logs, and specifies the unique database names (DB_UNIQUE_NAME) for each database in the Data Guard configuration.

log_archive_dest_3(这里的日志传输链路选择log_archive_dest_3,根据需求规范可改选其他的)

查看相关日志传输链路是否存在错误信息:

select dest_id, dest_name, error from v$archive_dest where dest_id=3;

select inst_id, error from gv$archive_dest where dest_id=3;

例如:

在主库上对部分参数做适当的修改调整。

alter system set FAL_SERVER='jyzhao_s';
alter system set log_archive_config= 'DG_CONFIG=(jyzhao,jyzhao_s)';
alter system set log_archive_dest_3='SERVICE=jyzhao_s LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=jyzhao_s';

在11.2官档中,提到其中LGWR参数已过时,Specify SYNC or ASYNC. ASYNC is the default if neither attribute is specified.

--设置db_unique_name, log_archive_config(这里主库的db_unique_name,出于对现有的生产环境最小影响考虑没有改)

alter system set db_unique_name='jyzhao' scope=spfile;
alter system set log_archive_config= 'DG_CONFIG=(jyzhao,jyzhao_s)';

--归档日志目录

alter system set log_archive_dest_3='SERVICE=jyzhao_s LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=jyzhao_s';
select dest_id, dest_name, error from v$archive_dest where dest_id=3;

--归档日志文件命名规则

--DG的fal_server和fal_client

alter system set fal_server='jyzhao_s';

--设置standby_file_management为自动

alter system set standby_file_management=AUTO;

--设置备库日志文件组,数量一般为目标库日志文件组+1(当原环境是RAC环境时,如何修改?)

alter database add standby logfile thread 1 group 11 size 50M;
alter database add standby logfile thread 1 group 12 size 50M;
alter database add standby logfile thread 1 group 13 size 50M; alter database add standby logfile thread 2 group 21 size 50M;
alter database add standby logfile thread 2 group 22 size 50M;
alter database add standby logfile thread 2 group 23 size 50M;

3.3 创建备库密码文件

主库密码文件拷贝到备库相应的目录下

scp $ORACLE_HOME/dbs/orapw* xxx.xxx.xxx.xxx:/.../dbs/

[oracle@jyrac2 dbs]$ scp $ORACLE_HOME/dbs/orapwjyzhao2 192.168.56.158:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwjyzhao_s

--确认 orapwjyzhao_s 确认standby database的db_name为jyzhao; 然后db_unique_name, service_names, instance_name都是jyzhao_s

3.4 创建pfile文件

从主库的spfile中导出pfile文件,传输到备库并做适当的修改调整。

create pfile='/tmp/pfile.ora' from spfile;

在备库修改如下:

--原版(去掉RAC实例1,2的相关设置参数):
[oracle@jydg tmp]$ more pfile.ora
*.audit_file_dest='/opt/app/oracle/admin/jyzhao/adump'
*.audit_trail='db'
*.cluster_database=true
*.compatible='11.2.0.4.0'
*.control_files='+DATA1/jyzhao/controlfile/current.260.919999027','+FRA1/jyzhao/controlfile/current.256.919999029'
*.db_block_size=8192
*.db_create_file_dest='+DATA1'
*.db_domain=''
*.db_name='jyzhao'
*.db_recovery_file_dest='+FRA1'
*.db_recovery_file_dest_size=4621074432
*.diagnostic_dest='/opt/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=jyzhaoXDB)'
*.fal_server='jyzhao_s'
*.log_archive_config='DG_CONFIG=(jyzhao,jyzhao_s)'
*.log_archive_dest_3='SERVICE=jyzhao_s LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=jyzhao_s'
*.log_archive_dest_state_3='enable'
*.memory_max_target=314572800
*.memory_target=314572800
*.open_cursors=300
*.processes=150
*.remote_listener='jyrac-scan:1521'
*.remote_login_passwordfile='exclusive'
*.standby_file_management='AUTO' --修正后(主要确认路径是否都存在):
[oracle@jydg tmp]$ more pfile.ora
*.audit_file_dest='/u01/app/oracle/admin/jyzhao/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/control01.ctl','/u01/app/oracle/fra/control02.ctl'
db_unique_name='jyzhao_s'
DB_FILE_NAME_CONVERT='+DATA1/jyzhao/datafile','/u01/app/oracle/oradata','+DATA1/jyzhao/tempfile/','/u01/app/oracle/oradata/'
LOG_FILE_NAME_CONVERT='+DATA1/jyzhao/onlinelog','/u01/app/oracle/oradata','+FRA1/jyzhao/onlinelog','/u01/app/oracle/oradata'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/fra'
*.db_name='jyzhao'
*.db_recovery_file_dest='/u01/app/oracle/fra'
*.db_recovery_file_dest_size=4621074432
*.diagnostic_dest='/u01/app/oracle'
*.fal_server='jyzhao'
*.log_archive_config='DG_CONFIG=(jyzhao_s,jyzhao)'
*.log_archive_dest_3='SERVICE=jyzhao LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=jyzhao'
*.log_archive_dest_state_3='enable'
*.memory_max_target=314572800
*.memory_target=314572800
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='exclusive'
*.standby_file_management='AUTO'

3.5 启动备库到nomount

su - oracle

mkdir -p /u01/app/oracle/admin/jyzhao/adump
mkdir -p /u01/app/oracle/oradata
mkdir -p /u01/app/oracle/fra
startup nomount pfile='/tmp/pfile.ora'
create spfile from pfile='/tmp/pfile.ora';

这里参数文件也可以只指定db_name='jyzhao_s' 但是这样的话就在duplicate时指定参数了。

3.6 使用duplicate搭建备库

例如:

--duplication script, running at jyzhao_s
--这里是在备库执行脚本;连接的是原环境RAC的节点2;
su - oracle
mkdir -p /home/oracle/mirgration_scripts
cd /home/oracle/mirgration_scripts
vi /home/oracle/mirgration_scripts/duplicate.sql run {
allocate channel p1 type disk;
allocate channel p2 type disk;
allocate auxiliary channel s1 type disk;
allocate auxiliary channel s2 type disk;
duplicate target database for standby from active database dorecover nofilenamecheck;
} nohup rman target sys/oracle@jyzhao2 auxiliary sys/oracle@jyzhao_s @/home/oracle/mirgration_scripts/duplicate.sql log=/home/oracle/mirgration_scripts/d1.log &
--实验发现,duplicate主库时,如果日志传送链路没有打开,那么是恢复不成功滴!

3.7 在OPEN状态下进行日志应用

例如:

sqlplus / as sysdba
--alter database recover managed standby database cancel;
alter database open;
alter database recover managed standby database using current logfile disconnect from session;
--alter database recover managed standby database disconnect from session; --这种不需要standby logfile

3.8 确认ADG状态正常

主库日志类似如下信息:

******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_3
******************************************************************
Wed Nov 30 04:48:42 2016
Archived Log entry 268 added for thread 2 sequence 115 ID 0x9603a618 dest 1:
LNS: Standby redo logfile selected for thread 2 sequence 116 for destination LOG_ARCHIVE_DEST_3

备库日志类似如下信息:

Media Recovery Waiting for thread 2 sequence 116 (in transit)

也可以查看主备库的当前SCN,或者查询备库的v$dataguard_stats视图。

--主备库都可查询当前SCN:
SQL> select current_scn||'' from v$database; --备库查询v$dataguard_stats视图:
SQL> set lines 1000
SQL> select * from v$dataguard_stats;

以上检查确认没有问题,则说明ADG搭建成功完成。

RAC 主库配置单实例ADG的更多相关文章

  1. 一步一步搭建11gR2 rac+dg之配置单实例的DG(八)【转】

    RAC主库配置单实例ActiveDataguard 本文文档结构: 这里配置的过程中需要注意的一项是多看看rac1和rac2以及dg的告警日志会对配置过程有更深刻的理解...配置oracle rac的 ...

  2. Oracle_lhr_CentOS 7.3 ECS上搭建RAC 18c+单实例DG+EMCC+DG的FSFO快速故障转移配置

    Oracle_lhr_CentOS 7.3  ECS上搭建RAC 18c+单实例DG+EMCC+DG的FSFO快速故障转移配置 [大型连续免费公开课]Oracle 18c rac+dg+13.3的em ...

  3. oracle 11g r2 rac到单实例的dg

    oracle 11g r2 rac到单实例的dg 1 主备环境说明 rac环境--primary CentOS release 6.5 (Final)hostname rac1 rac2ip 10.* ...

  4. ORACLE11g R2【RAC+ASM→单实例FS】

    ORACLE11g R2[RAC+ASM→单实例FS] 11g R2 RAC+ASMà单实例FS的DG,建议禁用OMF. 本演示案例所用环境:   primary standby OS Hostnam ...

  5. ORACLE10g R2【RAC+ASM→单实例FS】

    ORACLE10g R2[RAC+ASM→单实例FS] 10g R2 RAC+ASMà单实例FS的DG,建议禁用OMF. 本演示案例所用环境:   primary standby OS Hostnam ...

  6. Oracle 11g RAC 环境下单实例非缺省监听及端口配置

    如果在Oracle 11g RAC环境下使用dbca创建单实例数据库后,Oracle会自动将其注册到缺省的1521端口及监听器.大多数情况下我们使用的为非缺省监听器以及非缺省的监听端口.而且在Orac ...

  7. 这里的*号实际表示就是RAC中所有实例都使用

    您的位置: ITPUB个人空间 » cc59的个人空间 » 日志 发布新日志 我的日志我的足迹我的收藏 unix/linuxHA随笔backup&restoreperformance tuni ...

  8. mongodb 配置单实例与双实例

    环境: centos6.5 192.168.16.70 配置单实例mongodb:[root@www soft]# tar xf mongodb-linux-x86_64-rhel62-3.2.7.t ...

  9. RAC 单节点实例异常关闭,关键报错ORA--29770

    监控系统监控到RAC 的一个实例异常关闭 ,时间是凌晨1点多,还好没有影响到业务 之后就是分析原因 这套RAC搭建在虚拟化环境OS SUSE11 查看oracel alert log信息 Mon :: ...

随机推荐

  1. Python的单元测试(一)

    title: Python的单元测试(一) author: 青南 date: 2015-02-27 22:50:47 categories: Python tags: [Python,单元测试] -- ...

  2. shiro权限管理框架与springmvc整合

    shiro是apache下的一个项目,和spring security类似,用于用户权限的管理‘ 但从易用性和学习成本上考虑,shiro更具优势,同时shiro支持和很多接口集成 用户及权限管理是众多 ...

  3. SDWebImage源码解读之SDWebImageCache(下)

    第六篇 前言 我们在SDWebImageCache(上)中了解了这个缓存类大概的功能是什么?那么接下来就要看看这些功能是如何实现的? 再次强调,不管是图片的缓存还是其他各种不同形式的缓存,在原理上都极 ...

  4. Spring注解

    AccountController .java Java代码   1.        /** 2.         * 2010-1-23 3.         */ 4.        packag ...

  5. MVP初探

    什么是MVP MVP是一种UI的架构模式,是MVC的一种变体,适用于基于事件驱动的应用框架.MVP中的M和V分别对应了MVC中的Model和View,而P代替了Controller,而它更多地体现在了 ...

  6. 兼容Mono的下一代云环境Web开发框架ASP.NET vNext

    微软在2014年5月12日的TechEd大会上宣布将会发布下一代ASP.NET框架ASP.NET vNext的预览.此次发布的ASP.NET框架与以前相比发生了根本性的变化,凸显了微软“云优先”(cl ...

  7. 一步步搭建自己的博客 .NET版(2、评论功能)

    前言 这次开发的博客主要功能或特点:    第一:可以兼容各终端,特别是手机端.    第二:到时会用到大量html5,炫啊.    第三:导入博客园的精华文章,并做分类.(不要封我)    第四:做 ...

  8. Mac-OSX的Python3.5虚拟环境下安装Opencv

    Mac-OSX的Python3.5虚拟环境下安装Opencv 1   关键词 关键词:Mac,OSX,Python3.5,Virtualenv,Opencv 2   概述 本文是一篇 环境搭建 的基础 ...

  9. 吐血大奉献,打造cnblogs最新最火辣的css3模板(IE9以下请勿入内) -- 第一版

    一直自己都想给自己的博客打造一个独一无二的皮肤,但是一直没有强劲的动力去完成这件事情.后来凭借着工作上面的需求(涉及到css3),就把自己的博客当成一个最好的试验场地.从而产生了你现在所看到的这个模板 ...

  10. Windows10自适应和交互式toast通知[1]

    阅读目录: 概述 toast通知的结构 视觉区域(Visual) 行为(Actions) 特定场景下的Toast通知 带多内容的通知 带行为的通知(例子1) 带行为的通知(例子2) 带文本输入框和行为 ...