修改mongodb 3.4在centos 7上的启动方式

时间:2017-07-26 17:17:39

标签: mongodb amazon-ec2 centos7

我试图在EC2 Centos 7.3机器上启动mongodb 3.4。

问题是rpm安装的默认启动脚本会抛出此错误:

2017-07-26T13:01:29.820-0400 I NETWORK  [websvr] admin web console waiting for connections on port 28017
2017-07-26T13:01:29.822-0400 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/local/mongo-data/diagnostic.data'
2017-07-26T13:01:29.822-0400 I REPL     [initandlisten] Did not find local voted for document at startup.
2017-07-26T13:01:29.822-0400 I REPL     [initandlisten] Did not find local replica set configuration document at startup;  NoMatchingDocument: Did not find replica set configuration document in local.system.replset
2017-07-26T13:01:29.823-0400 I CONTROL  [signalProcessingThread] got signal 15 (Terminated), will terminate after current cmd ends
2017-07-26T13:01:29.823-0400 I NETWORK  [signalProcessingThread] shutdown: going to close listening sockets...
2017-07-26T13:01:29.823-0400 I NETWORK  [signalProcessingThread] closing listening socket: 9
2017-07-26T13:01:29.823-0400 I NETWORK  [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2017-07-26T13:01:29.823-0400 I NETWORK  [signalProcessingThread] shutdown: going to flush diaglog...
2017-07-26T13:01:29.823-0400 I REPL     [signalProcessingThread] shutting down replication subsystems
2017-07-26T13:01:29.824-0400 I NETWORK  [thread1] waiting for connections on port 27017
2017-07-26T13:01:29.824-0400 I FTDC     [signalProcessingThread] Shutting down full-time diagnostic data capture
2017-07-26T13:01:29.824-0400 I STORAGE  [signalProcessingThread] WiredTigerKVEngine shutting down
2017-07-26T13:01:29.894-0400 I STORAGE  [signalProcessingThread] shutdown: removing fs lock...
2017-07-26T13:01:29.894-0400 I CONTROL  [signalProcessingThread] now exiting
2017-07-26T13:01:29.894-0400 I CONTROL  [signalProcessingThread] shutting down with code:0

由于找不到与[initandlisten] Did not find local voted for document at startup.[initandlisten] Did not find local replica set configuration document at startup; NoMatchingDocument: Did not find replica set configuration document in local.system.replset有关的任何内容。

我用

成功启动了mongo
mongod --config /etc/mongod.conf

它有效。没有问题。我猜这上面的命令与以systemctl start mongod

开头的init脚本相同

我的配置文件如下所示:

systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongo/mongod.log

# Where and how to store data.
storage:
  dbPath: /local/mongo-data
  journal:
    enabled: true

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongo.pid  # location of pidfile

# network interfaces
net:
  port: 27017
  http:
    RESTInterfaceEnabled: true

replication:
  replSetName: res0

现在......也许有人可以告诉我我做错了什么以及为什么默认的启动脚本不起作用。 但问题是如何用我的解决方法替换默认启动脚本...... mongod --config /etc/mongod.conf

谢谢你, 加布里埃尔

1 个答案:

答案 0 :(得分:0)

问题在于,厨师我正在从模板更改默认数据文件夹和日志文件夹,而selinux拒绝访问它们。调整selinux以允许mongod用户解决了这个问题。

谢谢大家的回答。