通过SQL检查GBase 8s HDR运行状态

检查GBase 8s HDR集群运行状态最简便的方式是使用onstat -g dri命令

GBase Database Server Version 12.10.FC4G1AEE -- On-Line (Prim) -- Up 00:28:21 -- 627616 Kbytes

Data Replication at 0x47588028:
  Type           State        Paired server        Last DR CKPT (id/pg)    Supports Proxy Writes
  primary        on           gbase32                       4 / 14         NA

  DRINTERVAL   0
  DRTIMEOUT    30
  DRAUTO       0
  DRLOSTFOUND  /home/gbase30/etc/dr.lostfound
  DRIDXAUTO    0
  ENCRYPT_HDR  0
  Backlog      0
  Last Send    2019/05/06 09:09:42
  Last Receive 2019/05/06 09:09:42
  Last Ping    2019/05/06 09:09:36
  Last log page applied(log id,page): 4,15

如果不适应使用onstat命令方式,也可通过sysadmin api来实现,语句为:EXECUTE FUNCTION task("onstat","-g dri");

> EXECUTE FUNCTION task("onstat","-g dri");


(expression)
GBase Database Server Version 12.10.FC4G1AEE -- On-Line (Prim) -- Up 00:32:15 -- 627616 Kbytes

Data Replication at 0x47588028:

  Type           State        Paired server        Last DR CKPT (id/pg)    Supports Proxy Writes
  primary        on           gbase32                       4 / 22         NA
  DRINTERVAL   0
  DRTIMEOUT    30
  DRAUTO       0
  DRLOSTFOUND  /home/gbase30/etc/dr.lostfound
  DRIDXAUTO    0
  ENCRYPT_HDR  0
  Backlog      0
  Last Send    2019/05/06 09:13:36
  Last Receive 2019/05/06 09:13:36
  Last Ping    2019/05/06 09:13:07
  Last log page applied(log id,page): 4,23


1 row(s) retrieved.

如果需要只通过sql语句来实现,则需要查询sysmaster库,现有的系统表或者视图有简单的状态信息

> select * from sysdri;



type       Primary
state      On
name       gbase32
intvl      0
timeout    30
lostfound  /home/gbase30/etc/dr.lostfound
drauto     0
dridxauto  0

1 row(s) retrieved.

如果需要更多的信息,需要自定义查询语句,如:

-- SQL语句, 查询sysmaster库
select b.txt as type, c.txt as state , dbservername as localserver, a.name as pairserver, a.intvl as interval, a.timeout as timeout, DBINFO('utc_to_datetime',pingtime) as lastpingtime, current year to second as currenttime
from sysmaster:sysdrcb a, sysmaster:flags_text b, sysmaster:flags_text c
where a.type = b.flags
  and b.tabname = 'sysdrcb'
  and a.state = c.flags
  and c.tabname = 'sysdrcb';
  
-- 主机Primary显示, 首先判断正常的是 state, 状态应是 On, 然后currenttime - lastpingtime 的差值应小于 4 * timeout
type          Primary
state         On
localserver   gbase31                -- 本机服务名称(实例名)
pairserver    gbase32                -- 对端服务名称(实例名)
interval      0
timeout       30                     -- 超时时间,3次超时将会出现异常
lastpingtime  2019-05-06 09:00:36    -- 最后一次正确ping成功的时间
currenttime   2019-05-06 09:01:00    -- 当前时间

-- 备机Secondary显示, 首先判断正常的是 state, 状态应是 On, 然后currenttime - lastpingtime 的差值应小于 4 * timeout
type          Secondary
state         On
localserver   gbase32
pairserver    gbase31
interval      0
timeout       30
lastpingtime  2019-05-06 09:01:06
currenttime   2019-05-06 09:01:08

标签: gbase 8s, hdr, sql api, sysadmin task

添加新评论