有一段时间没用mongo了,每次配置都得上官网copy配置文件,这次配置顺便记录下来,主要是记录出现的一个问题
先看看我们目录结构
这里我使用最小化的方式配置mongo,详细可以参考官网的doc文档
systemLog:
destination: file
path: "/home/linux/Applications/mongodb/logs/logs.txt"
logAppend: true
storage:
dbPath: "/home/linux/Applications/mongodb/data"
journal:
enabled: true
processManagement:
fork: true
pidFilePath: "/home/linux/Applications/mongodb/pids/pids.txt"
net:
bindIp: 127.0.0.1
port: 27017
setParameter:
enableLocalhostAuthBypass: false
~
~
这里需要注意的是,至少当前这个版本在我们ubuntu下不会显示conf配置的问题,记得之前在win下是会爆出错误配置的log信息的
问题:
linux@linux:~/Applications/mongodb$ ./bin/mongod -f ./conf/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 5128
ERROR: child process failed, exited with error number 1
由于没有爆出错误的信息,但我是知道10有8成是conf的问题,于是在使用--shutdown的参数启动mongod时偶然看到问题了
linux@linux:~/Applications/mongodb$ ./bin/mongod -f ./conf/mongod.conf --shutdown
2016-02-07T14:39:07.925+0800 F CONTROL [main] Failed global initialization: FileNotOpen logpath "/home/linux/Applications/mongodb/logs" should name a file, not a directory.
所以先创建pid文件和logs的文件
linux@linux:~/Applications/mongodb$ ./bin/mongod -f ./conf/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 5203
child process started successfully, parent exiting
linux@linux:~/Applications/mongodb$ ./bin/mongo -p 27017
MongoDB shell version: 3.2.1
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2016-02-07T14:42:34.362+0800 I CONTROL [initandlisten]
2016-02-07T14:42:34.369+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-02-07T14:42:34.369+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-02-07T14:42:34.369+0800 I CONTROL [initandlisten]
2016-02-07T14:42:34.370+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-02-07T14:42:34.370+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-02-07T14:42:34.370+0800 I CONTROL [initandlisten]
>