当有两个 IP 地址时,mongodb 服务无法启动

当有两个 IP 地址时,mongodb 服务无法启动

在 /etc/mongodb.conf 文件中我有这个设置 bindIp:“127.0.0.1,192.168.1.51”,192.168.1.51 是我的路由器提供的私有 IP。当我执行 systemctl status mongodb 时:

mongodb.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2016-09-26 17:51:40 CST; 32s ago
   Process: 1070 ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf (code=exited, status=48)
   Main PID: 1070 (code=exited, status=48)

当我检查 /var/log/mongodb/mongod.log 时,我得到的结果如下:

2016-09-26T17:55:05.129-0600 I CONTROL  [main] ***** SERVER RESTARTED *****
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] MongoDB starting : pid=2916 port=27017 dbpath=/var/lib/mongodb 64-bit host=goku
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] db version v3.2.9
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2i  22 Sep 2016
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] allocator: tcmalloc
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] modules: none
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] build environment:
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten]     distarch: x86_64
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten]     target_arch: x86_64
2016-09-26T17:55:05.135-0600 I CONTROL  [initandlisten] options: { config: "/etc/mongodb.conf", net: { bindIp: "127.0.0.1,
192.168.1.51", port: 27017 }, processManagement: { pidFilePath: "/var/run/mongodb/mongod.pid" }, security: { authorization
: "enabled" }, storage: { dbPath: "/var/lib/mongodb", engine: "wiredTiger", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log", quiet: true } }
2016-09-26T17:55:05.163-0600 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=6G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),f
ile_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-09-26T17:55:05.521-0600 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2016-09-26T17:55:05.521-0600 I NETWORK  [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-09-26T17:55:05.522-0600 I NETWORK  [initandlisten] waiting for connections on port 27017

但是我可以运行 systemctl restart mongodb 并且一切正常

我已经编辑了 /usr/lib/systemd/system/mongodb.service 并添加了以下两行:

Requires=NetworkManager-dispatcher.service NetworkManager.service
After=syslog.target NetworkManager-dispatcher.service NetworkManager.service

因此,价值一百万美元的问题是,我还应该/可以做什么才能使其在启动时正常工作?

感谢您的帮助 :-)

答案1

您的日志表明该过程已成功启动(最后一行表示成功),但您的服务状态表明它已退出。

日志更有可能是正确的,服务已成功启动,但进程 ID ( PID) 似乎不匹配。您的服务状态为PID1070,日志显示 2916。我怀疑这是您的问题,我主要怀疑原因是选项pidFilePath。查看该文件中实际的内容并尝试删除该选项,看看是否能解决问题。

相关内容