无法在redhat上启动mongod进程

时间:2016-11-14 11:14:35

标签: mongodb

我尝试使用命令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脚本文件应该从/etc/mongod.conf文件中选择配置我已经提到了dbpath,这里我从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。

提前致谢。

1 个答案:

答案 0 :(得分:0)

使用--config指定配置文件,以便mongod.exe可以使用配置文件启动服务器。

语法:

mongod --config /etc/mongod.conf

参考:

  1. https://docs.mongodb.com/v3.2/reference/configuration-options/#use-the-configuration-file