写在前面:

最终实现环境: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. OpenCV2邻域和模板操作

    在图像处理中,通过当前位置的邻域像素计算新的像素值是很常见的操作.当邻域包含图像的上几行和下几行时,就需要同时扫描图像的若干行,这就是图像的邻域操作了.至于模板操作是实现空间滤波的基础,通常是使用一个 ...

  2. 241. Different Ways to Add Parentheses

    241. Different Ways to Add Parentheses https://leetcode.com/problems/different-ways-to-add-parenthes ...

  3. #8.10.16总结# 属性选择符 伪对象选择符 CSS的常用样式

    属性选择符 E[att] E[att="val"] E[att~="val"] E[att^="val"] E[att$="val ...

  4. smaller programs should improve performance

    COMPUTER ORGANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION In this section, we l ...

  5. Android ListView简单实用

    layout创建: activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ ...

  6. ios 沙盒 NSCoding(相当于JAVA对象序列化) 归档 数据存储

    通过NSCoding能实现像JAVA一样能够实现对象的序列化,可以保存对象到文件里. NSCoding 跟其他存储方式略有不同,他可以存储对象 对象存储的条件是: 对象需要遵守 NSCoding 协议 ...

  7. QxtFlowView(libqxt)

    https://github.com/mnutt/libqxt/tree/master/examples http://libqxt.bitbucket.org/doc/0.5/class_qxt_f ...

  8. c#串口编程和单片机通信重大发现

    1.遇到问题时看看这里 //每次响应中断结束后清空缓存,防止在显示关闭时,打开后又一次性出现 serialPort1.DiscardInBuffer();

  9. myEclipse快捷键及其常用设置

    快捷键:    查找替换:ctrl + f    复制行: ctrl + alt + down    删除行: ctrl + d    插入行: shift + enter, ctrl + shift ...

  10. redis数据类型-字符串类型

    Redis数据类型 字符串类型 字符串类型是Redis中最基本的数据类型,它能存储任何形式的字符串,包括二进制数据.你可以用其存储用户的邮箱.JSON化的对象甚至是一张图片.一个字符串类型键允许存储的 ...