您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“DB2_PureScale環境HADR如何搭建”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“DB2_PureScale環境HADR如何搭建”這篇文章吧。
#####HADR搭建######
1、創建主庫的備份
db2 BACKUP DB sampledb to /gpfs1nsd/backup
-- db2 backup db sampledb online to /gpfs1nsd/backup include logs
2、restore初始化備庫
db2 RESTORE DB sampledb from /gpfs1nsd/backup
-- db2 restore db sampledb from "/gpfs1nsd/backup" taken at 20170124085238 to "/gpfs1nsd/SAMPLEDB" logtarget "/gpfs1nsd/backup" with 2 buffers buffer 12800 replace history file parallelism 4
3、在主數據庫上,DBA 設置集群級別的 HADR 參數,這些參數指定備用集群和同步方式。
db2 "UPDATE DB CFG FOR sampledb USING\
HADR_TARGET_LIST {psnode1-standby:4000|psnode2-standby:4000}\
HADR_REMOTE_HOST {psnode1-standby:4000|psnode2-standby:4000}\
HADR_REMOTE_INST db2sdin1\
HADR_SYNCMODE async"
(參數需要重啟生效)
4、DBA 在主數據庫上設置成員級別 HADR 參數,這些參數標識每個成員的地址和端口
對于成員 0:
db2 "UPDATE DB CFG FOR sampledb MEMBER 0 USING HADR_LOCAL_HOST psnode1-primay HADR_LOCAL_SVC 4000"
對于成員 1:
db2 "UPDATE DB CFG FOR sampledb MEMBER 1 USING HADR_LOCAL_HOST psnode2-primay HADR_LOCAL_SVC 4000"
5、在備用數據庫上,DBA 設置集群級別的 HADR 參數,這些參數指定主集群和同步方式
db2 "UPDATE DB CFG FOR sampledb USING\
HADR_TARGET_LIST {psnode1-primay:4000|psnode2-primay:4000}\
HADR_REMOTE_HOST {psnode1-primay:4000|psnode2-primay:4000}\
HADR_REMOTE_INST db2inst1\
HADR_SYNCMODE async"
6、DBA 在備用數據庫上設置成員級別 HADR 參數,這些參數標識每個成員的地址和端口:
對于成員 0:
db2 "UPDATE DB CFG FOR sampledb MEMBER 0 USING HADR_LOCAL_HOST psnode1-standby HADR_LOCAL_SVC 4000"
對于成員 1:
db2 "UPDATE DB CFG FOR sampledb MEMBER 1 USING HADR_LOCAL_HOST psnode2-standby HADR_LOCAL_SVC 4000"
7、啟動備庫
db2 START HADR ON DB sampledb AS STANDBY
db2sdin1@psnode1:/gpfs1nsd/backup> db2 START HADR ON DB sampledb AS STANDBY
SQL1766W The command completed successfully. However, LOGINDEXBUILD was not
enabled before HADR was started.
8、啟動主庫
db2 START HADR ON DB sampledb AS PRIMARY
db2inst1@psnode2:/gpfs1nsd/backup> db2 START HADR ON DB sampledb AS PRIMARY
SQL1766W The command completed successfully. However, LOGINDEXBUILD was not
enabled before HADR was started.
9、檢查HADR
db2 "select LOG_STREAM_ID, PRIMARY_MEMBER, STANDBY_MEMBER, HADR_STATE from table (mon_get_hadr(-2))"
LOG_STREAM_ID PRIMARY_MEMBER STANDBY_MEMBER HADR_STATE
------------- -------------- -------------- -----------------------
1 1 0 PEER
0 0 0 PEER
2 record(s) selected.
db2pd -d sampledb -hadr
db2 get db cfg for sampledb | grep -i hadr
#####角色切換####
1、DBA 確保主項上成員均不處于異常狀態:
db2inst1@psnode1:~> db2 "SELECT ID,varchar(STATE,21) AS STATE,varchar(HOME_HOST,10) AS HOME_HOST, varchar(CURRENT_HOST,10) AS CUR_HOST, ALERT FROM SYSIBMADM.DB2_MEMBER"
ID STATE HOME_HOST CUR_HOST ALERT
------ --------------------- ---------- ---------- --------
0 STARTED psnode1 psnode1 NO
1 STARTED psnode2 psnode2 NO
2 record(s) selected.
2、DBA 確保所有日志流處于 PEER 狀態:
db2inst1@psnode1:~> db2 "select LOG_STREAM_ID, PRIMARY_MEMBER, STANDBY_MEMBER, HADR_STATE from table (mon_get_hadr(-2))"
LOG_STREAM_ID PRIMARY_MEMBER STANDBY_MEMBER HADR_STATE
------------- -------------- -------------- -----------------------
1 1 0 PEER
0 0 0 PEER
2 record(s) selected.
3、在standby,DBA 對成員 0 發出 TAKEOVER HADR 命令:
db2sdin1@psnode1:~> db2 TAKEOVER HADR ON DB sampledb
DB20000I The TAKEOVER HADR ON DATABASE command completed successfully.
4、在primary,DBA 在備用項上停用數據庫(這使數據庫保持處于 HADR 備用項的角色):
db2 DEACTIVATE DATABASE sampledb
db2stop
執行維護操作
db2start
db2 activate database sampledb
5、在primary,執行切換命令
db2 TAKEOVER HADR ON DB sampledb
以上是“DB2_PureScale環境HADR如何搭建”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。