linux下gate版本管理,Linux安装使用GoldenGate
如何安裝使用goldengate
一.環(huán)境:
OS:linux CentOS_Final_5.5(64bit)
DB:oracle11gR2(單機模式)
goldengate: ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar
網(wǎng)絡(luò):局域網(wǎng),源端IP 192.168.128.100 ?鏡像端IP ?192.168.128.101
二.目標:
實現(xiàn)源端到鏡像端的數(shù)據(jù)同步(單向)
三.源端數(shù)據(jù)庫實施:
1數(shù)據(jù)庫準備
1.1開啟數(shù)據(jù)庫歸檔日志
查看數(shù)據(jù)庫當前日志模式
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;
查看第二歸檔日志是否生效(重啟數(shù)據(jù)庫)
show parameter archive;
1.2開啟supplemental logging和force logging
查看當前數(shù)據(jù)庫是否開啟supplementallogging
select SUPPLEMENTAL_LOG_DATA_MIN fromv$database;
開啟數(shù)據(jù)庫級別的最小supplementallogging
alter database add supplemental log data;
查看當前數(shù)據(jù)庫forcelogging的狀態(tài)
select force_logging from v$database;
開啟forcelogging
alter database force logging;
1.3創(chuàng)建goldengate管理用戶,并賦予相關(guān)權(quán)限
創(chuàng)建管理用戶的表空間
create tablespace tbs_ggmgr datafiel ‘/u01/app/oracle/goldengate/ggmgr.dbf’size 50M autoextend on;
創(chuàng)建goldengate管理用戶
create user ggmgr identified by oracledefault tablespace tbs_ggmgr temporary tablespace TEMP quota unlimited ontbs_ggmgr;
賦予ggmgr相關(guān)權(quán)限(想簡單的話,可以賦予DBA權(quán)限)
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;
1.4創(chuàng)建測試用戶和表
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;
2goldengate安裝及參數(shù)設(shè)置
2.1設(shè)置goldengate運行所需的環(huán)境變量
編輯oracle的home目錄下.bash_profile文件
vi .bash_profile
添加如下內(nèi)容
exportLD_LIBRARY_PATH=$ORACLE_BASE/goldengate:$ORACLE_HOME/lib
2.2創(chuàng)建goldengate安裝目錄
通常將goldengate安裝在ORACLE_BASE目錄下
mkdir –p /u01/app/oracle/goldengate/
2.3解壓并初始化goldengate
將goldengate壓縮文件解壓到goldengate得安裝目錄
tar vxf ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar
執(zhí)行./ggsci進入GGSCI
創(chuàng)建目錄結(jié)構(gòu)
create subdirs ?--只在第一次啟動執(zhí)行
2.4 添加trandata
在GGSCI中
dbloign userid ggmgr,password oracle
對要進行復(fù)制的表添加表級supplemental logging
add trandata test.*
查看
info trandata test.*
2.5添加并配置mgr進程
edit param mgr
添加如下內(nèi)容
port 7809
purgeoldextracts ./dirdat/*,usecheckpoints, minkeepfiles 20
2.6添加并配置extract進程
添加一個extract進程
add extract exts100,tranlog,begin now
給extract進程指定trail文件
add exttrail ./dirdat/s1,extract exts100,megabytes 100
配置extract的參數(shù)
edit param exts100
添加如下內(nèi)容(開啟第二歸檔的情況下)
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;
2.7添加并配置pump進程
add extract dps100 exttrailsource./dirdat/s1
add rmttrail ./dirdat/t1,extract dps100
配置pump進程參數(shù)
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;
2.8檢查進程是否能夠成功啟動
start
start mgr
start exts100
start dps100
查看進程狀態(tài)
info all
四.鏡像端數(shù)據(jù)庫的初始化
1.從源端數(shù)據(jù)庫導(dǎo)出相關(guān)的數(shù)據(jù)和表結(jié)構(gòu)(需要相關(guān)權(quán)限,可以使用有DBA權(quán)限的用戶)
exp username/password file=test_1203013.dmpowner=test triggers=n indexes=n log=test_120313.log;
2.將導(dǎo)出的數(shù)據(jù)文件傳到鏡像端
可以使用ftp
3.在鏡像端創(chuàng)建和源端對應(yīng)的用戶和表空間,要保持表空間的名字一致
create user test identified by test;
4.在鏡像端導(dǎo)入數(shù)據(jù)文件(需要相關(guān)權(quán)限,可以使用有DBA權(quán)限的用戶)
imp username/password file=test_120313.dmpfromuser=test touser=test log=test_120313.log;
查看數(shù)據(jù)是否導(dǎo)入成功
五.鏡像端數(shù)據(jù)庫實施
1數(shù)據(jù)庫準備
創(chuàng)建管理用戶的表空間
create tablespace tbs_ggmgr datafiel ‘/u01/app/oracle/goldengate/ggmgr.dbf’size 50M autoextend on;
創(chuàng)建goldengate管理用戶
create user ggmgr identified by oracledefault tablespace tbs_ggmgr temporary tablespace TEMP quota unlimited ontbs_ggmgr;
賦予ggmgr相關(guān)權(quán)限(想簡單的話,可以賦予DBA權(quán)限)
grant CONNECT,RESOURCE to ggmgr;
grant CREATE SESSION,ALTER SESSION toggmgr;
grant SELECT ANY DICTIONARY,SELECT ANYTABLE to ggmgr;
grant CREATE TABLE to ggmgr;
2goldengate安裝及參數(shù)設(shè)置
2.1.設(shè)置goldengate運行所需的環(huán)境變量
編輯oracle的home目錄下.bash_profile文件
vi .bash_profile
添加如下內(nèi)容
exportLD_LIBRARY_PATH=$ORACLE_BASE/goldengate:$ORACLE_HOME/lib
2.2.創(chuàng)建goldengate安裝目錄
通常將goldengate安裝在ORACLE_BASE目錄下
mkdir –p /u01/app/oracle/goldengate/
2.3.解壓并初始化goldengate
將goldengate壓縮文件解壓到goldengate得安裝目錄
tar vxf ggs_Linux_x64_ora11g_64bit_v11_1_1_0_0_078.tar
執(zhí)行./ggsci進入GGSCI
創(chuàng)建目錄結(jié)構(gòu)
create subdirs ?--只在第一次啟動執(zhí)行
2.4編輯全局參數(shù)文件
dblogin userid ggmgr,password oracle
edit params ./GLOBALS
添加如下內(nèi)容
checkpointtable ggmgr.ogg_checkpointtable
添加檢查點表
add checkpointtableggmgr.ogg_checkpointtable
2.5.添加并配置mgr進程
edit param mgr
添加如下內(nèi)容
port 7809
(這里沒有加入清除trail文件的設(shè)置)
2.6.添加并配置replicat進程
add replicat rept101,exttrail ./dirdat/t1
編輯replicat進程的參數(shù)文件
edit param rept101
添加如下內(nèi)容
replicat rept101
userid ggmgr,password oracle
ASSUMETARGETDEFS
DISCARDFILE ./dirrpt/rept101.dsc,PURGE
MAP TEST.TEST, TARGET TEST.TEST;
2.7檢查進程能否成功啟動
start
start mgr
start rept101
查看進程狀態(tài)
info all
六.測試
1.在源端數(shù)據(jù)庫插入數(shù)據(jù)
insert into test values(3,’test3,’test3’);
commit;
2.生成歸檔日志
alter system switch logfile;
3.查看鏡像端數(shù)據(jù)庫
select * from test;
總結(jié)
以上是生活随笔為你收集整理的linux下gate版本管理,Linux安装使用GoldenGate的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于 iOS 16 照片应用“重复项目”
- 下一篇: linux uboot 源码分析,UBo