加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-13 18:34:49 所属栏目:Linux 来源:网络整理
导读:mongodb附带的标准upstart脚本工作正常: # Ubuntu upstart file at /etc/init/mongodb.conflimit nofile 20000 20000kill timeout 300 # wait 300s between SIGTERM and SIGKILL.pre-start script mkdir -p /var/lib/mongodb/ mkdir -p /var/log/mongodb/en
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 – 你必须停止然后重新开始

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读