這是我的設(shè)定檔
port=27017 #端口號(hào)
fork=true #以守護(hù)進(jìn)程的方式運(yùn)行,創(chuàng)建服務(wù)器進(jìn)程
# master=true #單主從配置時(shí)設(shè)為主服務(wù)器
#salve=true ##單主從配置時(shí)設(shè)為從服務(wù)器
logpath=~/database/data/log.log #日志輸出文件路徑
logappend=true #日志輸出方式
dbpath=~/database/data/db/ #數(shù)據(jù)庫路徑
# replSet=testrs #設(shè)置富本集的名字
# shardsvr=true #設(shè)置是否分片
# auth=true#是否開啟授權(quán)
mongod -f ~/database/data/mongodb.conf
試圖啟動(dòng),然後報(bào)錯(cuò):
about to fork child process, waiting until server is ready for connections.
forked process: 27916
ERROR: child process failed, exited with error number 1
這個(gè)情況較大可能是因?yàn)?log 檔案的路徑和權(quán)限有問題
stackoverflow 上有類似討論:http://stackoverflow.com/ques...
樓主自己找到了解決方法是 log 檔案的路徑改成 /home/<user>
絕對(duì)路徑。
用 ~
代表 home 是 shell 提供的一個(gè) alias,只能用在 shell 中。