嗨,我已经为 MongoDB 配置了一个副本集。如果我运行命令:
sudo mongod --replSet "rs0"
一切正常,3 个副本正常工作,但如果我运行命令:
sudo mongod --config /etc/mongod.conf
它不起作用,shell 不显示任何内容,如果我检查运行 mongod 的进程没有与副本集一起运行。
这是我的 mongod.conf:
# 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
journal:
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:
#operationProfiling:
replication:
replSetName: "rs0"
这是日志文件:
2016-04-28T15:34:30.079+0000 I CONTROL [main] ***** SERVER RESTARTED *****
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] MongoDB starting : pid=30634 port=27017 dbpath=/var/lib/mongodb 64-bit host=db-test01
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] db version v3.2.5
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] git version: 34e65e5383f7ea1726332cb175b73077ec4a1b02
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] allocator: tcmalloc
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] modules: none
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] build environment:
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] distmod: ubuntu1404
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] distarch: x86_64
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] target_arch: x86_64
2016-04-28T15:34:30.097+0000 I CONTROL [initandlisten] options: { config: "/etc/mongod.conf", net: { port: 27017 }, replication: { replSetName: "res0" }, storage: { dbPath: "/var/lib/mongodb", journal: { enabled: true } }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2016-04-28T15:34:30.168+0000 I - [initandlisten] Detected data files in /var/lib/mongodb created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2016-04-28T15:34:30.168+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1G,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2016-04-28T15:34:30.907+0000 I CONTROL [initandlisten]
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten] ** WARNING: Insecure configuration, access control is not enabled and no --bind_ip has been specified.
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted,
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten] ** and the server listens on all available network interfaces.
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten]
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten]
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten]
2016-04-28T15:34:30.908+0000 I CONTROL [initandlisten]
2016-04-28T15:34:30.908+0000 I REPL [initandlisten] Did not find local voted for document at startup; NoMatchingDocument: Did not find replica set lastVote document in local.replset.election
2016-04-28T15:34:30.909+0000 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
2016-04-28T15:34:30.909+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongodb/diagnostic.data'
2016-04-28T15:34:30.909+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2016-04-28T15:34:30.909+0000 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker