OGG从入门到高可用系列

0    552    1

Tags:

👉 本文共约70973个字,系统预计阅读时间或需267分钟。

【OGG】RAC环境下配置OGG单向同步 (四)

实验环境介绍

项目source dbtarget db
db 类型rac单实例
db version11.2.0.111.2.0.1
db 存储ASMFS type
ORACLE_SIDjmrac1/jmrac2orcl
db_namejmracorcl
主机IP地址:192.168.1.31/192.168.1.32192.168.1.128
OS版本及kernel版本RHEL5.7 64位,2.6.18-274.el5RHEL6.5 64位,2.6.32-504.16.2.el6.x86_64
OGG版本11.2.1.0.1 64位11.2.1.0.1 64位
OS hostnamenode1/node2orcltest

实验部分

实验目标

本文配置是:rac(source)同单实例(target)数据库之间的ogg单向同步

RAC环境下配置OGG单向同步

首先在两个rac节点上配置ASM动态注册,11g的监听器引入了endpoints_listener.ora文件管理

配置listener

配置监听,加入对ASM的动态注册:

[oracle@node1 ~]$ srvctl status listener

Listener LISTENER is enabled

Listener LISTENER is running on node(s): node1,node2

[oracle@node1 ~]$ lsnrctl services

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-JUN-2015 16:39:32

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

Services Summary...

Service "+ASM" has 2 instance(s).

Instance "+ASM1", status UNKNOWN, has 1 handler(s) for this service...

Handler(s):

"DEDICATED" established:0 refused:0

LOCAL SERVER

Instance "+ASM1", status READY, has 1 handler(s) for this service...

Handler(s):

"DEDICATED" established:3 refused:0 state:ready

LOCAL SERVER

Service "HAHA" has 2 instance(s).

Instance "jmrac1", status READY, has 2 handler(s) for this service...

Handler(s):

"DEDICATED" established:0 refused:0 state:ready

REMOTE SERVER

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1521)))

"DEDICATED" established:5 refused:0 state:ready

LOCAL SERVER

Instance "jmrac2", status READY, has 1 handler(s) for this service...

Handler(s):

"DEDICATED" established:0 refused:0 state:ready

REMOTE SERVER

(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1521)))

The command completed successfully

[oracle@node1 ~]$

[grid@node1 ~]$ cat $TNS_ADMIN/listener.ora

LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent

LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = +ASM)

(ORACLE_HOME=/u01/grid)

(SID_NAME = +ASM1)

)

)

[grid@node1 ~]$ cat $TNS_ADMIN/endpoints_listener.ora

LISTENER_NODE1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node1-vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.31)(PORT=1521)(IP=FIRST)))) # line added by Agent

[grid@node1 ~]$

节点二监听:

[grid@node2 ~]$ cat $TNS_ADMIN/listener.ora

LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))) # line added by Agent

LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))) # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON # line added by Agent

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(GLOBAL_DBNAME = +ASM)

(ORACLE_HOME=/u01/grid)

(SID_NAME = +ASM2)

)

)

[grid@node2 ~]$ cat $TNS_ADMIN/endpoints_listener.ora

LISTENER_NODE2=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=node2-vip)(PORT=1521))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.32)(PORT=1521)(IP=FIRST)))) # line added by Agent

[grid@node2 ~]$

检查配置情况:

C:\Users\Administrator> sqlplus sys/lhr@192.168.1.31:1521/+ASM as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 11 11:13:37 2015

Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Real Application Clusters and Automatic Storage Management options

SQL> set line 9999

SQL> show parameter name

NAME TYPE VALUE

------------------------------------ ---------------------- ------------------------------

db_unique_name string +ASM

instance_name string +ASM1

lock_name_space string

service_names string +ASM

SQL> conn sys/lhr@192.168.1.32:1521/+ASM as sysdba

Connected.

SQL> show parameter name

NAME TYPE VALUE

------------------------------------ ---------------------- ------------------------------

db_unique_name string +ASM

instance_name string +ASM2

lock_name_space string

service_names string +ASM

SQL>

配置tnsnames.ora

注意切换到oracle用户下,2个节点均配置:

RAC上安装OGG软件

安装ACFS

我们首先来安装ACFS,即ASM Cluster File System,相关知识不多解释,而安装ACFS也有很多种办法,这里我们采用命令行的方式来安装ACFS,我们在节点一上操作:

a、root用户手工加载驱动:ASM volume driver,acfsload为grid用户下的命令

[root@node1 ~]# acfsload -s

acfsload: ACFS-9228: usage: acfsload {start|stop} [-s]

[root@node1 ~]# acfsload start

ACFS-9327: Verifying ADVM/ACFS devices.

ACFS-9322: done.

[root@node1 ~]#

b、创建磁盘组,也可以不用创建磁盘组,后边采用已经存在的磁盘组来创建卷组,我们这里就不再重新创建磁盘组了

c、创建asm卷

[root@node1 ~]# su - grid

[grid@node1 ~]$ sqlplus / as sysasm

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 11 14:16:13 2015

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Real Application Clusters and Automatic Storage Management options

SQL> alter diskgroup DATA add volume acfsvol1 size 1G;

Diskgroup altered.

SQL> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Real Application Clusters and Automatic Storage Management options

[grid@node1 ~]$ ll /dev/asm

total 0

brwxrwx--- 1 root asmadmin 252, 118786 Jun 11 14:16 acfsvol1-232

brwxrwx--- 1 root asmadmin 252, 118785 Jun 11 13:45 vol01-232

[grid@node1 ~]$

d、创建acfs挂载目录,在rac1和rac2节点都执行

[root@node1 ~]# mkdir -p /u01/app/acfsmounts/acfsvol1-232

[root@node2 ~]# mkdir -p /u01/app/acfsmounts/acfsvol1-232

e、用mkfs创建文件系统

[root@node1 ~]# /sbin/mkfs -t acfs -n acfs01 /dev/asm/acfsvol1-232

mkfs.acfs: version = 11.2.0.1.0.0

mkfs.acfs: on-disk version = 39.0

mkfs.acfs: volume = /dev/asm/acfsvol1-232

mkfs.acfs: volume size = 1073741824

mkfs.acfs: Format complete.

[root@node1 ~]#

f、用acfsuit命令注册文件系统

[root@node1 ~]# /sbin/acfsutil registry -a -f /dev/asm/acfsvol1-232 /u01/app/acfsmounts/acfsvol1-232

acfsutil registry: mount point /u01/app/acfsmounts/acfsvol1-232 successfully added to Oracle Registry

g、用mount.acfs命令挂载文件系统

[root@node1 ~]# mount.acfs -o all

[root@node1 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 75G 57G 15G 81% /

/dev/sda1 99M 27M 67M 29% /boot

tmpfs 1005M 463M 542M 47% /dev/shm

/dev/asm/vol01-232 1.0G 73M 952M 8% /u01/app/acfsmounts/data_vol01

/dev/asm/acfsvol1-232

1.0G 73M 952M 8% /u01/app/acfsmounts/acfsvol1-232

[root@node1 ~]#

[root@node1 ~]# ssh node2 "df -h"

root@node2's password:

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 75G 16G 55G 23% /

/dev/sda1 99M 26M 69M 28% /boot

tmpfs 1005M 463M 542M 47% /dev/shm

/dev/asm/vol01-232 1.0G 73M 952M 8% /u01/app/acfsmounts/data_vol01

/dev/asm/acfsvol1-232

1.0G 73M 952M 8% /u01/app/acfsmounts/acfsvol1-232

[root@node1 ~]#

h、改变文件系统属性供oracle使用

[root@node1 ~]# chown oracle.asmadmin /u01/app/acfsmounts/acfsvol1-232

[root@node1 ~]# ll -d /u01/app/acfsmounts/acfsvol1-232

drwxrwx--- 4 oracle asmadmin 4096 Jun 11 14:24 /u01/app/acfsmounts/acfsvol1-232

[root@node1 ~]# ssh node2 "ls -ld /u01/app/acfsmounts/acfsvol1-232"

root@node2's password:

drwxrwx--- 4 oracle asmadmin 4096 Jun 11 14:24 /u01/app/acfsmounts/acfsvol1-232

[root@node1 ~]#

acfs上安装ogg,acfs用来存放ogg的安装目录,便于集群件的共享,在10g上部署可以选择ocfs2

首先上传ogg软件到/TMP目录下:

2个节点均配置环境变量,加入如下参数:

export OGG_HOME=/u01/app/acfsmounts/acfsvol1-232/gg11

export PATH=$OGG_HOME:$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$OGG_HOME:$ORACLE_HOME/lib:$LD_LIBRARYPATH

alias ggsci='rlwrap ggsci'

节点一:

[oracle@node1 gg11]$ source ~/.bash_profile

[oracle@node1 gg11]$ echo $OGG_HOME

/u01/app/acfsmounts/acfsvol1-232/gg11

[oracle@node1 gg11]$

节点二:

[oracle@node2 ~]$ source ~/.bash_profile

[oracle@node2 ~]$ echo $OGG_HOME

/u01/app/acfsmounts/acfsvol1-232/gg11

[oracle@node2 ~]$

开始在节点一安装OGG软件:

[root@node1 tmp]# chown oracle.oinstall ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

[root@node1 tmp]# su - oracle

[oracle@node1 tmp]$ unzip ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

Archive: ogg112101_fbo_ggs_Linux_x64_ora11g_64bit.zip

inflating: fbo_ggs_Linux_x64_ora11g_64bit.tar

inflating: OGG_WinUnix_Rel_Notes_11.2.1.0.1.pdf

inflating: Oracle GoldenGate 11.2.1.0.1 README.txt

inflating: Oracle GoldenGate 11.2.1.0.1 README.doc

[oracle@node1 tmp]$

[oracle@node1 tmp]$ tar xvf fbo_ggs_Linux_x64_ora11g_64bit.tar -C $OGG_HOME

。。。。。。。。。。。。。。。。

[oracle@node1 ~]$ cd $OGG_HOME

[oracle@node1 gg11]$ pwd

/u01/app/acfsmounts/acfsvol1-232/gg11

[oracle@node1 gg11]$ ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

GGSCI (node1) 1>

GGSCI (node1) 1> create subdirs

Creating subdirectories under current directory /u01/app/acfsmounts/acfsvol1-232/gg11

Parameter files /u01/app/acfsmounts/acfsvol1-232/gg11/dirprm: already exists

Report files /u01/app/acfsmounts/acfsvol1-232/gg11/dirrpt: created

Checkpoint files /u01/app/acfsmounts/acfsvol1-232/gg11/dirchk: created

Process status files /u01/app/acfsmounts/acfsvol1-232/gg11/dirpcs: created

SQL script files /u01/app/acfsmounts/acfsvol1-232/gg11/dirsql: created

Database definitions files /u01/app/acfsmounts/acfsvol1-232/gg11/dirdef: created

Extract data files /u01/app/acfsmounts/acfsvol1-232/gg11/dirdat: created

Temporary files /u01/app/acfsmounts/acfsvol1-232/gg11/dirtmp: created

Stdout files /u01/app/acfsmounts/acfsvol1-232/gg11/dirout: created

GGSCI (node1) 2>

节点二测试:

[root@node2 ~]# su - oracle

[oracle@node2 ~]$ cd $OGG_HOME

[oracle@node2 gg11]$ ggsci

Oracle GoldenGate Command Interpreter for Oracle

Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO

Linux, x64, 64bit (optimized), Oracle 11g on Apr 23 2012 08:32:14

Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.

GGSCI (node2) 1>

配置mgr进程

节点一上配置mgr进程:

GGSCI (node1) 2> edit params mgr

GGSCI (node1) 3> view params mgr

port 7809

autostart er *

autorestart er *

GGSCI (node1) 4> start mgr

Manager started.

GGSCI (node1) 5> info mgr

Manager is running (IP port node1.7809).

GGSCI (node1) 6> sh netstat -ntpl |grep 7809

(Not all processes could be identified, non-owned process info

will not be shown, you would have to be root to see it all.)

tcp 0 0 0.0.0.0:7809 0.0.0.0:* LISTEN 7561/mgr

GGSCI (node1) 7> sh ps -ef|grep mgr

gdm 5077 5060 0 14:52 ? 00:00:00 /usr/libexec/gdmgreeter

oracle 7561 7424 0 15:11 ? 00:00:00 ./mgr PARAMFILE /u01/app/acfsmounts/acfsvol1-232/gg11/dirprm/mgr.prm REPORTFILE /u01/app/acfsmounts/acfsvol1-232/gg11/dirrpt/MGR.rpt PROCESSID MGR PORT 7809

oracle 7595 7424 0 15:11 pts/2 00:00:00 sh -c ps -ef|grep mgr

GGSCI (node1) 8>

target库安装OGG软件

省略安装过程。。。。

rac数据库上进行配置,创建用户,授权,运行执行序列号和ddl复制的相关脚本等

脚本:

create user ogg identified by ogg;

grant connect,resource,dba to ogg;

@sequence.sql

alter database add supplemental log data;

alter database add supplemental log data (primary key) columns;

alter database add supplemental log data (foreign key) columns;

alter database add supplemental log data (unique) columns;

alter system archive log current;

grant execute on utl_file to ogg;

@marker_setup.sql

@ddl_setup.sql

@role_setup.sql

grant ggs_ggsuser_role to ogg;

@ddl_enable.sql

@ddl_pin ogg

[oracle@node1 gg11]$ ORACLE_SID=jmrac1

[oracle@node1 gg11]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 11 15:17:43 2015

Copyright (c) 1982, 2009, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

SQL> select instance_name from v$instance;

INSTANCE_NAME

----------------

jmrac1

SQL> create user ogg identified by ogg;

User created.

SQL> grant connect,resource,dba to ogg;

Grant succeeded.

SQL> @sequence.sql

Please enter the name of a schema for the GoldenGate database objects:

ogg

Setting schema name to OGG

UPDATE_SEQUENCE STATUS:

Line/pos

--------------------

Error

-----------------------------------------------------------------

No errors

No errors

GETSEQFLUSH

Line/pos

--------------------

Error

-----------------------------------------------------------------

No errors

No errors

SEQTRACE

Line/pos

--------------------

Error

-----------------------------------------------------------------

No errors

No errors

REPLICATE_SEQUENCE STATUS:

Line/pos

--------------------

Error

-----------------------------------------------------------------

No errors

No errors

STATUS OF SEQUENCE SUPPORT

--------------------------------------------------------------

SUCCESSFUL installation of Oracle Sequence Replication support

SQL> alter database add supplemental log data;

Database altered.

SQL> alter database add supplemental log data (primary key) columns;

Database altered.

SQL> alter database add supplemental log data (foreign key) columns;

Database altered.

SQL> alter database add supplemental log data (unique) columns;

Database altered.

SQL> alter system archive log current;

System altered.

SQL> grant execute on utl_file to ogg;

Grant succeeded.

SQL> @marker_setup.sql

Marker setup script

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.

NOTE: The schema must be created prior to running this script.

NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:ogg

Marker setup table script complete, running verification script...

Please enter the name of a schema for the GoldenGate database objects:

Setting schema name to OGG

MARKER TABLE

-------------------------------

OK

MARKER SEQUENCE

-------------------------------

OK

Script complete.

SQL> @ddl_setup.sql

Oracle GoldenGate DDL Replication setup script

Verifying that current user has privileges to install DDL Replication...

You will be prompted for the name of a schema for the Oracle GoldenGate database objects.

NOTE: For an Oracle 10g source, the system recycle bin must be disabled. For Oracle 11g and later, it can be enabled.

NOTE: The schema must be created prior to running this script.

NOTE: Stop all DDL replication before starting this installation.

Enter Oracle GoldenGate schema name:ogg

Working, please wait ...

Spooling to file ddl_setup_spool.txt

Checking for sessions that are holding locks on Oracle Golden Gate metadata tables ...

Check complete.

Using OGG as a Oracle GoldenGate schema name.

Working, please wait ...

DDL replication setup script complete, running verification script...

Please enter the name of a schema for the GoldenGate database objects:

Setting schema name to OGG

CLEAR_TRACE STATUS:

Line/pos Error

-------------------- -----------------------------------------------------------------

No errors No errors

CREATE_TRACE STATUS:

Line/pos Error

-------------------- -----------------------------------------------------------------

No errors No errors

TRACE_PUT_LINE STATUS:

Line/pos Error

-------------------- -----------------------------------------------------------------

No errors No errors

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!
AiDBA后续精彩内容已被站长无情隐藏,请输入验证码解锁本文!
验证码:
获取验证码: 请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“AiDBA”或者“dbaup6”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复