怎樣指定oracle
創(chuàng)新互聯(lián)網(wǎng)站建設(shè)提供從項目策劃、軟件開發(fā),軟件安全維護、網(wǎng)站優(yōu)化(SEO)、網(wǎng)站分析、效果評估等整套的建站服務(wù),主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、成都網(wǎng)站制作,APP應(yīng)用開發(fā)以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。創(chuàng)新互聯(lián)深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
ogg
投遞進程從指定的scn開始
1、首先登陸ogg服務(wù)器
2、用命令
su
-
oracle卻換到oracle用戶
3、用命令
cd
ogg進入到ogg目錄
4、用命令
./ggsci進入到ogg命令行界面
5、用命令
info
all查看ogg進程運行情況
6、用命令
view
report
xxxx可以查看某個進入的運行信息日志
(如何那個進程掛起了就看那個的)
例如view
report
r_in!
Oracle Goldengate目前支持主被動式的雙向配置,換而言之OGG可以將來自于激活的主庫的數(shù)據(jù)變化完全復(fù)制到從庫中,從庫在不斷同步數(shù)據(jù)的同時已經(jīng)為計劃內(nèi)的和計劃外的outages做好了故障切換的準備,也就是我們說的Live Standby。這里我們重點介紹一下配置Oracle Goldengate Live Standby系統(tǒng)的步驟,和具體的故障切換過程。
如果自己搞不定可以找ASKMACLEAN專業(yè)ORACLE數(shù)據(jù)庫修復(fù)團隊成員幫您恢復(fù)!
SQL?conn?clinic/clinic
Connected.
SQL?drop?table?tv;
create?table?tv?(t1?int?primary?key,t2?int,t3?varchar2(30));
Table?dropped.
SQL?
Table?created.
SQL?drop?sequence?seqt1;
create?sequence?seqt1?start?with?1?increment?by?1;
Sequence?dropped.
SQL?SQL
Sequence?created.
declare
rnd?number(9,2);
begin
for?i?in?1..100000?loop
insert?into?tv?values(seqt1.nextval,i*dbms_random.value,'MACLEAN?IS?TESTING');
commit;
end?loop;
end;
/
/*?以上腳本在primary主庫的某個應(yīng)用賬戶下創(chuàng)建了測試用的數(shù)據(jù),
接著我們可以使用各種工具將數(shù)據(jù)初始化到從庫中,如果在這個過程中
希望實時在線數(shù)據(jù)遷移的話,可以參考《Goldengate實現(xiàn)在線數(shù)據(jù)遷移》
*/
/*?注意我們在Live?Standby的環(huán)境中往往需要復(fù)制sequence序列,以保證切換到備庫時業(yè)務(wù)可以正常進行??*/
/*?初始化備庫數(shù)據(jù)后,確保已與主庫完全一致?*/
primary?:
SQL?select?sum(t2)?from?tv;
SUM(T2)
----------
2498624495
SQL?select?last_number?from?user_sequences;
LAST_NUMBER
-----------
100001
standby:
SQL?select?sum(t2)?from?tv;
SUM(T2)
----------
2498624495
SQL?select?last_number?from?user_sequences;
LAST_NUMBER
-----------
100001
以上完成準備工作后,我們可以進入到正式配置Goldengate?live?stanby的階段,包括以下步驟:
配置由主庫到備庫的extract、replicat、data?pump,該步驟同普通的單向復(fù)制沒有太大的區(qū)別
配置由備庫到主庫的extract、replicat、data?pump
啟動由主庫到備庫的extract、replicat、data?pump
接下來我們會實踐整個配置過程:
1.
創(chuàng)建由主庫到備庫的extract、data?pump、replicat
GGSCI?(rh2.oracle.com)?10?dblogin?userid?maclean
Password:?
Successfully?logged?into?database.
GGSCI?(rh2.oracle.com)?11?add?trandata?clinic.*
Logging?of?supplemental?redo?data?enabled?for?table?CLINIC.TV
GGSCI?(rh2.oracle.com)?4?add?extract?extstd1,tranlog,begin?now
EXTRACT?added.
GGSCI?(rh2.oracle.com)?5?add?exttrail?/d01/ext/cl,megabytes?100,extract?extstd1
EXTTRAIL?added.
GGSCI?(rh2.oracle.com)?7?view?params?extstd1
--?Identify?the?Extract?group:
EXTRACT?extstd1
--?Specify?database?login?information?as?needed?for?the?database:
userid?maclean,?password?maclean
--?Specify?the?local?trail?that?this?Extract?writes?to:
EXTTRAIL?/d01/ext/cl
--?Specify?sequences?to?be?captured:
SEQUENCE?clinic.seqt1;
--?Specify?tables?to?be?captured:
TABLE?clinic.*;
--?Exclude?specific?tables?from?capture?if?needed:
--?TABLEEXCLUDE?
GGSCI?(rh2.oracle.com)?17?add?extract?pumpstd1,exttrailsource?/d01/ext/cl,begin?now
EXTRACT?added.
GGSCI?(rh2.oracle.com)?98?add?rmttrail?/d01/rmt/cl,megabytes?100,extract?pumpstd1
RMTTRAIL?added.
GGSCI?(rh2.oracle.com)?129?view?params?pumpstd1
--?Identify?the?data?pump?group:
EXTRACT?pumpstd1
userid?maclean,?password?maclean
--?Specify?database?login?information?as?needed?for?the?database:
userid?maclean,?password?maclean
RMTHOST?rh3.oracle.com,?MGRPORT?7809
--?Specify?the?remote?trail?on?the?standby?system:
RMTTRAIL?/d01/rmt/cl
--?Pass?data?through?without?mapping,?filtering,?conversion:
PASSTHRU
sequence?clinic.seqt1;
Table?clinic.*;
在備庫上配置由主庫到備庫的replicat:
GGSCI?(rh3.oracle.com)?4?add?replicat?repstd1,exttrail?/d01/rmt/cl,begin?now
REPLICAT?added.
GGSCI?(rh3.oracle.com)?49?view?params?repstd1
--?Identify?the?Replicat?group:
REPLICAT?repstd1
--?State?that?source?and?target?definitions?are?identical:
ASSUMETARGETDEFS
--?Specify?database?login?information?as?needed?for?the?database:
userid?maclean,?password?maclean
--?Specify?tables?for?delivery:
MAP?clinic.*,?TARGET?clinic.*;
--?Exclude?specific?tables?from?delivery?if?needed:
--?MAPEXCLUDE?
2.
創(chuàng)建由備庫到主庫的extract、data?pump、replicat
GGSCI?(rh3.oracle.com)?51?dblogin?userid?maclean
Password:?
Successfully?logged?into?database.
GGSCI?(rh3.oracle.com)?52?add?trandata?clinic.*
Logging?of?supplemental?redo?data?enabled?for?table?CLINIC.TV.
/*?不要忘記在備庫端的相關(guān)表加上追加日志?*/
GGSCI?(rh3.oracle.com)?53?add?extract?extstd2,tranlog,begin?now
EXTRACT?added.
GGSCI?(rh3.oracle.com)?54?add?exttrail?/d01/ext/cl,megabytes?100,extract?extstd2
EXTTRAIL?added.
GGSCI?(rh3.oracle.com)?58?view?params?extstd2
--?Identify?the?Extract?group:
EXTRACT?extstd2
--?Specify?database?login?information?as?needed?for?the?database:
userid?maclean,?password?maclean
--?Specify?the?local?trail?that?this?Extract?writes?to:
EXTTRAIL?/d01/ext/cl
--?Specify?sequences?to?be?captured:
SEQUENCE?clinic.seqt1;
--?Specify?tables?to?be?captured:
TABLE?clinic.*;
--?Exclude?specific?tables?from?capture?if?needed:
--?TABLEEXCLUDE?
GGSCI?(rh3.oracle.com)?59?add?extract?pumpstd2,exttrailsource?/d01/ext/cl,begin?now
EXTRACT?added.
GGSCI?(rh3.oracle.com)?60?add?rmttrail?/d01/rmt/cl,megabytes?100,extract?pumpstd2
RMTTRAIL?added.
GGSCI?(rh3.oracle.com)?63?view?params?pumpstd2
--?Identify?the?data?pump?group:
EXTRACT?pumpstd2
userid?maclean,?password?maclean
--?Specify?database?login?information?as?needed?for?the?database:
userid?maclean,?password?maclean
RMTHOST?rh2.oracle.com,?MGRPORT?7809
--?Specify?the?remote?trail?on?the?standby?system:
RMTTRAIL?/d01/rmt/cl
--?Pass?data?through?without?mapping,?filtering,?conversion:
PASSTHRU
sequence?clinic.seqt1;
Table?clinic.*;
在主庫上配置replicat:
GGSCI?(rh2.oracle.com)?136?add?replicat?repstd2,exttrail?/d01/rmt/cl,begin?now,checkpointtable?maclean.ck
REPLICAT?added.
GGSCI?(rh2.oracle.com)?138?view?params?repstd2
--?Identify?the?Replicat?group:
REPLICAT?repstd2
--?State?that?source?and?target?definitions?are?identical:
ASSUMETARGETDEFS
--?Specify?database?login?information?as?needed?for?the?database:
userid?maclean,?password?maclean
--?Specify?tables?for?delivery:
MAP?clinic.*,?TARGET?clinic.*;
--?Exclude?specific?tables?from?delivery?if?needed:
--?MAPEXCLUDE?
3.
完成以上OGG配置后,可以啟動主庫到備庫的extract、pump、以及replicat:
GGSCI?(rh2.oracle.com)?141?start?extstd1
Sending?START?request?to?MANAGER?...
EXTRACT?EXTSTD1?starting
GGSCI?(rh2.oracle.com)?142?start?pumpstd1
Sending?START?request?to?MANAGER?...
EXTRACT?PUMPSTD1?starting
GGSCI?(rh3.oracle.com)?70?start?repstd1
Sending?START?request?to?MANAGER?...
REPLICAT?REPSTD1?starting
/*?如果你是在offline狀態(tài)下配置的話,那么此時可以啟用應(yīng)用了*/
接下來我們嘗試做有計劃的主備庫切換演練:
1.
首先停止一切在主庫上的應(yīng)用,這一點和DataGuard?Switchover一樣。在保證沒有活動事務(wù)的情況下,才能切換干凈。
2.
在主庫端使用LAG等命令了解extract的延遲,若返回如"At?EOF,?no?more?records?to?process"的信息,則說明所有事務(wù)均已被抽取。
GGSCI?(rh2.oracle.com)?144?lag?extstd1
Sending?GETLAG?request?to?EXTRACT?EXTSTD1?...
Last?record?lag:?0?seconds.
At?EOF,?no?more?records?to?process.
在EOF的前提下關(guān)閉extract:
GGSCI?(rh2.oracle.com)?146?stop?extstd1?
Sending?STOP?request?to?EXTRACT?EXTSTD1?...
Request?processed.
3.
同樣對pump使用LAG命令,若返回如"At?EOF,?no?more?records?to?process"的信息,則說明已抽取的數(shù)據(jù)都被發(fā)送到備庫了。
GGSCI?(rh2.oracle.com)?147?lag?pumpstd1
Sending?GETLAG?request?to?EXTRACT?PUMPSTD1?...
Last?record?lag:?3?seconds.
At?EOF,?no?more?records?to?process.
在EOF的前提下,關(guān)閉data?pump
GGSCI?(rh2.oracle.com)?148?stop?pumpstd1
Sending?STOP?request?to?EXTRACT?PUMPSTD1?...
Request?processed.
3.
檢查備庫端replicat的同步情況,如返回"At?EOF,?no?more?records?to?process.",則說明所有記錄均被復(fù)制。
GGSCI?(rh3.oracle.com)?71?lag?repstd1
Sending?GETLAG?request?to?REPLICAT?REPSTD1?...
Last?record?lag:?5?seconds.
At?EOF,?no?more?records?to?process.
在EOF的前提下關(guān)閉replicat
GGSCI?(rh3.oracle.com)?72?stop?repstd1
Sending?STOP?request?to?REPLICAT?REPSTD1?...
Request?processed.
4.
緊接著我們可以在備庫上為業(yè)務(wù)應(yīng)用用戶賦予必要的insert、update、delete權(quán)限,啟用各種觸發(fā)器trigger及cascade?delete約束等;
以上手段在主庫上對應(yīng)的操作是收回應(yīng)用業(yè)務(wù)的權(quán)限,disable掉各種觸發(fā)器及cascade?delete約束,
之所以這樣做是為了保證在任何時候扮演備庫角色的數(shù)據(jù)庫均不應(yīng)當(dāng)接受任何除了OGG外的手動的或者應(yīng)用驅(qū)動的業(yè)務(wù)數(shù)據(jù)變更,
以保證主備庫間的數(shù)據(jù)一致。
5.
修改原備庫上的extract的啟動時間到現(xiàn)在,已保證它不去抽取那些之前的重做日志
GGSCI?(rh3.oracle.com)?75?alter?extstd2?,begin?now
EXTRACT?altered.
GGSCI?(rh3.oracle.com)?76?start?extstd2
Sending?START?request?to?MANAGER?...
EXTRACT?EXTSTD2?starting
若之前沒有啟動由備庫到主庫的pump和replicat的話可以在此時啟動:
GGSCI?(rh3.oracle.com)?78?start?pumpstd2
Sending?START?request?to?MANAGER?...
EXTRACT?PUMPSTD2?starting
GGSCI?(rh2.oracle.com)?161?start?repstd2
Sending?START?request?to?MANAGER?...
REPLICAT?REPSTD2?starting
6.此時我們可以正式啟動在原備庫現(xiàn)在的主庫上的應(yīng)用了
接下來我們嘗試回切到原主庫上:
1.前提步驟與之前的切換相似,首先停止在原備庫上的任何應(yīng)用,
之后使用LAG命令確認extract和replicat的進度,在確認后關(guān)閉extract和replicat。
完成在主庫上的維護工作:包括賦予權(quán)限,啟用觸發(fā)器等等。
2.修改原主庫上的extract的開始時間為當(dāng)前,保證它不去處理之前的重做日志:
GGSCI?(rh2.oracle.com)?165?alter?extract?extstd1,begin?now
EXTRACT?altered.
3.此時我們已經(jīng)可以啟動在原主庫現(xiàn)在的主庫上的應(yīng)用了
4.啟動最早配置的由主庫到備庫的extract、pump、replicat:
GGSCI?(rh2.oracle.com)?166?start?extstd1
Sending?START?request?to?MANAGER?...
EXTRACT?EXTSTD1?starting
GGSCI?(rh2.oracle.com)?171?start?pumpstd1
Sending?START?request?to?MANAGER?...
EXTRACT?PUMPSTD1?starting
GGSCI?(rh3.oracle.com)?86?start?repstd1
Sending?START?request?to?MANAGER?...
REPLICAT?REPSTD1?starting
以上完成了OGG的Live?Standby中主備庫之間的計劃內(nèi)的切換Switchover,That's?Great!
oracleogg購買直接從官方下載就好。Oracle軟件本身是免費的,任何人都可以從Oracle官方網(wǎng)站下載并安裝Oracle的數(shù)據(jù)庫軟件,收費的是License,即軟件授權(quán),如果數(shù)據(jù)庫用于商業(yè)用途,就需要購買相應(yīng)Oracle產(chǎn)品的License。
下面還需要對ogg及oracle進行一系列配置(ogg支持多種復(fù)制方式,比如單項復(fù)制、雙...OGG的抓取進程所產(chǎn)生的數(shù)據(jù)隊列遠遠大于 Oracle數(shù)據(jù)庫所產(chǎn)生的歸檔日志,導(dǎo)致 OGG... 縮短保留隊列的時間可以調(diào)節(jié) OGG自動刪除隊列間的參數(shù),縮短保留隊列的時間。例如
Golden Gate(簡稱OGG)提供異構(gòu)環(huán)境下交易數(shù)據(jù)的實時捕捉、變換、投遞。
1、OGG原理
OGG是一種基于日志的結(jié)構(gòu)化數(shù)據(jù)復(fù)制軟件,通過捕獲源數(shù)據(jù)庫online redo log (在線重做日志)或archive log(歸檔日志)獲得數(shù)據(jù)變化,形成tail(隊列文件 ),再將這些tail通過網(wǎng)絡(luò)協(xié)議,傳輸?shù)侥繕?biāo)數(shù)據(jù)庫,目標(biāo)端通過解析,插入至目標(biāo)端數(shù)據(jù)庫,從而實現(xiàn)源端與目標(biāo)端數(shù)據(jù)同步。
2、OGG的特性:
1)、對生產(chǎn)系統(tǒng)影響小:實時讀取交易日志,以低資源占用實現(xiàn)大交易量數(shù)據(jù)實時復(fù)制;
2)、以交易為單位復(fù)制,保證交易一致性:只同步已提交的數(shù)據(jù);
3)、高性能,智能的交易重組和操作合并,使用數(shù)據(jù)庫本地接口訪問,并行處理體系,靈活的拓撲結(jié)構(gòu):支持一對一、一對多、多對一、多對多和雙向復(fù)制等。
3、工作機制
擴展資料
1)、每個GoldenGate實例可支持5000個Extract和Replicat進程;
2)、每個Extract和Replicat需要25-50M或更多的內(nèi)存,這取決于系統(tǒng)的事物量和事物大??;
3)、GoldenGate實際使用的物理內(nèi)存由操作系統(tǒng)控制和管理,GoladenGate 緩存管理器利用操作系統(tǒng)內(nèi)存管理功能的優(yōu)勢,確保GoladenGate進程持續(xù)和有效的工作;
參考資料
Oracle官網(wǎng)-Golden Gate
推測Oracle GoldenGate(OGG)OGG目的端 rep進程Checkpoint Lag的計算方法
背景介紹:如下是OGG目的端的rep進程的顯示,當(dāng)時,OGG源頭的傳輸進程由于網(wǎng)絡(luò)擁堵的原因,導(dǎo)致傳輸速度急劇下降,降低為1.5M/分鐘。此時,源頭已經(jīng)積壓了很多trail file。
也就是說,目的端的rep進程處于"吃不飽"的狀態(tài)--傳輸進程的傳輸速度趕不上rep進程的應(yīng)用速度。
GGSCI?(hostb)?5?info?repb
info?repb
REPLICAT???REPB??????Last?Started?2014-08-01?14:43???Status?RUNNING
Checkpoint?Lag???????00:00:00?(updated?00:00:12?ago)
Log?Read?Checkpoint??File?/u02/ggs/dirdat/tb001541
2014-08-01?05:26:32.766558??RBA?32744080
GGSCI?(hostb)?6?!
info?repb
REPLICAT???REPB??????Last?Started?2014-08-01?14:43???Status?RUNNING
Checkpoint?Lag???????09:21:35?(updated?00:00:00?ago)
Log?Read?Checkpoint??File?/u02/ggs/dirdat/tb001541
2014-08-01?05:26:34.768028??RBA?33105784
注意觀察Checkpoint Lag 的差異:
第一個是Checkpoint?Lag???????00:00:00??
第一個是Checkpoint?Lag???????09:21:35
當(dāng)前時間是2014-08-01 下午 15點左右,
結(jié)合trail文件傳輸速度降低的情況,我們可以推測Checkpoint Lag的計算方法:
當(dāng)有新的trail文件被傳輸?shù)侥康亩耍ù藭r該trail尚未被應(yīng)用)時,OGG讀取trail文件中的時間戳和 當(dāng)前的os時間做比對,從而得出Checkpoint Lag為09:21:35
當(dāng)所有的trail文件均被應(yīng)用時,Checkpoint Lag為00:00:00