我无法使用systemd服务启动mongos
Mongodb Sharding群集设置
/etc/mongos.conf
分片:configDB: CONFIG0 /蒙戈-CONFIG-1:27017,蒙戈-CONFIG-2:27017,蒙戈-CONFIG-3:27017 net:bindIp:0.0.0.0
/etc/systemd/system/mongos.service
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
Documentation=https://docs.mongodb.org/manual
[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongos --config /etc/mongos.conf --fork --logpath /var/log/mongodb/mongos.log
PIDFile=/var/run/mongodb/mongos.pid
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
[Install]
WantedBy=multi-user.target
摘自/var/log/mongodb/mongos.log
2018-03-28T13:22:05.019+0000 I CONTROL [main]
2018-03-28T13:22:05.019+0000 I CONTROL [main] ** WARNING: Access control is not enabled for the database.
2018-03-28T13:22:05.019+0000 I CONTROL [main] ** Read and write access to data and configuration is unrestricted.
2018-03-28T13:22:05.019+0000 I CONTROL [main]
2018-03-28T13:22:05.021+0000 I SHARDING [mongosMain] mongos version v3.6.3
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] allocator: tcmalloc
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] modules: none
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] build environment:
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] distmod: ubuntu1604
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] distarch: x86_64
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] target_arch: x86_64
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] db version v3.6.3
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] git version: 9586e557d54ef70f9ca4b43c26892cd55257e1a5
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] allocator: tcmalloc
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] modules: none
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] build environment:
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] distmod: ubuntu1604
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] distarch: x86_64
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] target_arch: x86_64
2018-03-28T13:22:05.021+0000 I CONTROL [mongosMain] options: { config: "/etc/mongos.conf", net: { bindIp: "0.0.0.0" }, processManagement: { fork: true }, sharding: { configDB: "config0/mongo-config-1:27017,mongo-config-2:27017,mongo-config-3:27017" }, systemLog: { destination: "file", path: "/var/log/mongodb/mongos.log" } }
2018-03-28T13:22:05.022+0000 I NETWORK [mongosMain] Starting new replica set monitor for config0/mongo-config-1:27017,mongo-config-2:27017,mongo-config-3:27017
2018-03-28T13:22:05.022+0000 I SHARDING [thread1] creating distributed lock ping thread for process mongos-router-2:27017:1522243325:-5142424883419352228 (sleeping for 30000ms)
2018-03-28T13:22:05.025+0000 I NETWORK [shard registry reload] Successfully connected to mongo-config-3:27017 (1 connections now open to mongo-config-3:27017 with a 5 second timeout)
2018-03-28T13:22:05.025+0000 I NETWORK [mongosMain] Successfully connected to mongo-config-1:27017 (1 connections now open to mongo-config-1:27017 with a 5 second timeout)
2018-03-28T13:22:05.026+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mongo-config-2:27017 (1 connections now open to mongo-config-2:27017 with a 5 second timeout)
2018-03-28T13:22:05.026+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Connecting to mongo-config-3:27017
2018-03-28T13:22:05.026+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Connecting to mongo-config-1:27017
2018-03-28T13:22:05.026+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Connecting to mongo-config-1:27017
2018-03-28T13:22:05.026+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Connecting to mongo-config-3:27017
2018-03-28T13:22:05.030+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Successfully connected to mongo-config-3:27017, took 4ms (2 connections now open to mongo-config-3:27017)
2018-03-28T13:22:05.034+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Successfully connected to mongo-config-1:27017, took 8ms (2 connections now open to mongo-config-1:27017)
2018-03-28T13:22:05.034+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Successfully connected to mongo-config-1:27017, took 8ms (2 connections now open to mongo-config-1:27017)
2018-03-28T13:22:05.034+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Successfully connected to mongo-config-3:27017, took 8ms (2 connections now open to mongo-config-3:27017)
2018-03-28T13:22:05.036+0000 I NETWORK [shard registry reload] Starting new replica set monitor for shard1/mongo-shard1-server-1:27017,mongo-shard1-server-2:27017
2018-03-28T13:22:05.036+0000 I NETWORK [shard registry reload] Starting new replica set monitor for shard2/mongo-shard2-server-1:27017,mongo-shard2-server-2:27017
2018-03-28T13:22:05.041+0000 W SHARDING [replSetDistLockPinger] pinging failed for distributed lock pinger :: caused by :: LockStateChangeFailed: findAndModify query predicate didn't match any lock document
2018-03-28T13:22:05.042+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mongo-shard1-server-1:27017 (1 connections now open to mongo-shard1-server-1:27017 with a 5 second timeout)
2018-03-28T13:22:05.047+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mongo-shard1-server-2:27017 (1 connections now open to mongo-shard1-server-2:27017 with a 5 second timeout)
2018-03-28T13:22:05.054+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mongo-shard2-server-1:27017 (1 connections now open to mongo-shard2-server-1:27017 with a 5 second timeout)
2018-03-28T13:22:05.061+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mongo-shard2-server-2:27017 (1 connections now open to mongo-shard2-server-2:27017 with a 5 second timeout)
2018-03-28T13:22:07.031+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Connecting to mongo-config-2:27017
2018-03-28T13:22:07.040+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Successfully connected to mongo-config-2:27017, took 9ms (1 connections now open to mongo-config-2:27017)
2018-03-28T13:22:07.040+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Connecting to mongo-config-2:27017
2018-03-28T13:22:07.041+0000 I FTDC [mongosMain] Initializing full-time diagnostic data capture with directory '/var/log/mongodb/mongos.diagnostic.data'
2018-03-28T13:22:07.042+0000 I ASIO [NetworkInterfaceASIO-ShardRegistry-0] Successfully connected to mongo-config-2:27017, took 2ms (2 connections now open to mongo-config-2:27017)
2018-03-28T13:22:07.043+0000 I NETWORK [mongosMain] waiting for connections on port 27017
2018-03-28T13:22:07.045+0000 I CONTROL [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2018-03-28T13:22:07.046+0000 W SHARDING [signalProcessingThread] error encountered while cleaning up distributed ping entry for mongos-router-2:27017:1522243325:-5142424883419352228 :: caused by :: InterruptedAtShutdown: interrupted at shutdown
2018-03-28T13:22:07.046+0000 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2018-03-28T13:22:07.046+0000 W SHARDING [Uptime reporter] failed to refresh mongos settings :: caused by :: InterruptedAtShutdown: Failed to refresh the balancer settings due to InterruptedAtShutdown: interrupted at shutdown
2018-03-28T13:22:07.046+0000 I CONTROL [signalProcessingThread] shutting down with code:0
注意:我可以使用命令行启动mongos
sudo /usr/bin/mongos --config /etc/mongos.conf --logpath /var/log/mongodb/mongos.log
答案 0 :(得分:0)
答案 1 :(得分:0)
如果在配置文件中指定了fork和pidFile,则不必在systemd中指定fork选项。
processManagement:
fork: true
pidFilePath: "/var/run/mongos.pid"
重要的是,两个配置文件中的pidfile必须匹配。