用户可以通过 SDB Shell 或者其他驱动监控复制组,查看复制组节点运行状态。
SequoiaDB 巨杉数据库提供多个快照,以查看当前数据库系统的各种状态。其中节点健康检测快照 SDB_SNAP_HEALTH 可以查看到各个节点的健康状态。用户可以从节点运行状态、复制组同步状态、系统资源使用情况、节点启动历史等不同的方面,来评估复制组节点的健康状况。
连接协调节点,查看复制组 group1 的节点健康状态
> var db = new Sdb( 'sdbserver1', 11810 ) > db.snapshot( SDB_SNAP_HEALTH, { GroupName: "group1" } )
输出结果如下:
{ "NodeName": "sdbserver1:11820", "IsPrimary": true, "ServiceStatus": true, "Status": "Normal", "BeginLSN": { "Offset": 0, "Version": 1 }, "CurrentLSN": { "Offset": 9610788, "Version": 1 }, "CommittedLSN": { "Offset": 76, "Version": 1 }, "CompleteLSN": 9610868, "LSNQueSize": 0, "NodeID": [ 1000, 1000 ], "DataStatus": "Normal", "SyncControl": false, "Ulimit": { "CoreFileSize": -1, "VirtualMemory": -1, "OpenFiles": 1024, "NumProc": 23948, "FileSize": -1 }, "ResetTimestamp": "2018-03-09-09.47.04.826497", "ErrNum": { "SDB_OOM": 1, "SDB_NOSPC": 0, "SDB_TOO_MANY_OPEN_FD": 1 }, "Memory": { "LoadPercent": 3, "TotalRAM": 3157524480, "RssSize": 96591872, "LoadPercentVM": 0, "VMLimit": -1, "VMSize": 2380341248 }, "Disk": { "Name": "/dev/mapper/vgdata-lvdata1", "LoadPercent": 69, "TotalSpace": 52836298752, "FreeSpace": 16025624576 }, "FileDesp": { "LoadPercent": 3, "TotalNum": 1024, "FreeNum": 985 }, "StartHistory": [ "2018-01-24-15.55.58.374162", "2018-01-24-15.55.00.318481" ], "CrashHistory": [ "2018-01-24-15.55.58.374162" ], "DiffLSNWithPrimary": 0 }
Note:
Rebuild 状态:当节点启动时发现数据损坏,则进行数据重组以恢复数据
Note:
每条 LSN 由 Offset 和 Version 两个字段组成:
- Offset 是指该条事务日志在日志文件中的偏移;
- 复制组每次切换主节点,Version 都会递增 1。
用户可以通过 resetSnapshot() 重置节点健康检测快照中的某些字段。
重置复制组 group1 的节点健康检测快照
> db.resetSnapshot( { Type: "health", GroupName: "db1" })
查询字段 ErrNode、StartHistory、CrashHistory 是否已被置为空
> db.snapshot( SDB_SNAP_HEALTH, { GroupName: "group1" }, { NodeName: null, ErrNode: null, StartHistory: null, AbnormalHistory: null } ) { "NodeName": "sdbserver1:11820", "ErrNum": { "SDB_OOM": 0, "SDB_NOSPC": 0, "SDB_TOO_MANY_OPEN_FD": 0 }, "StartHistory": [], "CrashHistory": [] }