您好,登錄后才能下訂單哦!
這里必須報怨,提出這個測試的兄弟做的時候出問題了,然后我說做出來給他。但是他現在網吧打游戲mmp!!!
本文主要測試目的:驗證一臺多實例的服務器上是否可以通過OGG來實習實例之間的同步(一臺主機上兩個實例之間表數據通過OGG同步)
主要思路:一般我們OGG的思路是抽取、傳送、應用。雖然OGG有很多種應用方式,但大多都是多臺服務器,畢竟很少遇到一臺服務器兩個庫之間做ogg。當我兄弟問我這個環境是否可以通過OGG同步,我第一反應是可以,大概實現方式就是抽取出來放在本地直接應用就好了。(經過測試的確可以)
操作系統:RatHat Linux 6.5 x64
主機名:source.zhan
IP地址:192.168.214.52
數據庫版本:11.2.0.4 x64
數據庫SID:zhankys(源)、zhankyd(目的)
OGG版本:12.1.2.1
創建所需目錄并授權
--賦權給安裝包
mkdir -p /soft
chown -R oracle:oinstall /soft
chmod -R 775 /soft
--歸檔日志路徑
mkdir -p /archivelog/zhankys
mkdir -p /archivelog/zhankyd
chown -R oracle:oinstall /archivelog
chmod -R 775 /archivelog
--創建OGG安裝目錄
mkdir /ogg
chown -R oracle:oinstall /ogg
chmod -R 775 /ogg
--設置OGG環境變量
echo 'export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib'>>/home/oracle/.bash_profile
數據庫準備(zhankys)
--登錄數據庫
export ORACLE_SID=zhankys
sqlplus / as sysdba
--創建ogg賬戶
create tablespace ogg_tablespace datafile '/u01/app/oracle/oradata/zhankys/ogg01.dbf' size 10m autoextend on next 5m;
create user goldengate identified by goldengate default tablespace ogg_tablespace;
grant dba to goldengate;
--查看歸檔、強制日志模式、數據庫級別的補充日志是否開啟(注意歸檔存放目錄)
archive log list;
select force_logging,supplemental_log_data_min from v$database;
show parameter enable_goldengate_replication;
--開啟歸檔
shutdow immediate
start mount
alter database archivelog;
alter system set log_archive_dest_1='location=/archivelog/zhankys' scope =both;
alter database open;
--開啟數據庫強制日志模式、數據庫級別的補充日志
alter database force logging;
alter database add supplemental log data;
--修改允許使用ogg的參數(針對11.2.0.4庫)
ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;
數據庫準備(zhankyd)
--登錄數據庫
export ORACLE_SID=zhankyd
sqlplus / as sysdba
--創建ogg賬戶
--創建ogg賬戶
create tablespace ogg_tablespace datafile '/u01/app/oracle/oradata/zhankyd/ogg01.dbf' size 10m autoextend on next 5m;
create user goldengate identified by goldengate default tablespace ogg_tablespace;
grant dba to goldengate;
--查看歸檔、強制日志模式、數據庫級別的補充日志是否開啟(注意歸檔存放目錄)
archive log list;
select force_logging,supplemental_log_data_min from v$database;
show parameter enable_goldengate_replication;
--開啟歸檔
shutdow immediate
start mount
alter database archivelog;
alter system set log_archive_dest_1='location=/archivelog/zhankyd' scope =both;
alter database open;
--開啟數據庫強制日志模式、數據庫級別的補充日志
alter database force logging;
alter database add supplemental log data;
--修改允許使用ogg的參數(針對11.2.0.4庫)
ALTER SYSTEM SET ENABLE_GOLDENGATE_REPLICATION = TRUE SCOPE=BOTH;
更改tnsname(源目的相同)
vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
{
ZHANKYS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.214.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ZHANKYS)
)
)
ZHANKYD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.214.52)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ZHANKYD)
)
)
}
初始化數據準備(兩個庫都建)
connect goldengate/goldengate
--創建表
DROP TABLE tcustmer;
CREATE TABLE tcustmer ( cust_code VARCHAR(4) NOT NULL, name VARCHAR(30),
city VARCHAR(20), state CHAR(2), PRIMARY KEY (cust_code));
DROP TABLE tcustord;
CREATE TABLE tcustord ( cust_code VARCHAR(4) NOT NULL, product_code VARCHAR(8) NOT NULL,
order_id INTEGER NOT NULL, product_price DECIMAL(8,2), product_amount INTEGER,
transaction_id INTEGER, PRIMARY KEY (cust_code, product_code, order_id) );
select * from goldengate.tcustmer;
select * from goldengate.tcustord;
OGG軟件安裝
xhost +
su - oracle
cd /soft
unzip 121210_ggs_Linux_x64_shiphome.zip
cd fbo_ggs_Linux_x64_shiphome/Disk1/
./runInstaller
創建ogg目錄
cd /ogg
./ggsci
create subdirs
創建checkpoint表(注意dblogin到兩個庫都創建)
--源主機創建checkpoint表
{
dblogin userid goldengate@zhankys,password goldengate
add checkpointtable goldengate.ggs_checkpoint
}
--源實例創建完后exit在登錄目的庫建checkpoint表
{
dblogin userid goldengate@zhankyd,password goldengate
add checkpointtable goldengate.ggs_checkpoint
}
設置globals
edit params ./globals
{
UNLOCKEDTRAILFILES
}
配置MGR
edit params mgr
{
PORT 7809
AUTOSTART ER *
AUTORESTART ER *,RETRIES 3,WAITMINUTES 5,RESETMINUTES 60
LAGREPORTHOURS 1
LAGINFOMINUTES 3
LAGCRITICALMINUTES 10
PURGEOLDEXTRACTS ./dirdat/*,USECHECKPOINTS,MINKEEPDAYS 3
}
start mgr
配置需要trandata的對象(跟蹤的表為源庫,注意dblogin登錄是否源庫)
dblogin userid goldengate@zhankys,password goldengate
add trandata goldengate.tcustmer
add trandata goldengate.tcustord
info trandata goldengate.*
配置extract(注意userid指定抽取的庫)
add extract e_single,tranlog,begin now
add exttrail ./dirdat/single,extract b_e_29,megabytes 5
edit param e_single
{
EXTRACT e_single
SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
GETENV (NLS_LANG)
userid goldengate@zhankys,password goldengate
EXTTRAIL ./dirdat/single,FORMAT RELEASE 12.1
DISCARDFILE ./dirrpt/e_single.dsc,PURGE
--NOCOMPRESSDELETES
NOCOMPRESSUPDATES
GETUPDATEBEFORES
GETUPDATEAFTERS
TRANLOGOPTIONS LOGRETENTION disabled
WARNLONGTRANS 30m,CHECKINTERVAL 3m
table goldengate.tcustmer;
table goldengate.tcustord;
}
start e_single
info e_single
配置replicat(注意userid指定應用的庫)
dblogin userid goldengate@zhankyd,password goldengate
add replicat r_single,exttrail ./dirdat/single,checkpointtable goldengate.ggs_checkpoint
edit param r_single
{
REPLICAT r_single
SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK")
GETENV (NLS_LANG)
USERID goldengate@zhankyd,PASSWORD goldengate
HANDLECOLLISIONS
ASSUMETARGETDEFS
REPERROR DEFAULT,DISCARD
DBOPTIONS NOSUPPRESSTRIGGERS
DISCARDFILE ./dirrpt/b_r_29.dsc,PURGE
MAP goldengate.TCUSTMER, TARGET goldengate.TCUSTMER;
MAP goldengate.TCUSTORD, TARGET goldengate.TCUSTORD;
}
start r_single
info r_single
select * from goldengate.TCUSTMER;
select * from goldengate.TCUSTORD;
INSERT INTO goldengate.tcustmer VALUES ('ZZZ','BG SOFTWARE CO.','SEATTLE','WZ');
INSERT INTO goldengate.tcustord VALUES ('ZZZ','CAR',144,17520,3,100);
COMMIT;
INSERT INTO goldengate.tcustmer VALUES ('ZqZZ','BqG SOFTWARE CO.','SEATTLE','WZ');
INSERT INTO goldengate.tcustord VALUES ('ZqZZ','CAR',144,17520,3,100);
COMMIT;
INSERT INTO goldengate.tcustmer VALUES ('ZbZ','BzG SOFTWARE CO.','SEATTLE','WZ');
INSERT INTO goldengate.tcustord VALUES ('ZbZ','CAR',144,17520,3,100);
COMMIT;
INSERT INTO goldengate.tcustmer VALUES ('ZghZ','BG SOFTWARE CO.','SEATTLE','WZ');
INSERT INTO goldengate.tcustord VALUES ('ZghZ','CAR',144,17520,3,100);
COMMIT;
delete goldengate.tcustmer where cust_code='ZZZ';
delete goldengate.tcustord where cust_code='ZZZ';
delete goldengate.tcustmer where cust_code='ZqZZ';
delete goldengate.tcustord where cust_code='ZqZZ';
delete goldengate.tcustmer where cust_code='ZbZ';
delete goldengate.tcustord where cust_code='ZbZ';
delete goldengate.tcustmer where cust_code='ZghZ';
delete goldengate.tcustord where cust_code='ZghZ';
commit;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。