OGG(11G)RAC-->单实例 搭建--同构同版本(数据泵初始化)
【摘要】 一、环境介绍项目源库目标库操作系统RHEL6.9RHEL6.9主机名p11g01,p11g02p11gIP地址192.168.1.40/41192.168.1.38数据库及版本ORACLE11.2.0.4ORACLE11.2.0.4数据库字符集AL32UTF8AL32UTF8ORACLE SIDorcl1,orcl2ora11gGoldengate用户oggoggGoldengate版本1...
一、环境介绍
项目 | 源库 | 目标库 |
操作系统 | RHEL6.9 | RHEL6.9 |
主机名 | p11g01,p11g02 | p11g |
IP地址 | 192.168.1.40/41 | 192.168.1.38 |
数据库及版本 | ORACLE11.2.0.4 | ORACLE11.2.0.4 |
数据库字符集 | AL32UTF8 | AL32UTF8 |
ORACLE SID | orcl1,orcl2 | ora11g |
Goldengate用户 | ogg | ogg |
Goldengate版本 | 112103(Linux x86-64) | 112103(Linux x86-64) |
二、GoldenGate安装(源端+目标端)
1、创建OGG安装目录(RAC采用共享盘挂载目录)
源端
--划分磁盘主分区
fdisk /dev/sdd
--查看主分区
lsblk
--格式化主分区
mkfs.ext4 /dev/sdd1
--新建/ogg目录(双节点)
mkdir -p /ogg
chown -R oracle:oinstall /ogg
chmod 775 /ogg
--挂载主分区到/ogg目录
mount /dev/sdd1 /ogg
--配置开机自动挂载
vim /etc/fstab
/dev/sdd1 /ogg ext4 defaults 0 0
--生效
mount -a
目标端
mkdir -p /ogg
chown -R oracle:oinstall /ogg
chmod 775 /ogg
2、修改OGG操作系统用户环境变量(所有RAC节点均配置)
如需配置 alias ggsci='rlwrap ggsci’ 可参考:
https://blog.csdn.net/m0_50546016/article/details/112525017
cat<<EOF >> /home/oracle/.bash_profile
################ogg profile add#########################
export OGG_HOME=/ogg
export PATH=\$ORACLE_HOME/bin:\$PATH:\$OGG_HOME
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$OGG_HOME:/lib:/usr/lib
alias ggsci='rlwrap ggsci'
EOF
3、上传OGG安装介质并解压
chown -R oracle:oinstall /soft/
su - oracle -c "tar -xvf /soft/fbo_ggs_Linux_x64_ora11g_64bit.tar -C /ogg"
4、建立OGG表空间及用户,给用户授权
源端
SQL> show parameter db_create
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string +DATA
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
SQL> create tablespace ogg_data datafile size 1024M;
Tablespace created.
SQL> create user ogg identified by ogg default tablespace ogg_data;
User created.
SQL> grant connect,resource,dba,create table,create sequence to ogg;
Grant succeeded.
目标端
create tablespace ogg_data datafile '/oradata/ora11g/ogg01.dbf' size 1024M;
create user ogg identified by ogg default tablespace ogg_data;
grant connect,resource,dba,create table,create sequence to ogg;
5、配置数据库参数
附加日志
alter database add SUPPLEMENTAL log data;
强制日志
alter database force logging;
检查是否开启
select NAME,OPEN_MODE,FORCE_LOGGING,SUPPLEMENTAL_LOG_DATA_MIN from v$database;
开启归档日志模式
源端
--设置归档路径
su - oracle
sqlplus / as sysdba
alter system set log_archive_dest_1='location=+DATA';
--关闭数据库实例
srvctl stop database -d orcl -o immediate
--开启数据库实例orcl1到mount状态
srvctl start instance -d orcl -i orcl1 -o mount
--开启归档
sqlplus / as sysdba
alter database archivelog;
--开启实例orcl1
alter database open;
--开启数据库实例orcl2
srvctl start instance -d orcl -i orcl2
--查看归档路径
archive log list;
alter system switch logfile;
目标端
mkdir /archivelog
chown -R oracle:oinstall /archivelog/
su - oracle
sqlplus / as sysdba
alter system set log_archive_dest_1='location=/archivelog';
shutdown immediate
startup mount
alter database archivelog;
alter database open;
archive log list;
alter system switch logfile;
关闭回收站
alter system set recyclebin=off scope=spfile;
解锁scott用户
SQL> alter user scott account unlock;
User altered.
SQL> alter user scott identified by scott;
User altered.
6 、TNS配置(所有RAC节点均配置)
加入对ASM的动态注册,具体配置根据环境决定。
注意:RAC所有节点都要配置
--所有节点都要配置
cat <<EOF >> /u01/app/11.2.0/grid/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = +ASM)
(ORACLE_HOME=/u01/app/11.2.0/grid)
(SID_NAME = +ASM1)
)
)
EOF
--重启监听
srvctl stop listener
--查看监听服务
lsnrctl stat
lsnrctl services
--测试连接
sqlplus sys/oracle@192.168.1.40/+ASM as sysdba
sqlplus sys/oracle@192.168.1.41/+ASM as sysdba
--oracle下配置TNS
##节点一配置
cat <<EOF >> /u01/app/oracle/product/11.2.0/db/network/admin/tnsnames.ora
+ASM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.40)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = +ASM)
)
)
EOF
##节点二配置
cat <<EOF >> /u01/app/oracle/product/11.2.0/db/network/admin/tnsnames.ora
+ASM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.41)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = +ASM)
)
)
EOF
--TNS测试连接
sqlplus sys/oracle@+ASM as sysdba
7、GGSCI初始化目录
cd /ogg
ggsci
GGSCI (s11g) 1> create subdirs
三、GoldenGate配置
1、配置mgr进程(源端+目标端)
GGSCI (s11g) 1> edit params mgr
GGSCI (s11g) 2> view params mgr
port 7809
GGSCI (s11g) 3> start mgr
Manager started.
GGSCI (s11g) 4> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
GGSCI (s11g) 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 :::7809 :::* LISTEN 5760/./mgr
GGSCI (s11g) 7> sh ps -ef|grep mgr
root 14 2 0 09:59 ? 00:00:00 [async/mgr]
postfix 1683 1676 0 09:59 ? 00:00:00 qmgr -l -t fifo -u
oracle 5760 5752 0 11:52 ? 00:00:00 ./mgr PARAMFILE /ogg/dirprm/mgr.prm REPORTFILE /ogg/dirrpt/MGR.rpt PROCESSID MGR PORT 7809
oracle 5852 5752 0 12:15 pts/0 00:00:00 sh -c ps -ef|grep mgr
oracle 5854 5852 0 12:15 pts/0 00:00:00 grep mgr
2、添加表级trandata(源端)
GGSCI (p11g01) 121> add trandata scott.*
2021-03-27 23:08:32 WARNING OGG-00869 No unique key is defined for table 'BONUS'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SCOTT.BONUS.
Logging of supplemental redo data enabled for table SCOTT.DEPT.
Logging of supplemental redo log data is already enabled for table SCOTT.EMP.
2021-03-27 23:08:34 WARNING OGG-00869 No unique key is defined for table 'SALGRADE'. All viable columns will be used to represent the key, but may not guarantee uniqueness. KEYCOLS may be used to define the key.
Logging of supplemental redo data enabled for table SCOTT.SALGRADE.
GGSCI (p11g01) 122> info trandata scott.*
Logging of supplemental redo log data is enabled for table SCOTT.BONUS.
Columns supplementally logged for table SCOTT.BONUS: ENAME, JOB, SAL, COMM.
Logging of supplemental redo log data is enabled for table SCOTT.DEPT.
Columns supplementally logged for table SCOTT.DEPT: DEPTNO.
Logging of supplemental redo log data is enabled for table SCOTT.EMP.
Columns supplementally logged for table SCOTT.EMP: EMPNO.
Logging of supplemental redo log data is enabled for table SCOTT.SALGRADE.
Columns supplementally logged for table SCOTT.SALGRADE: GRADE, LOSAL, HISAL.
3、配置extract抽取进程(源端)
GGSCI (p11g01) 11> add extract ext1,tranlog,begin now,threads 2
EXTRACT added.
GGSCI (p11g01) 12> add exttrail /ogg/dirdat/et,extract ext1
EXTTRAIL added.
GGSCI (p11g01) 13> edit param ext1
GGSCI (p11g01) 14> view param ext1
EXTRACT ext1
SETENV (NLS_LANG="AMERICAN_AMERICA.AL32UTF8") --此处数据库字符集设为一致
USERID ogg, PASSWORD ogg
TRANLOGOPTIONS ASMUSER sys@+ASM,ASMPASSWORD oracle
THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 20000
EXTTRAIL /ogg/dirdat/et
DYNAMICRESOLUTION
--DDL INCLUDE ALL
TABLE scott.*
GGSCI (p11g01) 15> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT STOPPED EXT1 00:00:00 00:02:07
4、配置pump传输进程(源端)
GGSCI (p11g01) 16> add extract pump1,exttrailsource /ogg/dirdat/et,begin now
EXTRACT added.
GGSCI (p11g01) 17> add rmttrail /ogg/dirdat/et,extract pump1
RMTTRAIL added.
GGSCI (p11g01) 18> edit param pump1
GGSCI (p11g01) 19> view param pump1
EXTRACT pump1
RMTHOST 192.168.1.38, MGRPORT 7809
RMTTRAIL /ogg/dirdat/et
PASSTHRU
DYNAMICRESOLUTION
TABLE scott.*;
GGSCI (p11g01) 20> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT STOPPED EXT1 00:00:00 00:07:18
EXTRACT STOPPED PUMP1 00:00:00 00:01:40
5、添加GLOBALS参数文件,创新检查点表(源端+目标端)
GGSCI (p11g01) 21> edit params ./GLOBALS
GGSCI (p11g01) 22> view param /ogg/GLOBALS
GGSCHEMA ogg
checkpointtable ogg.checkpoint
GGSCI (p11g01) 23> add checkpointtable ogg.checkpoint
Successfully created checkpoint table ogg.checkpoint.
6、配置replicat复制进程(目标端)
GGSCI (p11g) 10> add replicat rep1,exttrail /ogg/dirdat/et,checkpointtable ogg.checkpoint
REPLICAT added.
GGSCI (p11g) 11> edit param rep1
GGSCI (p11g) 12> view param rep1
REPLICAT rep1
setenv (ORACLE_SID=ora11g)
SETENV (ORACLE_HOME = "/u01/app/oracle/product/11.2.0/db")
USERID ogg,PASSWORD ogg
ASSUMETARGETDEFS
HANDLECOLLISIONS
REPERROR (DEFAULT, DISCARD)
DDLERROR DEFAULT DISCARD
DDLOPTIONS REPORT
DISCARDFILE /ogg/dirrpt/repr1.dsc,append,megabytes 100
MAP scott.*, TARGET scott.*;
四、数据初始化(EXPDP)
1、启动源端的EXTRACT进程
GGSCI (p11g01) 59> start ext1
Sending START request to MANAGER ...
EXTRACT EXT1 starting
GGSCI (p11g01) 101> start pump1
Sending START request to MANAGER ...
EXTRACT PUMP1 starting
GGSCI (p11g01) 105> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXT1 00:00:00 00:00:00
EXTRACT RUNNING PUMP1 00:00:00 00:00:05
2、查看数据库中所有事务的开始时间
查看数据库中所有事务的开始时间,直到其大于抽取进程的启动时间再开始备份数
据库,因为GoldenGate 的只获取在Extract 启动以后的交易变化,在Extract 启动之
前开始而在Extract 启动以后才完成的交易GoldenGate 将会忽略这些交易,这些被忽
略的交易数据就会丢失。所以需要等数据库中所以的交易都在Extract 启动之后开始
的才能开始备份数据库。通过gv$transaction 视图来查看数据库中的交易:
SQL> select * from gv$transaction;
no rows selected
这里是测试环境没有事物,可以进行后面的备份了。
3、EXPDP 备份源端数据库
--当所有在Extract 启动之前的开始的交易都完成后,我们就可以使用expdp 备份生产端的数据库了。备份数据库的过程中一定要密切监控Extract 进程的状态,保证其一直正常运行:
GGSCI (p11g01) 107> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXT1 00:00:00 00:00:05
EXTRACT RUNNING PUMP1 00:00:00 00:00:08
源端查询当前数据库SCN
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
1147075
创建导出目录
mkdir /backup
chown -R oracle:oinstall /backup/
SQL> create or replace directory dump_dir as '/backup';
Directory created.
备份源端数据库
expdp system/oracle directory=dump_dir dumpfile=scott.dmp logfile=scott.log schemas=scott flashback_scn= 1147075
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . exported "SCOTT"."DEPT" 5.929 KB 4 rows
. . exported "SCOTT"."EMP" 8.562 KB 14 rows
. . exported "SCOTT"."SALGRADE" 5.859 KB 5 rows
. . exported "SCOTT"."BONUS" 0 KB 0 rows
将备份文件传到目标端
scp /backup/* 192.168.1.38:/backup
oracle@192.168.1.38's password:
scott.dmp 100% 256KB 256.0KB/s 00:01
scott.log 100% 1871 1.8KB/s 00:00
目标端IMPDP 初始化数据
[oracle@p11g backup]$ impdp system/oracle directory=dump_dir dumpfile= scott.dmp logfile=imp_scott.log table_exists_action=replace SCHEMAS=scott
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."DEPT" 5.929 KB 4 rows
. . imported "SCOTT"."EMP" 8.562 KB 14 rows
. . imported "SCOTT"."SALGRADE" 5.859 KB 5 rows
. . imported "SCOTT"."BONUS" 0 KB 0 rows
用SCN 启动Replicat
GGSCI (p11g) 13> start rep1, aftercsn 1147075
Sending START request to MANAGER ...
REPLICAT REP1 starting
GGSCI (p11g) 14> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT RUNNING REP1 00:00:00 00:00:02
五、检查同步是否正常
1、DML测试
--测试前数据比对:源端目标端数据一致
SQL> conn scott/scott
Connected.
SQL> set line222
SQL> set pagesize100
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
--源端insert
insert into emp (empno,ename,job) values (9874,'LUCIFER','DBA');
--源端update
update emp set ename='ECHO' where empno=7934;
--源端delete
delete from emp where empno=7369;
commit;
--比对源端目标端数据,已同步
SCOTT@ora11g>/
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- --------
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 ECHO CLERK 7782 23-JAN-82 1300 10
9874 LUCIFER DBA
14 rows selected.
--查看抽取进程记录
GGSCI (p11g01) 111> stats ext1
Sending STATS request to EXTRACT EXT1 ...
Start of Statistics at 2021-03-27 22:57:05.
Output to /ogg/dirdat/et:
Extracting from SCOTT.EMP to SCOTT.EMP:
*** Total statistics since 2021-03-27 22:49:41 ***
Total inserts 1.00
Total updates 1.00
Total deletes 1.00
Total discards 0.00
Total operations 3.00
--查看传输进程
GGSCI (p11g01) 112> stats pump1
Sending STATS request to EXTRACT PUMP1 ...
Start of Statistics at 2021-03-27 22:58:14.
Output to /ogg/dirdat/et:
Extracting from SCOTT.EMP to SCOTT.EMP:
*** Total statistics since 2021-03-27 22:49:41 ***
Total inserts 1.00
Total updates 1.00
Total deletes 1.00
Total discards 0.00
Total operations 3.00
--查看复制进程
GGSCI (p11g) 21> stats rep1
Sending STATS request to REPLICAT REP1 ...
Start of Statistics at 2021-03-27 22:58:41.
Replicating from SCOTT.EMP to SCOTT.EMP:
*** Total statistics since 2021-03-27 22:49:46 ***
Total inserts 1.00
Total updates 1.00
Total deletes 1.00
Total discards 0.00
Total operations 3.00
开启DDL
在源端执行与DDL同步相关的SQL脚本
切记@marker_setup.sql 一定要在cd $OGG_HOME目录下执行否则会卡主。执行脚本时要输入ogg管理用户,本实例是ogg。
cd /ogg
sqlplus / as sysdba
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
源端extract 配置
GGSCI (p11g01) 114> edit param ext1
GGSCI (p11g01) 115> view param ext1
EXTRACT ext1
SETENV (NLS_LANG="AMERICAN_AMERICA.AL32UTF8") --此处数据库字符集设为一致
USERID ogg, PASSWORD ogg
TRANLOGOPTIONS ASMUSER sys@+ASM,ASMPASSWORD oracle
THREADOPTIONS MAXCOMMITPROPAGATIONDELAY 20000
EXTTRAIL /ogg/dirdat/et
DYNAMICRESOLUTION
DDL INCLUDE ALL
TABLE scott.*;
GGSCI (p11g01) 116> stop ext1
Sending STOP request to EXTRACT EXT1 ...
Request processed.
GGSCI (p11g01) 117> start ext1
Sending START request to MANAGER ...
EXTRACT EXT1 starting
GGSCI (p11g01) 118> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXT1 00:00:00 00:00:05
EXTRACT RUNNING PUMP1 00:00:00 00:00:08
目标端replicat 配置
GGSCI (p11g) 23> edit param rep1
GGSCI (p11g) 24> view param rep1
REPLICAT rep1
setenv (ORACLE_SID=ora11g)
SETENV (ORACLE_HOME = "/u01/app/oracle/product/11.2.0/db")
USERID ogg,PASSWORD ogg
ASSUMETARGETDEFS
HANDLECOLLISIONS
REPERROR (DEFAULT, DISCARD)
DDLERROR DEFAULT DISCARD
DDLOPTIONS REPORT
DISCARDFILE /ogg/dirrpt/repr1.dsc,append,megabytes 100
MAP scott.*, TARGET scott.*;
ddl include all
ddlerror default ignore retryop maxretries 3 retrydelay 5
GGSCI (p11g) 25> stop rep1
Sending STOP request to REPLICAT REP1 ...
Request processed.
GGSCI (p11g) 26> start rep1
Sending START request to MANAGER ...
REPLICAT REP1 starting
GGSCI (p11g) 27> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
REPLICAT RUNNING REP1 00:00:00 00:00:00
DDL测试
--源端创建表
SQL> create table lucifer(id number not null,name varchar2(20));
Table created.
SQL> alter table lucifer add primary key(id);
Table altered.
--增加trandata
GGSCI (p11g01) 130> add trandata scott.lucifer
Logging of supplemental redo data enabled for table SCOTT.LUCIFER.
GGSCI (p11g01) 131> info trandata scott.lucifer
Logging of supplemental redo log data is enabled for table SCOTT.LUCIFER.
Columns supplementally logged for table SCOTT.LUCIFER: ID.
--目标端查看
SYS@ora11g>conn scott/scott
Connected.
SCOTT@ora11g>select table_name from user_tables;
TABLE_NAME
------------------------------
LUCIFER
SALGRADE
BONUS
EMP
DEPT
SCOTT@ora11g>desc lucifer
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER
NAME VARCHAR2(20)
六、测试RAC共享盘切换
假设节点一由于各种原因down机了,我们可以通过节点二mount ogg共享盘,切换到节点二进行同步
1、节点一停止所有进程
GGSCI (p11g01) 134> stop ext1
Sending STOP request to EXTRACT EXT1 ...
Request processed.
GGSCI (p11g01) 135> stop pump1
Sending STOP request to EXTRACT PUMP1 ...
Request processed.
GGSCI (p11g01) 136>
GGSCI (p11g01) 136>
GGSCI (p11g01) 136> stop mgr
Manager process is required by other GGS processes.
Are you sure you want to stop it (y/n)? y
Sending STOP request to MANAGER ...
Request processed.
Manager stopped.
GGSCI (p11g01) 137>
GGSCI (p11g01) 137>
GGSCI (p11g01) 137> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT STOPPED EXT1 00:00:00 00:00:19
EXTRACT STOPPED PUMP1 00:00:00 00:00:15
2、节点二mount ogg共享盘
[root@p11g02 ~]# mount /ogg
[root@p11g02 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_p11g02-lv_root
ext4 50G 12G 35G 26% /
tmpfs tmpfs 2.0G 536M 1.5G 28% /dev/shm
/dev/sda1 ext4 477M 42M 410M 10% /boot
/dev/mapper/vg_p11g02-lv_home
ext4 45G 53M 43G 1% /home
/dev/sdd1 ext4 9.8G 251M 9.0G 3% /ogg
3、开启所有进程
[oracle@p11g02 ~]$ cd /ogg
[oracle@p11g02 ogg]$ ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.3 14400833 OGGCORE_11.2.1.0.3_PLATFORMS_120823.1258_FBO
Linux, x64, 64bit (optimized), Oracle 11g on Aug 23 2012 20:20:21
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (p11g02) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT ABENDED EXT1 00:00:00 00:00:04
EXTRACT ABENDED PUMP1 00:00:00 00:00:09
GGSCI (p11g02) 2>
GGSCI (p11g02) 2>
GGSCI (p11g02) 2> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER STOPPED
EXTRACT ABENDED EXT1 00:00:00 00:00:39
EXTRACT ABENDED PUMP1 00:00:00 00:00:45
GGSCI (p11g02) 3> start mgr
Manager started.
GGSCI (p11g02) 4> start ext1
Sending START request to MANAGER ...
EXTRACT EXT1 starting
GGSCI (p11g02) 5> start pump1
Sending START request to MANAGER ...
EXTRACT PUMP1 starting
GGSCI (p11g02) 6> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EXT1 00:00:01 00:00:04
EXTRACT RUNNING PUMP1 00:00:00 00:00:58
4、测试同步
源端
SQL> select * from lucifer;
no rows selected
SQL> insert into lucifer(id,name) values (1,'lucifer');
1 row created.
SQL> insert into lucifer(id,name) values (2,'echo');
1 row created.
SQL> commit;
Commit complete.
SQL> create table echo(id number primary key,name varchar2(20));
Table created.
SQL> select * from lucifer;
ID NAME
---------- --------------------
1 lucifer
2 echo
SQL> desc echo
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER
NAME VARCHAR2(20)
源端增加trandata scott.echo
GGSCI (p11g02) 12> dblogin userid ogg,password ogg
Successfully logged into database.
GGSCI (p11g02) 13> add trandata scott.echo
Logging of supplemental redo data enabled for table SCOTT.ECHO.
GGSCI (p11g02) 14> info trandata scott.echo
Logging of supplemental redo log data is enabled for table SCOTT.ECHO.
Columns supplementally logged for table SCOTT.ECHO: ID.
目标端已同步
SCOTT@ora11g>select * from lucifer;
ID NAME
---------- --------------------
1 lucifer
2 echo
SCOTT@ora11g>desc echo
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER
NAME VARCHAR2(20)
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)