mongodb如何通过设置文件开启集群模式?
发布于 9 个月前 作者 lzszone 1250 次浏览 来自 问答

这是我的设置文件:

# mongod.conf
# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
#  dbPath: /var/lib/mongodb
  dbPath: /var/lib/repl_master
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:
# where to write logging data.
systemLog:
  destination: file
  logAppend: true
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:
# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log
# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1
#processManagement:
#security:
#  authorization: enabled
#operationProfiling:
replication:
  replSet = rs0
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:

我修改之后使用systemctl restart mongod不生效…mongod实例都没启动起来 如果用官方文档里的mongod --port 27017 --dbpath /srv/mongodb/db0 --replSet rs0 倒是可以,但是肯定希望是可配置的并且是系统服务 然后mongo日志里没看到为什么,不知道是目录没对还是看不懂…我只会cat

2017-12-01T13:12:26.862+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:44602 #169 (9 connections now open)
2017-12-01T13:12:26.940+0800 I INDEX    [conn165] build index on: rescue.emailRegister properties: { v: 2, unique: true, key: { username: 1 }, name: "username_1", ns: "rescue.emailRegister", background: true }
2017-12-01T13:12:30.644+0800 I COMMAND  [conn165] command rescue.posts command: find { find: "posts", filter: { pid: "t79638" }, projection: {}, limit: 1, singleBatch: true, batchSize: 1 } planSummary: IXSCAN { pid: 1 } keysExamined:1 docsExamined:1 cursorExhausted:1 numYields:0 nreturned:1 reslen:850 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 176ms
2017-12-01T13:12:30.650+0800 I COMMAND  [conn166] command rescue.posts command: find { find: "posts", filter: { pid: "t78305" }, projection: {}, limit: 1, singleBatch: true, batchSize: 1 } planSummary: IXSCAN { pid: 1 } keysExamined:1 docsExamined:1 cursorExhausted:1 numYields:0 nreturned:1 reslen:16401 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 128ms
2017-12-01T13:12:30.660+0800 I COMMAND  [conn167] command rescue.posts command: find { find: "posts", filter: { pid: "t66509" }, projection: {}, limit: 1, singleBatch: true, batchSize: 1 } planSummary: IXSCAN { pid: 1 } keysExamined:1 docsExamined:1 cursorExhausted:1 numYields:0 nreturned:1 reslen:7661 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 115ms
2017-12-01T13:13:38.157+0800 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2017-12-01T13:13:38.157+0800 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2017-12-01T13:13:38.157+0800 I NETWORK  [signalProcessingThread] closing listening socket: 7
2017-12-01T13:13:38.157+0800 I NETWORK  [signalProcessingThread] closing listening socket: 8
2017-12-01T13:13:38.157+0800 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2017-12-01T13:13:38.157+0800 I NETWORK  [signalProcessingThread] shutdown: going to flush diaglog...
2017-12-01T13:13:38.157+0800 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2017-12-01T13:13:38.160+0800 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2017-12-01T13:13:38.567+0800 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2017-12-01T13:13:38.567+0800 I CONTROL  [signalProcessingThread] now exiting
2017-12-01T13:13:38.567+0800 I CONTROL  [signalProcessingThread] shutting down with code:0

有大佬知道啥情况吗?

2 回复

…问题是db文件夹的所有者要改为mongodb…

回到顶部