数码资讯
把mongodb 的 config-server 和 mongos(router)注册为Linux系统服务
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
启动mongodb的config server和mongos(router),可以直接用命令行启动,然后把命令行写入/etc/init.d/下面的文件中实现开机自动启动。
也可以注册为系统服务(Systemd方式),实现开机自启,步骤如下:
(config server和mongos的其他配置,请参考:http://blog.csdn.net/clementad/article/details/52538364)
注册config-server为系统服务:
1、创建配置文件:
vi /usr/lib/systemd/system/mongo-config.service
2、注册开机启动:
systemctl enable mongo-config.service
启动:
systemctl start mongo-config.service
检查状态:
systemctl status mongo-config.service
注册mongos为系统服务:
1、创建配置文件:
vi /usr/lib/systemd/system/mongos.service
2、注册开机启动:
systemctl enable mongos.service
启动:
systemctl start mongos.service
检查状态:
也可以注册为系统服务(Systemd方式),实现开机自启,步骤如下:
(config server和mongos的其他配置,请参考:http://blog.csdn.net/clementad/article/details/52538364)
注册config-server为系统服务:
1、创建配置文件:
vi /usr/lib/systemd/system/mongo-config.service
[Unit] Description=Mongo Config Service After=mongod.service syslog.target network.target [Service] Type=forking User=mongod ExecStart=/usr/bin/mongod --config /opt/mongodb/configsvr1/mongod.conf Restart=on-failure [Install] WantedBy=multi-user.target注:Type=forking很重要,没这行就老是启动不了。
2、注册开机启动:
systemctl enable mongo-config.service
启动:
systemctl start mongo-config.service
检查状态:
systemctl status mongo-config.service
注册mongos为系统服务:
1、创建配置文件:
vi /usr/lib/systemd/system/mongos.service
[Unit] Description=Mongo Router Service After=mongo-config.service [Service] Type=forking User=mongod ExecStart=/usr/bin/mongos --config /opt/mongodb/mongos1/mongod.conf Restart=on-failure [Install] WantedBy=multi-user.target
2、注册开机启动:
systemctl enable mongos.service
启动:
systemctl start mongos.service
检查状态:
systemctl status mongos.service
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。