gpt4 book ai didi

mongodb - 如何在Ubuntu 14.04.4上通过配置文件使用replicaSet启动mongoDB

转载 作者:可可西里 更新时间:2023-11-01 09:06:39 24 4
gpt4 key购买 nike

嗨,我给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: "res0"

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

这是日志文件:
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

最佳答案

命令行删除引号,配置(yaml)保留它们。因此,您在配置文件中指定的名称是“res0”(引号是名称的一部分)。编辑配置并写入:

replication:
replSetName: res0

或者对rs0做同样的操作,如果这也是一个问题的话。

关于mongodb - 如何在Ubuntu 14.04.4上通过配置文件使用replicaSet启动mongoDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36911292/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com