飞道的博客

中标麒麟v10sp1系统部署达梦数据库(dm8)主备技术文档

278人阅读  评论(0)

DM8达梦数据库数据守护(Data Watch)实时主备环境搭建与切换测试

 

1、环境准备:

本示例中组名为“GRP1”,配置为实时主备,主库命名为“DM1”,备库命名为“DM2”

主机类型

IP地址

实例名

操作系统

主库

10.10.15.85(外)

10.10.20.85(内)

dmdb1

kylin

备库

10.10.15.84(外)

10.10.20.84(内)

Dmdb2

kylin

监视器

10.10.15.83(外)

10.10.20.83(内)

 

kylin

 

2、端口规划

实例名

PORT_NUM

MAL_INST_DW_PORT

MAL_HOST

MAL_PORT

MAL_DW_PORT

DM1

5235

5237

10.10.20.85

5238

5239

DM2

5235

5237

10.10.20.84

5238

5239

MAL系统是基于TCP协议实现的一种内部通信机制,DM通过MAL系统实现Redo日志传输,以及其他一些实例间的消息通讯。

守护进程(dmwatcher)是数据库实例和监视器之间信息流转的桥梁。数据库实例向本地守护进程发送信息,接收本地守护进程的消息和命令;

监视器(dmmonitor)接收守护进程的消息,并向守护进程发送命令;数据库实例与监视器之间没有直接的消息交互;

守护进程解析并执行监视器发起的各种命令(Switchover/Takeover/Open force等),并在必要时通知数据库实例执行相应的操作。

MAL_DW_PORT:守护进程监听端口,其他守护进程或监视器使用MAL_HOST + MAL_DW_PORT创建TCP连接。监视器配置文件dmmonitor.ini中,MON_DW_IP就是一组MAL_HOST: MAL_DW_PORT。

MAL_INST_DW_PORT:实例对守护进程的监听端口,守护进程使用MAL_HOST + MAL_INST_DW_PORT创建到实例的TCP连接。

 

3、安装数据库

安装系统包

root@tidb-03:/home# cat /etc/apt/sources.list

deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server-ft2000 main restricted universe multiverse

root@tidb-03:/home# apt install x11-xserver-utils

root@tidb-01:~# apt-get install java*

root@Kylin:~# java -version

openjdk version "1.8.0_191"

OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0kord0.16.04.1-b12)

OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

root@Kylin:~# groupadddinstall

root@Kylin:~# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

root@Kylin:~# passwddmdba

输入新的UNIX密码:

重新输入新的UNIX密码:

passwd:已成功更新密码

 

groupadddinstall

useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

passwddmdba

mkdir -p /app/dm8/

chown -R dmdba.dinstall /app/dm8/

chmod -R 775 /app/dm8/

 

cat>> /etc/security/limits.conf<< EOF

dmdbasoftnproc2047

dmdbahardnproc16384

dmdbasoftnofile1024

dmdbahardnofile65536

EOF

 

cat>> /etc/pam.d/login << EOF

session required /lib64/security/pam_limits.so

EOF

 

kernel.shmall = 2097152

kernel.shmmax = 4294967296

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

fs.file-max = 359670

net.ipv4.ip_local_port_range = 9000 65500

net.core.rmem_default = 1048576

net.core.rmem_max = 1048576

net.core.wmem_default = 262144

net.core.wmem_max = 262144

 

vi .profile

export DM_HOME=/app/dm8/

export PATH=$DM_HOME/dmdbms/bin::$PATH:$HOME/bin:

export DM_SID=dmdb

 

上传介质

mount -o loop dm8_setup_FT_arm64_ent_8.1.0.147_20190328.iso /mnt/

cchown -R dmdba:dinstall /home/dm*

chmod -R 775 /home/dm*

chown -R dmdba:dinstall /app/*

chmod -R 775 /app/*

root@Kylin:/dm8# su - dmdba

dmdba@Kylin:~$ cd /mnt/

 

root@tidb-05:~# su - dmdba

dmdba@tidb-05:~$ export DISPLAY=10.10.11.46:0

dmdba@tidb-05:~$ xhost +

access control disabled, clients can connect from any host

xhost:must be on local machine to enable or disable access control.

dmdba@tidb-05:~$ cd /mnt/

dmdba@tidb-05:/mnt$ ls

DMInstall.binDM_Install_en.pdfDM_Install_zh.pdfrelease_en.txtrelease_zh.txt

 

root@tidb-05:~# /app/dm8/script/root/root_installer.sh

移动/app/dm8/bin/dm_svc.conf到/etc目录

修改服务器权限

创建DmAPService服务

Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /lib/systemd/system/DmAPService.service.

创建服务(DmAPService)完成

启动DmAPService服务

 

到此数据库软件安装完成。

dmdba@tidb-05:/app/dm8/bin$ ./dmi

dmimondminit

dmdba@tidb-05:/app/dm8/bin$ ./dminit PATH=/app/dm8/data/ DB_NAME=dmdb INSTANCE_NAME=dmdb1 PORT_NUM=5235

initdb V8.1.0.147-Build(2019.03.27-104581)ENT

db version: 0x7000a

filedm.key not found, use default license!

License will expire in 14 day(s) on 2020-07-21

 

log file path: /app/dm8/data/dmdb/dmdb01.log

 

log file path: /app/dm8/data/dmdb/dmdb02.log

 

write to dir [/app/dm8/data/dmdb].

createdm database success. 2020-07-07 15:59:29

 

使用dmserver启动数据库,在DM数据库第一次必须正常启动,完成初始化的动作:

 

dmdba@tidb-05:/app/dm8/bin$ ./dmserver /app/dm8/data/dmdb/dm.ini

filedm.key not found, use default license!

version info: develop

Use normal os_malloc instead of HugeTLB

Use normal os_malloc instead of HugeTLB

DM Database Server x64 V8.1.0.147-Build(2019.03.27-104581)ENTstartup...

License will expire in 14 day(s) on 2020-07-21

ckptlsn: 0

ndctdb load finished

ndct fill fast pool finished

iid page's trxid[1]

NEXT TRX ID = 2

pseg_collect_items, collect 0 active_trxs, 0 cmt_trxs, 0 pre_cmt_trxs, 0 active_pages, 0 cmt_pages, 0pre_cmt_pages

pseg_process_collect_items end, 0 active trx, 0 active pages, 0 committed trx, 0 committed pages

total 0 active crash trx, pseg_crash_trx_rollback begin ...

pseg_crash_trx_rollback end

purg2_crash_cmt_trx end, total 0 page purged

set EP[0]'s pseg state to inactive

psegrecv finished

nsvr_startup end.

aud sys init success.

audrt sys init success.

trx: 2 purged 1 pages

trx: 21 purged 1 pages

trx: 22 purged 1 pages

trx: 23 purged 1 pages

trx: 24 purged 1 pages

trx: 35 purged 1 pages

trx: 155 purged 1 pages

trx: 174 purged 1 pages

trx: 175 purged 1 pages

trx: 176 purged 1 pages

trx: 177 purged 1 pages

trx: 178 purged 1 pages

trx: 179 purged 1 pages

trx: 181 purged 1 pages

trx: 183 purged 1 pages

trx: 186 purged 1 pages

trx: 192 purged 1 pages

trx: 202 purged 1 pages

trx: 1039 purged 1 pages

trx: 1040 purged 1 pages

trx: 1041 purged 1 pages

trx: 1042 purged 1 pages

trx: 1043 purged 1 pages

trx: 1044 purged 1 pages

trx: 1045 purged 1 pages

trx: 1046 purged 1 pages

trx: 1047 purged 1 pages

trx: 1048 purged 1 pages

trx: 1049 purged 1 pages

trx: 1050 purged 1 pages

trx: 1051 purged 1 pages

trx: 1052 purged 1 pages

trx: 1053 purged 1 pages

trx: 1088 purged 1 pages

trx: 1089 purged 1 pages

trx: 1090 purged 1 pages

trx: 1091 purged 1 pages

trx: 1096 purged 21 pages

trx: 1123 purged 1 pages

trx: 1124 purged 1 pages

trx: 1125 purged 1 pages

trx: 1126 purged 1 pages

trx: 1132 purged 1 pages

trx: 1134 purged 1 pages

trx: 1136 purged 1 pages

trx: 1141 purged 1 pages

trx: 1146 purged 1 pages

trx: 1151 purged 1 pages

trx: 1153 purged 1 pages

trx: 1156 purged 1 pages

trx: 1158 purged 1 pages

trx: 1168 purged 1 pages

trx: 1170 purged 1 pages

trx: 1172 purged 1 pages

trx: 1177 purged 1 pages

trx: 1178 purged 1 pages

trx: 1194 purged 7 pages

trx: 1203 purged 1 pages

systablesdescinit success.

ndct_db_load_info success.

nsvr_process_before_open begin.

nsvr_process_before_open success.

total 0 active crash trx, pseg_crash_trx_rollback begin ...

pseg_crash_trx_rollback end

SYSTEM IS READY.

 

1、   启动归档模式

dmdba@tidb-05:/app/dm8/bin$ ./disql SYSDBA/SYSDBA:5235

 

服务器[LOCALHOST:5235]:处于普通打开状态

登录使用时间: 8.119(毫秒)

disql V8.1.0.147-Build(2019.03.27-104581)ENT

SQL> alter database mount;

操作已执行

已用时间: 00:00:01.842.执行号:0.

SQL> alter database add archivelog 'DEST=/app/dm8/dmarch,TYPE=local,FILE_SIZE=128,space_limit=0';

操作已执行

已用时间: 1.112(毫秒).执行号:0.

SQL> alter database archivelog;

操作已执行

已用时间: 4.560(毫秒).执行号:0.

SQL> alter database open;

操作已执行

已用时间: 00:00:01.217.执行号:0.

SQL> select arch_mode from v$database;

 

行号ARCH_MODE

---------- ---------

1Y

 

已用时间: 1.259(毫秒).执行号:866.

 

SQL> shutdown immediate ;

操作已执行

 

2、注册服务并且启动实例

root@tidb-05:/app/dm8/script/root# ./dm_service_installer.sh -t dmserver -p dmdb -i /app/dm8/data/dmdb/dm.ini

Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedmdb.service to /lib/systemd/system/DmServicedmdb.service.

创建服务(DmServicedmdb)完成

 

root@tidb-05:/app/dm8/script/root# systemctl start DmServicedmdb.service

root@tidb-05:/app/dm8/script/root# ps -ef | grep dm.ini

dmdba1889110 09:43 ?00:00:00 /app/dm8/bin/dmserver /app/dm8/data/dmdb/dm.ini -noconsole

root18960 183480 09:43 pts/300:00:00 grep --color=auto dm.ini

停止服务

root@tidb-05:/app/dm8/script/root# systemctl stop DmServicedmdb

脱机备份

dmdba@tidb-05:/app/dm8/bin$ ./dmrman

dmrman V8.1.0.147-Build(2019.03.27-104581)ENT

RMAN> backup database '/app/dm8/data/dmdb/dm.ini' full backupset '/app/dmbak/dbbak01';

backup database '/app/dm8/data/dmdb/dm.ini' full backupset '/app/dmbak/dbbak01';

EP[0] max_lsn: 50846

BACKUP DATABASE [dmdb],execute......

CMD CHECK LSN......

BACKUP DATABASE [dmdb],collect dbf......

CMD CHECK ......

DBF BACKUP SUBS......

total 1 packages processed...

total 3 packages processed...

total 4 packages processed...

DBF BACKUP MAIN......

BACKUPSET [/app/dmbak/dbbak01] END, CODE [0]......

META GENERATING......

total 8 packages processed...

total 8 packages processed...

total 8 packages processed!

CMD END.CODE:[0]

backup successfully!

time used: 964.395(ms)

RMAN>

 

3、创建备库利用主库备份恢复

 

dmdba@tidb-04:/app/dm8/bin$ ./dminit PATH=/app/dm8/data DB_NAME=dmdb INSTANCE_NAME=dmdb2 PORT_NUM=5235

initdb V8.1.0.147-Build(2019.03.27-104581)ENT

db version: 0x7000a

file dm.key not found, use default license!

License will expire in 14 day(s) on 2020-07-22

 

log file path: /app/dm8/data/dmdb/dmdb01.log

 

log file path: /app/dm8/data/dmdb/dmdb02.log

 

write to dir [/app/dm8/data/dmdb].

create dm database success. 2020-07-08 10:37:59

dmdba@tidb-04:/app/dm8/bin$

 

将主库的备份复制备库

dmdba@tidb-05:/app/dmbak$ scp -r dbbak01 10.10.15.84:/app/dmbak/

dmdba@10.10.15.84's password:

Permission denied, please try again.

dmdba@10.10.15.84's password:

dbbak01.meta100%69KB40.7MB/s00:00

dbbak01.bak100% 5510KB 103.6MB/s00:00

dmdba@tidb-05:/app/dmbak$

 

恢复备库

dmdba@tidb-04:/app/dm8/bin$ pwd

/app/dm8/bin

dmdba@tidb-04:/app/dm8/bin$ ./dmrman CTLSTMT="RESTORE DATABASE'/app/dm8/data/dmdb/dm.ini' FROM BACKUPSET '/app/dmbak/dbbak01'"

dmrman V8.1.0.147-Build(2019.03.27-104581)ENT

RESTORE DATABASE '/app/dm8/data/dmdb/dm.ini' FROM BACKUPSET '/app/dmbak/dbbak01'

file dm.key not found, use default license!

RESTORE DATABASE CHECK......

total 0 packages processed...

RESTORE DATABASE,dbf collect......

RESTORE DATABASE,dbf refresh ......

RESTORE BACKUPSET [/app/dmbak/dbbak01] START......

total 4 packages processed...

total 8 packages processed...

RESTORE DATABASE,UPDATE ctl file......

RESTORE DATABASE,REBUILD key file......

RESTORE DATABASE,CHECK db info......

RESTORE DATABASE,UPDATE db info......

total 8 packages processed...

total 8 packages processed!

CMD END.CODE:[0]

restore successfully.

time used: 4165.046(ms)

dmdba@tidb-04:/app/dm8/bin$ ./dmrman CTLSTMT="RECOVER DATABASE'/app/dm8/data/dmdb/dm.ini' FROM BACKUPSET '/app/dmbak/dbbak01'"

dmrman V8.1.0.147-Build(2019.03.27-104581)ENT

RECOVER DATABASE '/app/dm8/data/dmdb/dm.ini' FROM BACKUPSET '/app/dmbak/dbbak01'

file dm.key not found, use default license!

EP[0] max_lsn: 50846

RESTORE RLOGCHECK......

total 0 packages processed...

CMD END.CODE:[603],DESC:[备份集[/app/dmbak/dbbak01]备份过程中未产生日志]

备份集[/app/dmbak/dbbak01]备份过程中未产生日志

recover successfully!

time used: 168.066(ms)

dmdba@tidb-04:/app/dm8/bin$

 

dmdba@tidb-04:/app/dm8/bin$ ./dmrman CTLSTMT="RECOVER DATABASE '/app/dm8/data/dmdb/dm.ini' UPDATE DB_MAGIC"

dmrman V8.1.0.147-Build(2019.03.27-104581)ENT

RECOVER DATABASE '/app/dm8/data/dmdb/dm.ini' UPDATE DB_MAGIC

file dm.key not found, use default license!

EP[0] max_lsn: 50846

EP[0]'s begin_lsn[50846] >= end_lsn[50846]

recover successfully!

time used: 927.140(ms)

dmdba@tidb-04:/app/dm8/bin$

 

4、配置主备库参数

4.1配置dm.ini

主库

修改主备库参数,注意2个库的instance_name参数不同。

INSTANCE_NAME = DMDB1

PORT_NUM = 5235#数据库实例监听端口

ALTER_MODE_STATUS = 0#不允许手工方式修改实例模式/状态

ENABLE_OFFLINE_TS = 2#不允许备库OFFLINE表空间

MAL_INI = 1#打开MAL系统

ARCH_INI = 1#打开归档配置

备库

INSTANCE_NAME = DMDB2

PORT_NUM = 5235#数据库实例监听端口

ALTER_MODE_STATUS = 0#不允许手工方式修改实例模式/状态

ENABLE_OFFLINE_TS = 2#不允许备库OFFLINE表空间

MAL_INI = 1#打开MAL系统

ARCH_INI = 1#打开归档配置

4.2配置dmmal.ini

主库

dmdba@tidb-05:/app/dm8/data/dmdb$ cat dmmal.ini

MAL_CHECK_INTERVAL = 5#MAL链路检测时间间隔

MAL_CONN_FAIL_INTERVAL = 5#判定MAL链路断开的时间

 

[MAL_INST1]

MAL_INST_NAME = DMDB1#实例名,和dm.ini中的INSTANCE_NAME一致

MAL_HOST = 10.10.15.85#MAL系统监听TCP连接的IP地址

MAL_PORT = 5238#MAL系统监听TCP连接的端口

MAL_INST_HOST = 10.10.15.85#实例的对外服务IP地址

MAL_INST_PORT = 5235#实例的对外服务端口,和dm.ini中的PORT_NUM一致

MAL_INST_DW_PORT = 5237#实例监听守护进程TCP连接的端口

MAL_DW_PORT = 5239#实例对应的守护进程监听TCP连接的端口

 

[MAL_INST2]

MAL_INST_NAME = DMDB2

MAL_HOST = 10.10.15.84

MAL_PORT = 5238

MAL_INST_HOST = 10.10.15.84

MAL_INST_PORT = 5235

MAL_INST_DW_PORT = 5237

MAL_DW_PORT = 5239

备库

dmdba@tidb-04:/app/dm8/data/dmdb$ cat dmmal.ini

MAL_CHECK_INTERVAL = 5#MAL链路检测时间间隔

MAL_CONN_FAIL_INTERVAL = 5#判定MAL链路断开的时间

 

[MAL_INST1]

MAL_INST_NAME = DMDB1#实例名,和dm.ini中的INSTANCE_NAME一致

MAL_HOST = 10.10.15.85#MAL系统监听TCP连接的IP地址

MAL_PORT = 5238#MAL系统监听TCP连接的端口

MAL_INST_HOST = 10.10.15.85#实例的对外服务IP地址

MAL_INST_PORT = 5235#实例的对外服务端口,和dm.ini中的PORT_NUM一致

MAL_INST_DW_PORT = 5237#实例监听守护进程TCP连接的端口

MAL_DW_PORT = 5239#实例对应的守护进程监听TCP连接的端口

 

[MAL_INST2]

MAL_INST_NAME = DMDB2

MAL_HOST = 10.10.15.84

MAL_PORT = 5238

MAL_INST_HOST = 10.10.15.84

MAL_INST_PORT = 5235

MAL_INST_DW_PORT = 5237

MAL_DW_PORT = 5239

4.3配置dmarch.ini

主库

dmdba@tidb-05:/app/dm8/data/dmdb$ cat dmwatcher.ini

[GRP1]

DW_TYPE = GLOBAL#全局守护类型

DW_MODE = MANUAL#自动切换模式

DW_ERROR_TIME = 10#远程守护进程故障认定时间

INST_RECOVER_TIME = 60#主库守护进程启动恢复的间隔时间

INST_ERROR_TIME = 10#本地实例故障认定时间

INST_OGUID = 453331#守护系统唯一OGUID值

INST_INI = /app/dm8/data/dmdb/dm.ini#dm.ini配置文件路径

INST_AUTO_RESTART = 1#打开实例的自动启动功能

INST_STARTUP_CMD = /app/dm8/bin/dmserver#命令行方式启动

RLOG_SEND_THRESHOLD = 0#指定主库发送日志到备库的时间阀值,默认关闭

RLOG_APPLY_THRESHOLD = 0#指定备库重演日志的时间阀值,默认关闭

备库

dmdba@tidb-04:/app/dm8/data/dmdb$ cat dmwatcher.ini

[GRP1]

DW_TYPE = GLOBAL#全局守护类型

DW_MODE = MANUAL#自动切换模式

DW_ERROR_TIME = 10#远程守护进程故障认定时间

INST_RECOVER_TIME = 60#主库守护进程启动恢复的间隔时间

INST_ERROR_TIME = 10#本地实例故障认定时间

INST_OGUID = 453331#守护系统唯一OGUID值

INST_INI = /app/dm8/data/dmdb/dm.ini#dm.ini配置文件路径

INST_AUTO_RESTART = 1#打开实例的自动启动功能

INST_STARTUP_CMD = /app/dm8/bin/dmserver#命令行方式启动

RLOG_SEND_THRESHOLD = 0#指定主库发送日志到备库的时间阀值,默认关闭

RLOG_APPLY_THRESHOLD = 0#指定备库重演日志的时间阀值,默认关闭
 

主备库生成dmwatcher.ctl控制文件

./dmctlcvt TYPE=3 SRC=/app/dm8/data/dmdb/dmwatcher.ini DEST=/app/dm8/data/dmdb

4.4以mount模式启动主备库

主库

dmdba@tidb-05:/app/dm8/bin$ dmserver /app/dm8/data/dmdb/dm.ini mount

version info: enterprise

Use normal os_malloc instead of HugeTLB

Use normal os_malloc instead of HugeTLB

DM Database Server x64 V8.1.0.147-Build(2019.03.27-104581)ENTstartup...

License will expire on 2021-06-01

ckptlsn: 50846

ndctdb load finished

ndct fill fast pool finished

nsvr_startup end.

aud sys init success.

audrt sys init success.

systablesdescinit success.

ndct_db_load_info success.

SYSTEM IS READY.

备库

dmdba@tidb-04:/app/dm8/bin$ ./dmserver /app/dm8/data/dmdb/dm.ini mount

version info: enterprise

Use normal os_malloc instead of HugeTLB

Use normal os_malloc instead of HugeTLB

DM Database Server x64 V8.1.0.147-Build(2019.03.27-104581)ENTstartup...

License will expire on 2021-06-01

main rfil[/app/dm8/data/dmdb/dmdb01.log]'s grp collect 0 valid pwr record, discard 0 invalid pwr record

EP[0] max_lsn: 50846

ndctdb load finished

ndct fill fast pool finished

nsvr_startup end.

aud sys init success.

audrt sys init success.

systablesdescinit success.

ndct_db_load_info success.

SYSTEM IS READY.

一定要以mount方式启动数据库实例,否则系统启动时会重构回滚表空间,生成Redo日志;并且,启动后应用可能连接到数据库实例进行操作,破坏主备库的数据一致性。数据守护配置结束后,守护进程会自动Open数据库。

4.5设置OGUID

在主备库分别执行:

主库

dmdba@tidb-05:/app/dm8/data/dmdb$ disqlsysdba/SYSDBA:5235

 

服务器[LOCALHOST:5235]:处于普通配置状态

登录使用时间: 7.934(毫秒)

disql V8.1.0.147-Build(2019.03.27-104581)ENT

SQL>sp_set_oguid(453331);

DMSQL过程已成功完成

已用时间: 2.971(毫秒).执行号:1.

备库

dmdba@tidb-04:/app/dm8/bin$ disqlsysdba/SYSDBA:5235

 

服务器[LOCALHOST:5235]:处于普通配置状态

登录使用时间: 7.919(毫秒)

disql V8.1.0.147-Build(2019.03.27-104581)ENT

SQL>sp_set_oguid(453331);

DMSQL过程已成功完成

已用时间: 9.767(毫秒).执行号:1.

4.6修改数据库模式

主库修改数据库为primary

SQL> alter database primary;

操作已执行

已用时间: 2.599(毫秒).执行号:0.

备库修改数据库为standby

如果当前数据库不是normal模式,需要先修改dm.ini中ALTER_MODE_STATUS值 为1,允许修改数据库模式,修改Standby模式成功后再改回为0。

dmdba@tidb-04:/app/dm8/data/dmdb$ disqlsysdba/SYSDBA:5235

 

服务器[LOCALHOST:5235]:处于普通配置状态

登录使用时间: 7.915(毫秒)

disql V8.1.0.147-Build(2019.03.27-104581)ENT

SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);

DMSQL过程已成功完成

已用时间: 4.406(毫秒).执行号:2.

SQL> alter database standby;

操作已执行

已用时间: 8.667(毫秒).执行号:0.

SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);

DMSQL过程已成功完成

已用时间: 3.844(毫秒).执行号:3.

 

5、注册并启动守护进程

备库注册服务:

root@tidb-04:/app/dm8/script/root# ./dm_service_installer.sh -t dmserver -p dmdb -i /app/dm8/data/dmdb/dm.ini

Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedmdb.service to /lib/systemd/system/DmServicedmdb.service.

创建服务(DmServicedmdb)完成

在主备库进行注册:

主库

root@tidb-05:/app/dm8/script/root# ./dm_service_installer.sh -t dmwatcher -p dmdb -i /app/dm8/data/dmdb/dmwatcher.ini

Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicedmdb.service to /lib/systemd/system/DmWatcherServicedmdb.service.

创建服务(DmWatcherServicedmdb)完成

备库

root@tidb-04:/app/dm8/script/root# ./dm_service_installer.sh -t dmwatcher -p dmdb -i /app/dm8/data/dmdb/dmwatcher.ini

Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicedmdb.service to /lib/systemd/system/DmWatcherServicedmdb.service.

创建服务(DmWatcherServicedmdb)完成

 

主库启动服务

root@tidb-05:/home/dmdba# systemctl start DmWatcherServicedmdb.service

 

[Note] System unauthorized, Please contact the system supplier.

 

[Unauthorized System] root@tidb-05:/home/dmdba# systemctl status DmWatcherServicedmdb.service

●DmWatcherServicedmdb.service - Dameng Watcher Service(DmWatcherServicedmdb).

Loaded: loaded (/lib/systemd/system/DmWatcherServicedmdb.service; enabled; vendor preset: enabled)

Active: active (exited) since一2020-07-13 11:09:03 CST; 48s ago

Process: 6184 ExecStop=/app/dm8/bin/DmWatcherServicedmdb stop (code=exited, status=0/SUCCESS)

Process: 6424 ExecStart=/app/dm8/bin/DmWatcherServicedmdb start (code=exited, status=0/SUCCESS)

Main PID: 6424 (code=exited, status=0/SUCCESS)

 

7月13 11:08:48 tidb-05 systemd[1]: Starting Dameng Watcher Service(DmWatcherServicedmdb)....

7月13 11:08:48 tidb-05 su[6442]: Successful su for dmdba by root

7月13 11:08:48 tidb-05 su[6442]: + ??? root:dmdba

7月13 11:08:48 tidb-05 su[6442]: pam_unix(su:session): session opened for user dmdba by (uid=0)

7月13 11:09:03 tidb-05 DmWatcherServicedmdb[6424]: [42B blob data]

7月13 11:09:03 tidb-05 systemd[1]: Started Dameng Watcher Service(DmWatcherServicedmdb)..

备库启动服务

root@tidb-04:~# systemctl startDmWatcherServicedmdb

守护进程启动后,进入Startup状态,此时实例都处于Mount状态。守护进程开始广播自身和其监控实例的状态信息,结合自身信息和远程守护进程的广播信息,守护进程将本地实例Open,并切换为Open状态.

 

[Unauthorized System] root@tidb-04:~# systemctl start DmWatcherServicedmdb.service

 

[Note] System unauthorized, Please contact the system supplier.

 

[Unauthorized System] root@tidb-04:~# systemctl status DmWatcherServicedmdb.service

●DmWatcherServicedmdb.service - Dameng Watcher Service(DmWatcherServicedmdb).

Loaded: loaded (/lib/systemd/system/DmWatcherServicedmdb.service; enabled; vendor preset: enabled)

Active: active (exited) since一2020-07-13 11:07:11 CST; 14s ago

Process: 7164 ExecStop=/app/dm8/bin/DmWatcherServicedmdb stop (code=killed, signal=TERM)

Process: 7512 ExecStart=/app/dm8/bin/DmWatcherServicedmdb start (code=exited, status=0/SUCCESS)

Main PID: 7512 (code=exited, status=0/SUCCESS)

 

7月13 11:06:55 tidb-04 systemd[1]: Starting Dameng Watcher Service(DmWatcherServicedmdb)....

7月13 11:06:56 tidb-04 su[7531]: Successful su for dmdba by root

7月13 11:06:56 tidb-04 su[7531]: + ??? root:dmdba

7月13 11:06:56 tidb-04 su[7531]: pam_unix(su:session): session opened for user dmdba by (uid=0)

7月13 11:07:11 tidb-04 DmWatcherServicedmdb[7512]: [42B blob data]

7月13 11:07:11 tidb-04 systemd[1]: Started Dameng Watcher Service(DmWatcherServicedmdb)..

 

6、配置监视器(第三台服务器)

6.1参数文件

在监控节点的/app/dm8/data/dmdb/目录下创建并修改dmmonitor.ini配置确认监视器,其中MON_DW_IP中的IP和PORT和dmmal.ini中的MAL_HOST和MAL_DW_PORT配置项保持一致

dmdba@tidb-03:/app/dm8/data/dmdb$ cat dmmonitor.ini

MON_DW_CONFIRM = 1 #确认监视器模式

MON_LOG_PATH = /app/dm8/log #监视器日志文件存放路径

MON_LOG_INTERVAL = 60 #每隔60s定时记录系统信息到日志文件

MON_LOG_FILE_SIZE = 32 #每个日志文件最大32M

MON_LOG_SPACE_LIMIT = 0 #不限定日志文件总占用空间

 

[GRP1]

MON_INST_OGUID = 453331#组GRP1的唯一OGUID值

MON_DW_IP = 10.10.15.85:5239

MON_DW_IP = 10.10.15.84:5239

 

cd /app/dm8/bin

./dmmonitor /app/dm8/data/dmdb/dmmonitor.ini

 

[Unauthorized System] dmdba@tidb-03:/app/dm8/bin$ ./dmmonitor /app/dm8/data/dmdb/dmmonitor.ini

[monitor]2020-07-13 11:13:36: DMMONITOR[3.0] V8.1.0.147-Build(2019.03.27-104581)ENT

[monitor]2020-07-13 11:13:36: DMMONITOR[3.0] IS READY.

 

[monitor]2020-07-13 11:13:36: Received message from(DMDB1)

WTIMEWSTATUSINST_OKINAMEISTATUSIMODERSTATN_OPENFLSNCLSN

2020-07-13 11:13:36OPENOKDMDB1OPENPRIMARYVALID66563165631

 

[monitor]2020-07-13 11:13:36: Received message from(DMDB2)

WTIMEWSTATUSINST_OKINAMEISTATUSIMODERSTATN_OPENFLSNCLSN

2020-07-13 11:13:36OPENOKDMDB2OPENSTANDBYVALID66563165631

 

 

Input command illegal, please input help to get the help information!

 

show

2020-07-13 11:14:28

#================================================================================#

GROUPOGUIDMON_CONFIRMMODEMPP_FLAG

GRP1453331TRUEMANUALFALSE

 

 

<<DATABASE GLOBAL INFO:>>

IPMAL_DW_PORTWTIMEWTYPEWCTLSTATWSTATUSINAMEINST_OKN_EPISTATUSIMODERTYPERSTAT

10.10.15.8552392020-07-13 11:14:27GLOBALVALIDOPENDMDB1OK1OPENPRIMARYREALTIMEVALID

 

EP INFO:

INST_PORTINST_OKINAMEISTATUSIMODEDSC_STATUSDSC_SEQNODSC_CONTROL_NODE N_OKRTYPERSTATN_OPENFLSNCLSNDW_STAT_FLAGN_TASKTASK_MEM_USED

5235OKDMDB1OPENPRIMARYDSC_OPEN001REALTIMEVALID66563165631NONE00

 

<<DATABASE GLOBAL INFO:>>

IPMAL_DW_PORTWTIMEWTYPEWCTLSTATWSTATUSINAMEINST_OKN_EPISTATUSIMODERTYPERSTAT

10.10.15.8452392020-07-13 11:14:27GLOBALVALIDOPENDMDB2OK1OPENSTANDBYREALTIMEVALID

 

EP INFO:

INST_PORTINST_OKINAMEISTATUSIMODEDSC_STATUSDSC_SEQNODSC_CONTROL_NODE N_OKRTYPERSTATN_OPENFLSNCLSNDW_STAT_FLAGN_TASKTASK_MEM_USED

5235OKDMDB2OPENSTANDBYDSC_OPEN001REALTIMEVALID66563165631NONE00

 

EP(DMDB2) APPLY INFO FROM (DMDB1):

SEQNO = 0, IS_OK = 1, SSLSN = 65631, SLSN = 65631, APPLY_LSN = 65631, N_TSK = 0, TSK_MEM_USE = 0

6.2主备同步测试

主库

dmdba@tidb-05:~$ disqlsysdba/SYSDBA:5235

 

服务器[LOCALHOST:5235]:处于主库打开状态

登录使用时间: 8.164(毫秒)

disql V8.1.0.147-Build(2019.03.27-104581)ENT

SQL> create table dave as select * from sysobjects;

操作已执行

已用时间: 13.646(毫秒).执行号:6.

备库查询

dmdba@tidb-04:~$ disqlsysdba/SYSDBA:5235

 

服务器[LOCALHOST:5235]:处于备库打开状态

登录使用时间: 8.106(毫秒)

disql V8.1.0.147-Build(2019.03.27-104581)ENT

SQL> select count(1) from dave;

 

行号COUNT(1)

---------- --------------------

11303

 

已用时间: 1.316(毫秒).执行号:3.

6.3主备切换测试

操作直接在监控器里执行

6.4 Takeover接管

#此时可以接管了:

root@tidb-04:/home/dmdba# reboot

choose switchover grp1

 

Can choose one of the following instances to do switchover:

1: DMDB2

 

switchover grp1.dmdb2

[monitor]2020-07-13 11:38:09: Not login dmmonitor or server public key changed, please try to login again!

 

login

username:sysdba

password:

[monitor]2020-07-13 11:39:03: Login dmmonitor success!

6.5恢复原主库的网络后,监视器自动将原主库切换成了备库

1、   以脚本方式后台停止数据库(顺序:备主主备)

配置脚本:

cd/app/dm8/bin/service_template

 

vi DmService

Vi DmWatcherService

1.     停止备库DmWatcher

dmdba@tidb-04:/app/dm8/bin/service_template$ ./DmWatcherService stop

Stopping DmWatcherService:[ OK ]

2.     停止主库DmWatcher

dmdba@tidb-05:/app/dm8/bin/service_template$ ./DmWatcherService stop

Stopping DmWatcherService:[ OK ]

3.停止主库DmService

dmdba@tidb-05:/app/dm8/bin/service_template$ ./DmService stop

DmService service is not running.

4.停止备库DmService

dmdba@tidb-04:/app/dm8/bin/service_template$ ./DmService stop

Stopping DmService:[ OK]

以脚本方式后台启动数据库(顺序:主备主备)

 

1.     启动主库DmService

dmdba@tidb-05:/app/dm8/bin/service_template$ ./DmService start

Starting DmService:[ OK ]

2.     启动备库DmService

dmdba@tidb-04:/app/dm8/bin/service_template$ ./DmService start

Starting DmService:[ OK ]

3.     启动主库DmWatcher

dmdba@tidb-05:/app/dm8/bin/service_template$./DmWatcherService start

Starting DmWatcherService:[ OK ]

4.启动备库DmWatcher

dmdba@tidb-04:/app/dm8/bin/service_template$ ./DmWatcherService start

Starting DmWatcherService:[ OK ]

 

作者:苏献君


转载:https://blog.csdn.net/m0_46573967/article/details/112212162
查看评论
* 以上用户言论只代表其个人观点,不代表本网站的观点或立场