折腾:
期间,去加上多个IP后:
bindIp: 127.0.0.1, 112.4.64.141 # Listen to specific IP
结果去看看log:
[root@xxx-general-01 ~]# tail -n 40 /var/log/mongodb/mongod.log ... 2018-04-10T13:59:39.572+0800 I CONTROL [main] ***** SERVER RESTARTED ***** 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] MongoDB starting : pid=1573 port=32018 dbpath=/var/lib/mongo 64-bit host=xxx-general-01 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] db version v3.2.19 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] git version: a9f574de6a566a58b24d126b44a56718d181e989 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] allocator: tcmalloc 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] modules: none 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] build environment: 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] distmod: rhel70 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] distarch: x86_64 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] target_arch: x86_64 2018-04-10T13:59:39.580+0800 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1, 112.4.64.141", port: 32018 }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, security: { authorization: "enabled" }, storage: { dbPath: "/var/lib/mongo", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } } 2018-04-10T13:59:39.695+0800 I NETWORK [initandlisten] getaddrinfo(" 112.4.64.141") failed: Name or service not known 2018-04-10T13:59:39.695+0800 E NETWORK [initandlisten] listen(): socket is invalid. 2018-04-10T13:59:39.695+0800 E STORAGE [initandlisten] Failed to set up sockets during startup. 2018-04-10T13:59:39.695+0800 I CONTROL [initandlisten] dbexit: rc: 48
很明显,此处是语法问题:
getaddrinfo(” 112.4.64.141″) failed: Name or service not known
去把IP前面的空格去掉:
vi /etc/mongod.conf 27 net: 28 port: 32018 29 bindIp: 127.0.0.1,112.4.64.141 # Listen to specific IP
再重启mongo,看看是否还出错。
然后虽然还是有别的错误,但是此处的问题解决了。
【总结】
此处mongod的配置文件中,去配置:
bindIp: 127.0.0.1, 112.4.64.141 # Listen to specific IP
由于两个IP地址中间,除了本身的逗号分隔后,多加了个空格,导致无法被识别。
去掉空格:
bindIp: 127.0.0.1,112.4.64.141 # Listen to specific IP
就可以了。
-》看来,配置文件的解析,还是支持的不够智能啊。
后续详见:
【已解决】添加了IP限制的mongod重启出错:Job for mongod.service failed because the control process exited with error code
转载请注明:在路上 » 【已解决】mongo中给bindIp添加多个IP后出错:getaddrinfo failed Name or service not known