db2 HADR v10.5快速部署手册

一、目录准备
mkdir - p/home/db2inst1/db2_backup
mkdir - p/home/db2inst1/db2_archive
mkdir - p/home/db2inst1/db2_log
chmod - r 775/home/db2inst1/db2_backup
chmod - r 775/home/db2inst1/db2_archive
chmod - r 775/home/db2inst1/db2_log
乔恩- r db2inst1: db2inst1/home/db2inst1/db2_backup
乔恩- r db2inst1: db2inst1/home/db2inst1/db2_archive
乔恩- r db2inst1: db2inst1/home/db2inst1/db2_log

二、服务和端口配置(注意HADR服务端口和实例端口要区分开)
DB2_HADR_1 55110/tcp
DB2_HADR_2 55111/tcp


三,开启归档模式(主库和备库都操作)
先修改归档参数,做离线备份,重启数据库后,手工测试归档

主库
示例使用logarchmeth2磁盘db2 update db cfg:/home/db2inst1/db2_archive/

db2 update db cfg示例使用路径/home/db2inst1/db2_log

db2迫使应用程序所有

db2备份数据库样本/home/db2inst1/db2_backup/

db2stop; db2start

db2归档日志数据库示例

SQL1116N连接或激活数据库“sample”失败了,因为
数据库处于backup PENDING状态。SQLSTATE=57019

备库:

db2 update db cfg示例使用logarchmeth2磁盘:/home/db2inst1/db2_archive/

db2 update db cfg示例使用路径/home/db2inst1/db2_log

db2迫使应用程序所有

db2备份数据库样本/home/db2inst1/db2_backup/

db2stop; db2start

db2归档日志数据库示例


四、备份和还原从库
主库离线全备份
1。db2备份数据库sample/home/db2inst1/db2_backup
3。scp/home/db2inst1/db2_backup/SAMPLE.0.db2inst1.DBPART000.20171220165404.001 db2inst1@192.168.12.108:/home/db2inst1/db2_backup/


备库还原数据
db2恢复数据库样本“/home/db2inst1/db2_backup”在20171220165404取代历史文件

2。SQL2523W警告!恢复到一个现有的数据库不同于

3。数据库备份映像,但是有匹配的名称。目标数据库

4。将覆盖备份版本。前滚恢复日志

5。与目标相关联的数据库将被删除。

6。你想要继续吗?(y/n) y

7。DB20000I恢复数据库命令成功完成。


五、主库参数配置

db2 get db cfg for sample | grep -i HADR
[db2inst1@107-sqlcheck db2_backup]$ db2 get db cfg for sample | grep -i HADR
HADR database role=STANDARD
HADR local host name (HADR_LOCAL_HOST)=
HADR local service name (HADR_LOCAL_SVC)=
HADR remote host name (HADR_REMOTE_HOST)=
HADR remote service name (HADR_REMOTE_SVC)=
HADR instance name of remote server (HADR_REMOTE_INST)=
HADR timeout value (HADR_TIMEOUT)=120
HADR target list (HADR_TARGET_LIST)=
HADR log write synchronization mode (HADR_SYNCMODE)=NEARSYNC
HADR spool log data limit (4KB) (HADR_SPOOL_LIMIT)=AUTOMATIC(0)
HADR log replay delay (seconds) (HADR_REPLAY_DELAY)=0
HADR peer window duration (seconds) (HADR_PEER_WINDOW)=0


db2 update db cfg for sample using HADR_LOCAL_HOST 192.168.12.108

db2 update db cfg for sample using HADR_LOCAL_SVC DB2_HADR_2

db2 update db cfg for sample using HADR_REMOTE_HOST 192.168.12.107

db2 update db cfg for sample using HADR_REMOTE_SVC DB2_HADR_1

db2 update db cfg for sample using HADR_REMOTE_INST db2inst1

db2 update db cfg for sample using HADR_SYNCMODE NEARSYNC

db2 update db cfg for sample using HADR_TIMEOUT 120


备库参数配置

db2 get db cfg for sample | grep -i HADR

db2 update db cfg for sample using HADR_LOCAL_HOST 192.168.12.108

db2 update db cfg for sample using HADR_LOCAL_SVC DB2_HADR_2

db2 update db cfg for sample using HADR_REMOTE_HOST 192.168.12.107

db2 update db cfg for sample using HADR_REMOTE_SVC DB2_HADR_1

db2 update db cfg for sample using HADR_REMOTE_INST db2inst1

db2 update db cfg for sample using HADR_SYNCMODE NEARSYNC

db2 update db cfg for sample using HADR_TIMEOUT 120

db2 get db cfg for sample | grep -i HADR

启动HADR


先启动备库
standby端的数据库通过primary端的数据库恢复来,恢复后必须是roll forward-pending状态,
restore中不能使用without rolling forward,启动备库之前先确定这个状态
备库状态确认
db2 get db cfg for sample | grep Rollforward
Rollforward pending=DATABASE

相比于主库:
db2 get db cfg for sample | grep Rollforward
Rollforward pending=NO


启动备库
db2 start hadr on database sample as standby
[db2inst2@kvm111 ~]$ db2 start hadr on database sample as standby
SQL1766W The command completed successfully. 然而,LOGINDEXBUILD不是
启用HADR之前就开始了。null

db2 HADR v10.5快速部署手册