Oracle文件系统加dg,在ORACLE 12C RAC 的DG库上搭建OGG

一.创建共享磁盘

1. 查看rac节点是否有ASM的监听注册(双节点)

su - oracle

lsnrctl services

645589f897d0e4ce385d88e0171c2acd.png

如果没有,需要用grid用户在$ORACLE_HOME/network/admin/listener.ora文件中添加静态注册,然后reload listener(双节点):

[grid@rac1 ~]$ vi 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/app/oracle/product/12.2.0.1/db_1)

(SID_NAME = +ASM1)

)

)

2. 用oracle用户编辑$ORACLE_HOME/network/admin/tnsnames.ora文件,使其用别名可连接ASM实例和数据库

su - oracle

cd $ORACLE_HOME\network\admin

vim tnsnames.ora

[oracle@rac1 admin]$ cat tnsnames.ora

ORCL =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = rac-scan)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

tnsdg =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = dg)(PORT = 1522))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = orcl)

)

)

ASM =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521))

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = +ASM)

(SID_NAME = +ASM1)

)

)

3.测试连接:

sqlplus sys/woailyoo@ASM as sysasm

select instance_name from v$instance;

55cbec6e800e951468f9b5aac2fae555.png

sqlplus sys/woailyoo@ORCL as sysdba

select instance_name from gv$instance;

9c7c0bd366898e96d6d91af2d86a1d3c.png

4. 安装acfs(ASM Cluster File System)

从Oracle11.2开始,ASM不仅是一个磁盘组,他还提供了了一个卷管理器,称为ADVM(asm dynamic volume manager)。ADVM向用户提供卷管理服务,并提供标准的磁盘设备驱动程序。利用ADVM,可以在卷组中创建一个或多个卷,每个卷对应操作系统中的一个设备文件,这些卷是可以动态扩展的,就像操作系统中的卷或者利用第三方软件创建的卷一样,应用程序也可以对ADVM卷中的数据进行读写操作。

在ADVM卷中可以创建ACFS文件系统,ACFS是一种跨平台的、可扩展的集群文件系统,多个节点可以同时访问asfs中的文件。ACFS不仅可以作为oracle数据库软件的安装路径,还可以用来存储数据库中的警告文件和跟踪文件,还可以存储诸如视频、声音、图像、文本等类型的文件。

su - root

cd  /u01/app/12.2.0.1/grid/bin

export ORACLE_HOME=/u01/app/12.2.0.1/grid/

./acfsload start -s

ACFS-9459: ADVM/ACFS is not supported on this OS version: 'centos-release-7-6.1810.2.el7.centos.x86_64'

cd /u01/app/12.2.0.1/grid/lib

cp -p osds_acfslib.pm osds_acfslib.pm.bak

vim osds_acfslib.pm

添加  ($release =~ /^centos-release/) ||        # CentOS hack

a27d9166a7b58f51d415fd886e8e0504.png

2949dd4edc8c5ff20c92dbb2c5a28e83.png

cd /u01/app/12.2.0.1/grid/bin

./acfsload start -s

ACFS-9129: ADVM/ACFS not installed

./acfsroot install (双节点都要安装)

bba1cc27b69869d9d7a1d66ab439e036.png

5.检查

lsmod | grep oracle

3f7f8c65ae5960c1163f1feb2cba2c35.png

6. 这里可以使用挂在上来的磁盘或者现有的ASM磁盘做ogg的软件目录

我采用在现有ASM磁盘上创建一个ASM卷并挂载

su - grid

sqlplus / as sysasm

alter diskgroup DATA add volume acfsload size 5G;

ll /dev/asm*

89beefc30e638b8e46d475d09079b3a3.png

7. 创建acfs挂载目录,在两个节点都要创建相同目录

su - root

mkdir -p /acfsload-503

8. 用mkfs创建文件系统(格式化磁盘)

su - root

mkfs -t acfs -n acfs01 /dev/asm/acfsload-503

823d2a0878094138c10b2b1af75520af.png

9. 用acfsuit命令注册文件系统

[root@rac2 bin]# acfsutil registry -a -f /dev/asm/acfsload-503 /acfsload-503

acfsutil registry: mount point /acfsload-503 successfully added to Oracle Registry

10. 使用mount.acfs -o all命令挂载文件系统(另一节点自动挂载)

[root@rac2 bin]# mount.acfs -o all

[root@rac2 bin]# df -h

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root   50G   32G   19G  64% /

devtmpfs                 3.9G     0  3.9G   0% /dev

tmpfs                    6.0G  1.3G  4.8G  21% /dev/shm

tmpfs                    3.9G   13M  3.9G   1% /run

tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup

/dev/sda1               1014M  166M  849M  17% /boot

/dev/mapper/centos-home   42G   46M   42G   1% /home

tmpfs                    797M  4.0K  797M   1% /run/user/42

tmpfs                    797M   28K  797M   1% /run/user/1001

/dev/asm/acfsload-503    5.0G  495M  4.6G  10% /acfsload-503

[root@rac2 bin]#

11. 改变文件系统的归属,改为Oracle:oinstall

[root@rac2 bin]# chown -R oracle:oinstall /acfsload-503

二.安装 RAC OGG

su - oracle

55c3330ab898be32510765f4dd90bce8.png

0747574b3de673b758f3d718e43e72f0.png

3f8df99ef60819af419f14dbab6d2b83.png

三.安装 DG OGG

跟RAC安装类似,这里略过

四.配置 RAC OGG

1.检查归档、最小附加日志、强制日志是否开启

select log_mode,supplemental_log_data_min,force_logging from v$database;

① 开启最小附加日志

alter database add supplemental log data;

② 开启强制日志

alter database force logging;

2. OGG 创建文件夹

su - oracle

cd $OGG_HOME

./ggsci

create subdirs

3.配置mgr进程

edit params mgr

PORT 7809

DYNAMICPORTLIST 7840-7939

--AUTOSTART ER *

--AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 7

LAGREPORTHOURS 1

LAGINFOMINUTES 30

LAGCRITICALMINUTES 45

start mgr

4.创建用户

CREATE USER goldengate   IDENTIFIED BY goldengate ;

GRANT CONNECT TO goldengate;

GRANT ALTER ANY  TABLE TO goldengate;

GRANT ALTER SESSION TO goldengate;

GRANT CREATE SESSION TO goldengate;

GRANT FLASHBACK ANY TABLE TO goldengate;

GRANT SELECT ANY DICTIONARY TO goldengate;

GRANT SELECT ANY TABLE TO goldengate;

GRANT RESOURCE TO goldengate;

GRANT drop ANY TABLE TO goldengate;

grant create any table to goldengate;

grant insert any table to goldengate;

grant update any table to goldengate;

grant delete any table to goldengate;

grant select any transaction to goldengate;

BEGIN

dbms_goldengate_auth.grant_admin_privilege(grantee => 'goldengate',

privilege_type => 'CAPTURE',grant_select_privileges => TRUE,do_grants => TRUE);

END;

/

5.启用  enable_goldengate_replication

alter system set enable_goldengate_replication=true scope=both;

6.添加表级附加日志

ggsci > dblogin userid goldengate password goldengate

ggsci> add trandata WOAILYOO.OGG_TEST

7.生成def文件

ggsci> eidt params defgen

userid goldengate,password goldengate

defsfile ./dirdef/sql.def

table   WOAILYOO.OGG_TEST;

cd $OGG_HOME

./defgen  paramfile  dirprm/ defgen.prm

五.配置 DG OGG

1.检查归档、最小附加日志、强制日志是否开启

select log_mode,supplemental_log_data_min,force_logging from v$database;

2.检查 enable_goldengate_replication 是否启用

show parameter enable_goldengate_replication;

3.检查 临时文件 是否本地文件

select * from v$tempfile;

①开启最小附加日志

alter database add supplemental log data;

②开启强制日志

alter database force logging;

③启用enable_goldengate_replication

alter system set enable_goldengate_replication=true scope=both;

④创建本地临时文件

alter tablespace temp add tempfile '/u01/app/oracle/oradata/dg/ogg_temp01.dbf' size 100M reuse autoextend on next 50M maxsize 20G;

4.配置mgr参数

edit params mgr

PORT 7809

DYNAMICPORTLIST 7840-7939

--AUTOSTART ER *

--AUTORESTART EXTRACT *,RETRIES 5,WAITMINUTES 3

PURGEOLDEXTRACTS ./dirdat/*,usecheckpoints, minkeepdays 7

LAGREPORTHOURS 1

LAGINFOMINUTES 30

LAGCRITICALMINUTES 45

5.增加抽取进程和指定队列文件

GGSCI>add extract extpdb , tranlog,begin now, threads 2

GGSCI> add exttrail ./dirdat/pd, extract extpdb, megabytes 200

edit params extpdb

EXTRACT extpdb

setenv (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")

SETENV (ORACLE_SID=dg)

userid goldengate,password goldengate

tranlogoptions DBLOGREADER

REPORTCOUNT EVERY 1 MINUTES, RATE

WARNLONGTRANS 2h,CHECKINTERVAL 600s

FETCHOPTIONS NOUSESNAPSHOT

DISCARDFILE ./dirrpt/extpd.dsc,APPEND,MEGABYTES 1024

EXTTRAIL ./dirdat/pd

DBOPTIONS ALLOWUNUSEDCOLUMN

TRANLOGOPTIONS MINEFROMACTIVEDG

TRANLOGOPTIONS ALTARCHIVEDLOGFORMAT %t_%s_%r.arc

TRANLOGOPTIONS ALTARCHIVELOGDEST /u01/arch

STATOPTIONS REPORTFETCH

table WOAILYOO.OGG;

6.增加传输进程和指定队列文件

GGSCI> add extract dpepdb, exttrailsource ./dirdat/pd

GGSCI>add RMTTRAIL ./dirdat/pd, EXTRACT dpepdb, MEGABYTES 200

EXTRACT dpepdb

PASSTHRU

RMTHOST 192.168.247.16, MGRPORT 7809, compress

RMTTRAIL ./dirdat/pd

table WOAILYOO.OGG;

六.配置目标端OGG

aaa

ORA-16000: database or pluggable database open for read-only access

66cf645d43c1468a42833456f7815af6.png

OGG-00706  Failed to add supplemental log group on table WOAILYOO.OGG due to ORA-16000: database or pluggable database open for read-only access

3075195add27418a8e7efc2a2306f9a6.png

1967321c7f42bf37d29bec5381ffd631.png

b2e0f1464c8ef9db5c452314f130819e.png

可以看到虽然DG库是单实例的,但依然继承群集的架构(双节点)

未完成,明日再写。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值