我需要帮助找到我最近升级时搞砸了什么。
在我的Ubuntu 14.04系统上,我最近清除了所有mongod-org
# apt-get purge mongod-org
# apt-get autoremove
然后通过Mongo的说明安装(获得新密钥添加了3.2源代码)
# apt-get update
# apt-get mongodb-org
一切似乎安装得很好。让我们开始吧:
# service mongod start
mongod start/running, process 18811
# ps -ef | grep 18811
#
换句话说,不开始。没有写到mongod.log所以让我们尝试命令行!
# mongod
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] MongoDB starting : pid=18816 port=27017 dbpath=/data/db 64-bit host=as3001snllx
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] db version v3.2.3
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1f 6 Jan 2014
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] allocator: tcmalloc
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] modules: none
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] build environment:
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] distmod: ubuntu1404
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] distarch: x86_64
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] target_arch: x86_64
2016-03-03T09:46:42.104-0700 I CONTROL [initandlisten] options: {}
2016-03-03T09:46:42.145-0700 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2016-03-03T09:46:42.145-0700 I CONTROL [initandlisten] dbexit: rc: 100
啊,哈哈!没有/ data / db目录!但是,我有/etc/mongod.conf据说指向“/ var / lib / mongodb”。
这是/etc/mongod.conf
$ cat /etc/mongod.conf
storage:
dbPath: "/var/lib/mongodb"
engine: "wiredTiger"
journal:
enabled: true
systemLog:
destination: file
path: "/var/log/mongodb/mongod.log"
logAppend: true
net:
bindIp: 127.0.0.1
port: 27017
所以,也许我的upstart配置不读取此配置文件,因为/ data / db是默认设置。但是,我的/etc/init/mongod.conf有一个可以读取/etc/mongod.conf的指令。
我的/etc/init/mongod.conf文件
# Ubuntu upstart file at /etc/init/mongod.conf
# Recommended ulimit values for mongod or mongos
# See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
#
limit fsize unlimited unlimited
limit cpu unlimited unlimited
limit as unlimited unlimited
limit nofile 64000 64000
limit rss unlimited unlimited
limit nproc 64000 64000
kill timeout 300 # wait 300s between SIGTERM and SIGKILL.
pre-start script
DAEMONUSER=${DAEMONUSER:-mongodb}
if [ ! -d /var/lib/mongodb ]; then
mkdir -p /var/lib/mongodb && chown mongodb:mongodb /var/lib/mongodb
fi
if [ ! -d /var/log/mongodb ]; then
mkdir -p /var/log/mongodb && chown mongodb:mongodb /var/log/mongodb
fi
touch /var/run/mongodb.pid
chown $DAEMONUSER /var/run/mongodb.pid
end script
start on runlevel [2345]
stop on runlevel [06]
script
ENABLE_MONGOD="yes"
CONF=/etc/mongod.conf
DAEMON=/usr/bin/mongod
DAEMONUSER=${DAEMONUSER:-mongodb}
DAEMONGROUP=${DAEMONGROUP:-mongodb}
if [ -f /etc/default/mongod ]; then . /etc/default/mongod; fi
# Handle NUMA access to CPUs (SERVER-3574)
# This verifies the existence of numactl as well as testing that the command works
NUMACTL_ARGS="--interleave=all"
if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
then
NUMACTL="$(which numactl) -- $NUMACTL_ARGS"
DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"}
else
NUMACTL=""
DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"}
fi
if [ "x$ENABLE_MONGOD" = "xyes" ]
then
exec start-stop-daemon --start \
--chuid $DAEMONUSER:$DAEMONGROUP \
--pidfile /var/run/mongodb.pid \
--make-pidfile \
--exec $NUMACTL $DAEMON $DAEMON_OPTS --setParameter failIndexKeyTooLong=false
fi
end script
所以,让我们尝试使用--config /etc/init.d从命令行启动mongod
# mongod --config /etc/mongod.conf
这很有效。但是,我需要通过暴发户来解决这个问题!有什么想法吗?
答案 0 :(得分:3)
好的,所以我添加了一些日志记录到upstart脚本:
script
exec 2>>/dev/.initramfs/mongo-init.log
set -x
...
这提出了以下内容:
more /dev/.initramfs/mongo-init.log
+ ENABLE_MONGOD=yes
+ CONF=/etc/mongod.conf
+ DAEMON=/usr/bin/mongod
+ DAEMONUSER=mongodb
+ DAEMONGROUP=mongodb
+ [ -f /etc/default/mongod ]
+ . /etc/default/mongod
+ limit fsize unlimited unlimited
/proc/self/fd/9: 1: /etc/default/mongod: limit: not found
看看/ etc / default / mongod,我有:
more mongod
limit fsize unlimited unlimited # (file size)
limit cpu unlimited unlimited # (cpu time)
limit as unlimited unlimited # (virtual memory size)
limit nofile 64000 64000 # (open files)
limit nproc 64000 64000 # (processes/threads)
这是尝试调整以前的版本,我猜不再支持了。我评论了所有的东西(不想把它扔掉),而现在的新贵也在工作。
希望这可以帮助其他有类似问题的人