CentOS 7 下 MongoDB 分片副本集群日志切割测试
文章目录
- CentOS 7 下 MongoDB 分片副本集群日志切割测试
-
-
- 测试说明
- 环境搭建
- 测试方案
-
-
- 处理 config 服务日志
- 处理 shard 服务日志
- 处理 mongos 服务日志
- 测试结果
- 参考
测试说明
- CentOS 7.9 2009
- v3.4.24
- kill -SIGUSR1 ${port}
- mongodb config
- mongodb shard
- mongodb mongos
环境搭建
10.10.200.205 |
10.10.200.206 |
10.10.200.207 |
config |
config |
config |
shard1 |
shard1 |
shard1 |
shard2 |
shard2 |
shard2 |
shard3 |
shard3 |
shard3 |
mongos |
mongos |
mongos |
测试方案
处理 config 服务日志
[root@node2 log]
2023-01-16T10:17:44.205+0800 I NETWORK [conn913] received client metadata from 10.10.200.207:36786 conn913: { driver: { name: "NetworkInterfaceASIO-RS", version: "3.4.24" }, os: { type: "Linux", name: "CentOS Linux release 7.9.2009 (Core)", architecture: "x86_64", version: "Kernel 3.10.0-1160.el7.x86_64" } }
2023-01-16T10:19:01.287+0800 I - [conn913] end connection 10.10.200.207:36786 (27 connections now open)
[root@node2 log]
16072
[root@node2 log]
[root@node2 log]
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] pid=16072 port=21000 64-bit host=node2
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] Replica Set Config: { _id: "config", version: 1, configsvr: true, protocolVersion: 1, members: [ { _id: 0, host: "10.10.200.205:21000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "10.10.200.206:21000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 2, host: "10.10.200.207:21000", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatIntervalMillis: 2000, heartbeatTimeoutSecs: 10, electionTimeoutMillis: 10000, catchUpTimeoutMillis: 60000, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 }, replicaSetId: ObjectId('63bce0291c862cccdb2cedbc') } }
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] Replica Set Member State: PRIMARY
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] db version v3.4.24
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] git version: 865b4f6a96d0f5425e39a18337105f33e8db504d
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] allocator: tcmalloc
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] modules: none
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] build environment:
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] distmod: rhel70
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] distarch: x86_64
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] target_arch: x86_64
2023-01-16T10:20:04.486+0800 I CONTROL [signalProcessingThread] options: { config: "/usr/local/mongodb/conf/config.conf", net: { bindIp: "0.0.0.0", port: 21000 }, processManagement: { fork: true, pidFilePath: "/usr/local/mongodb/data/config/log/configsrv.pid" }, replication: { replSetName: "config" }, sharding: { clusterRole: "configsvr" }, storage: { dbPath: "/usr/local/mongodb/data/config/data", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/usr/local/mongodb/data/config/log/config.log" } }
[root@node2 log]
total 16
-rw-r--r--. 1 root root 2882 Jan 16 10:20 config.log
-rw-r--r--. 1 root root 7468 Jan 16 10:20 config.log.2023-01-16T02-20-04
-rw-r--r--. 1 root root 6 Jan 10 11:46 configsrv.pid
处理 shard 服务日志
[root@node2 log]
16226
[root@node2 log]
[root@node2 log]
total 36
-rw-r--r--. 1 root root 2478 Jan 16 10:22 shard1.log
-rw-r--r--. 1 root root 28448 Jan 16 10:22 shard1.log.2023-01-16T02-22-46
-rw-r--r--. 1 root root 6 Jan 10 11:53 shard1.pid
处理 mongos 服务日志
[root@node2 log]
22730
[root@node2 log]
[root@node2 log]
total 16
drwxr-xr-x. 2 root root 71 Jan 16 10:24 mongos.diagnostic.data
-rw-r--r--. 1 root root 1393 Jan 16 10:24 mongos.log
-rw-r--r--. 1 root root 7268 Jan 16 10:24 mongos.log.2023-01-16T02-24-21
-rw-r--r--. 1 root root 6 Jan 16 09:43 mongos.pid
测试结果
使用方法 |
是否影响服务 |
是否影响日志写入 |
是否方便简洁 |
是否可自动化 |
kill sigusr pid |
否(连接未断) |
否(备份、轮转) |
是(一条命令) |
是(计划任务) |
参考
- MongoDB – Forcing a Log Rotation with SIGUSR1