linux – ubuntu:启动(upstart)mongodb的第二个实例

前端之家收集整理的这篇文章主要介绍了linux – ubuntu:启动(upstart)mongodb的第二个实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
mongodb附带的标准upstart脚本工作正常:
# Ubuntu upstart file at /etc/init/mongodb.conf

limit nofile 20000 20000

kill timeout 300 # wait 300s between SIGTERM and SIGKILL.

pre-start script
    mkdir -p /var/lib/mongodb/
    mkdir -p /var/log/mongodb/
end script

start on runlevel [2345]
stop on runlevel [06]

script
  ENABLE_MONGODB="yes"
  if [ -f /etc/default/mongodb ]; then . /etc/default/mongodb; fi
  if [ "x$ENABLE_MONGODB" = "xyes" ]; then exec start-stop-daemon --start --quiet --chuid mongodb --exec  /usr/bin/mongod -- --config /etc/mongodb.conf; fi
end script

如果我想运行一个mongod的第二个实例,我以为我只是复制/etc/mongodb.conf – > /etc/mongodb2.conf和/etc/init/mongodb.conf – > /etc/init/mongodb2.conf并更改第一个conf文件中的std端口.然后调整上面的脚本,以新创建的/etc/mongodb2.conf开头.

然后我可以说开始mongodb2,服务开始…但是在启动后就被杀死了.我改变了什么,让两个进程都运行起来?

# Ubuntu upstart file at /etc/init/mongodb2.conf

limit nofile 20000 20000

kill timeout 300 # wait 300s between SIGTERM and SIGKILL.

pre-start script
    mkdir -p /var/lib/mongodb2/
    mkdir -p /var/log/mongodb2/
end script

start on runlevel [2345]
stop on runlevel [06]

script
  ENABLE_MONGODB="yes"
  if [ -f /etc/default/mongodb ]; then . /etc/default/mongodb; fi
  if [ "x$ENABLE_MONGODB" = "xyes" ]; then exec start-stop-daemon --start --quiet --chuid mongodb --exec  /usr/bin/mongod -- --config /etc/mongodb2.conf; fi
end script

解决方法

我不能让“标准”的起步脚本工作(如上所述),所以我改变了这样:
# Ubuntu upstart file at /etc/init/mongodb.conf

limit nofile 20000 20000

kill timeout 300 # wait 300s between SIGTERM and SIGKILL.

pre-start script
    mkdir -p /var/lib/mongodb/
    mkdir -p /var/log/mongodb/
end script

start on runlevel [2345]
stop on runlevel [06]

script

  exec sudo -u mongodb /usr/bin/mongod --config /etc/mongodb.conf

end script

并且如果要运行mongodb的其他实例,只需复制* .conf文件并对/etc/mongodb2.conf和/etc/init/mongodb2.conf进行更改

# Ubuntu upstart file at /etc/init/mongodb2.conf

limit nofile 20000 20000

kill timeout 300 # wait 300s between SIGTERM and SIGKILL.

pre-start script
    mkdir -p /var/lib/mongodb2/
    mkdir -p /var/log/mongodb2/
end script

start on runlevel [2345]
stop on runlevel [06]

script

  exec sudo -u mongodb /usr/bin/mongod --config /etc/mongodb2.conf

end script

我认为唯一不起作用的是重新启动mongodb – 你必须停止然后重新开始

原文链接:https://www.f2er.com/linux/402324.html

猜你在找的Linux相关文章