DB2_PureScale环境HADR如何搭建

网友投稿 232 2023-12-25

DB2_PureScale环境HADR如何搭建

这篇文章主要为大家展示了“DB2_PureScale环境HADR如何搭建”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“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如何搭建”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:前端开发移动端有些什么框架(前端移动端项目)
下一篇:vue安卓版(vue做安卓app)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~