【发布时间】:2016-11-14 11:14:34
【问题描述】:
我尝试使用命令 mongod 从 /etc/init.d 文件夹启动 mongod 进程,但出现以下错误:
2016-11-14T16:26:55.264+0530 I CONTROL [initandlisten] MongoDB starting : pid=16092 port=27017 dbpath=/data/db 64-bit host=xyz
2016-11-14T16:26:55.264+0530 I CONTROL [initandlisten] db version v3.0.12
2016-11-14T16:26:55.264+0530 I CONTROL [initandlisten] git version: 33934938e0e95d534cebbaff656cde916b9c3573
2016-11-14T16:26:55.264+0530 I CONTROL [initandlisten] build info: Linux ip-10-93-197-138 2.6.32-220.el6.x86_64 #1 SMP Wed Nov 9 08:03:13 EST 2011 x86_64 BOOST_LIB_VERSION=1_49
2016-11-14T16:26:55.264+0530 I CONTROL [initandlisten] allocator: tcmalloc
2016-11-14T16:26:55.264+0530 I CONTROL [initandlisten] options: {}
2016-11-14T16:26:55.289+0530 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-11-14T16:26:55.289+0530 I CONTROL [initandlisten] dbexit: rc: 100
上面的错误说它无法找到dbpath,但是mongod脚本文件应该从我提到dbpath的/etc/mongod.conf文件中选择配置,这里我从mongod脚本文件中放入一些内容,我们通过它知道这是假设从 /etc/mongod.conf 文件中选择配置:
#!/bin/bash
# mongod - Startup script for mongod
# chkconfig: 35 85 15
# description: Mongo is a scalable, document-oriented database.
# processname: mongod
# config: /etc/mongod.conf
# pidfile: /var/run/mongodb/mongod.pid
. /etc/rc.d/init.d/functions
# things from mongod.conf get there by mongod reading it
# NOTE: if you change any OPTIONS here, you get what you pay for:
# this script assumes all options are in the config file.
CONFIGFILE="/etc/mongod.conf"
OPTIONS=" -f $CONFIGFILE"
SYSCONFIG="/etc/sysconfig/mongod"
以下是 mongod.conf 文件中的一些内容:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: false
# engine:
mmapv1:
smallFiles: true
# wiredTiger:
我可以通过在命令本身中指定 --dbpath 选项来启动 mongod 进程,如下所示:
mongod --dbpath /var/lib/mongo
但我想知道原因,为什么它没有从 /etc/mongod.conf 文件中选择 dbpath。
提前致谢。
【问题讨论】:
标签: mongodb