如何安装使用goldengate
实现源端到镜像端的数据同步(单向)
查看数据库当前日志模式
archive log list;
更改为归档模式
shutdown immediate;
start mount;
alter database archivelog;
alter database open;
开启第二归档路径(可选)
alter system set log_archive_dest_2=’location=/archive_2OPTIONAL’ scope=spfile;
alter system archive log start tolog_archive_dest_2;
查看第二归档日志是否生效(重启数据库)
show parameter archive;
查看当前数据库是否开启supplementallogging
select SUPPLEMENTAL_LOG_DATA_MIN fromv$database;
开启数据库级别的最小supplementallogging
alter database add supplemental log data;
查看当前数据库forcelogging的状态
select force_logging from v$database;
开启forcelogging
alter database force logging;
创建管理用户的表空间
create tablespace tbs_ggmgr datafiel ‘/u01/app/oracle/goldengate/ggmgr.dbf’size 50M autoextend on;
创建goldengate管理用户
create user ggmgr identified by oracledefault tablespace tbs_ggmgr temporary tablespace TEMP quota unlimited ontbs_ggmgr;
赋予ggmgr相关权限(想简单的话,可以赋予DBA权限)
grant CONNECT,RESOURCE to ggmgr;
grant CREATE SESSION,ALTER SESSION toggmgr;
grant SELECT ANY DICTIONARY,SELECT ANYTABLE to ggmgr;
grant CREATE TABLE,ALTER ANY TABLE to ggmgr;
create user test identified by test;
conn test/test;
create table test(
stuid number(8),
stuname varchar2(20),
stupasswd varchar2(20)
);
insert into test values(1,’test1’,’test1);
insert into test values(2,’test2’,’test2’);
commit;
编辑oracle的home目录下.bash_profile文件
vi .bash_profile
添加如下内容
exportLD_LIBRARY_PATH=$ORACLE_BASE/goldengate:$ORACLE_HOME/lib
通常将goldengate安装在ORACLE_BASE目录下
mkdir �Cp /u01/app/oracle/goldengate/
将goldengate压缩文件解压到goldengate得安装目录
tar vxf ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar
执行./ggsci进入GGSCI
创建目录结构
create subdirs --只在第一次启动执行
在GGSCI中
dbloign userid ggmgr,password oracle
对要进行复制的表添加表级supplemental logging
add trandata test.*
查看
info trandata test.*
edit param mgr
添加如下内容
port 7809
purgeoldextracts ./dirdat/*,usecheckpoints, minkeepfiles 20
添加一个extract进程
add extract exts100,tranlog,begin now
给extract进程指定trail文件
add exttrail ./dirdat/s1,extract exts100,megabytes 100
配置extract的参数
edit param exts100
添加如下内容(开启第二归档的情况下)
extract exts100
userid ggmgr,password oracle
tranlogoptions archivedlogonly
tranlogoptions altarchivelogdest instanceorcl /archive_2
tranlogoptions altarchivedlogformat%t_%s_%r.dbf
gettruncates
reportcount every 30 minutes,rate
discardfile./dirrpt/exts100.dsc,APPEND,MEGABYTES 100
exttail ./dirdat/s1
table TEST.TEST;
add extract dps100 exttrailsource./dirdat/s1
add rmttrail ./dirdat/t1,extract dps100
配置pump进程参数
edit param dps100
extract dps100
userid ggmgr,password oracle
rmthost 192.168.128.101,mgrport7809,compress
numfiles 5000
DYNAMICRESOLUTION
rmttrail ./dirdat/t1
table TEST.TEST;
start <进程名>
start mgr
start exts100
start dps100
查看进程状态
info all
exp username/password file=test_1203013.dmpowner=test triggers=n indexes=n log=test_120313.log;
可以使用ftp
create user test identified by test;
imp username/password file=test_120313.dmpfromuser=test touser=test log=test_120313.log;
查看数据是否导入成功
创建管理用户的表空间
create tablespace tbs_ggmgr datafiel ‘/u01/app/oracle/goldengate/ggmgr.dbf’size 50M autoextend on;
创建goldengate管理用户
create user ggmgr identified by oracledefault tablespace tbs_ggmgr temporary tablespace TEMP quota unlimited ontbs_ggmgr;
赋予ggmgr相关权限(想简单的话,可以赋予DBA权限)
grant CONNECT,RESOURCE to ggmgr;
grant CREATE SESSION,ALTER SESSION toggmgr;
grant SELECT ANY DICTIONARY,SELECT ANYTABLE to ggmgr;
grant CREATE TABLE to ggmgr;
编辑oracle的home目录下.bash_profile文件
vi .bash_profile
添加如下内容
exportLD_LIBRARY_PATH=$ORACLE_BASE/goldengate:$ORACLE_HOME/lib
通常将goldengate安装在ORACLE_BASE目录下
mkdir �Cp /u01/app/oracle/goldengate/
将goldengate压缩文件解压到goldengate得安装目录
tar vxf ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar
执行./ggsci进入GGSCI
创建目录结构
create subdirs --只在第一次启动执行
dblogin userid ggmgr,password oracle
edit params ./GLOBALS
添加如下内容
checkpointtable ggmgr.ogg_checkpointtable
添加检查点表
add checkpointtableggmgr.ogg_checkpointtable
edit param mgr
添加如下内容
port 7809
(这里没有加入清除trail文件的设置)
add replicat rept101,exttrail ./dirdat/t1
编辑replicat进程的参数文件
edit param rept101
添加如下内容
replicat rept101
userid ggmgr,password oracle
ASSUMETARGETDEFS
DISCARDFILE ./dirrpt/rept101.dsc,PURGE
MAP TEST.TEST, TARGET TEST.TEST;
start <进程名>
start mgr
start rept101
查看进程状态
info all
insert into test values(3,’test3,’test3’);
commit;
alter system switch logfile;
select * from test;