mongodb默认绑定ip:127.0.0.1
但是一旦设定其他ip,即使设定nounixsocket
为false,也无法生成mongodb-27017.sock文件,也即无法通过socket链接访问服务mongod。
MongoDB, by default, creates a unix socket at /tmp/mongodb-27017.sock
as of pymongo 2.4. You can make a connection like this:
from pymongo import MongoClient
CONNECTION = MongoClient('/tmp/mongodb-27017.sock')
Additionally you can disable this behavior by starting mongod with --nounixsocket
or specify an alternate location with --unixSocketPrefix <path>
MongoDB will always create and listen on a UNIX socket, unless --nounixsocket
is set, --bind_ip
is not set, or --bind_ip
specifies 127.0.0.1
.