centos7开机启动mongodb shard cluster
2015-06-26 10:10
696 查看
centos7开机启动mongodb shard cluster
分享光荣,盗链可耻。转载务必注明出处,鄙视盗链鼠辈。
shard node2配置
config server配置
mongos配置
注意:启停脚本第一行
systemctl enable mongodb开机自动启动
启停:systemctl start mongodb // systemctl stop mongodb
加上#!/bin/sh后信息如下
分享光荣,盗链可耻。转载务必注明出处,鄙视盗链鼠辈。
shard配置
shard node1配置shardsvr=true#注意此项 port=27018 rest=true httpinterface=true fork=true dbpath=/mongo_data/shard/node1 logpath=/var/log/mongo/shard/node1.log pidfilepath=/tmp/mongo_shard_node1.pid
shard node2配置
shardsvr=true#注意此项 port=27081 rest=true httpinterface=true fork=true dbpath=/mongo_data/shard/node2 logpath=/var/log/mongo/shard/node2.log pidfilepath=/tmp/mongo_shard_node2.pid
config server配置
configsvr = true#注意此项 port = 27019 rest=true httpinterface=true fork=true dbpath=/mongo_data/shard/config logpath=/var/log/mongo/shard/config.log pidfilepath=/tmp/mongo_shard_config.pid
mongos配置
configdb = 127.0.0.1:27019#注意与configsvr一致 chunkSize = 64 httpinterface=true fork=true logpath=/var/log/mongo/shard/mongos.log pidfilepath=/tmp/mongos.pid
shard启动脚本
启动,停止顺序自行思考,很好想start_mongo_shard.sh(先起shard node,再config server,再mongos)
#!/bin/sh /usr/local/mongodb3.0/bin/mongod --config=/usr/local/mongodb3.0/shard_node1_server /usr/local/mongodb3.0/bin/mongod --config=/usr/local/mongodb3.0/shard_node2_server /usr/local/mongodb3.0/bin/mongod --config=/usr/local/mongodb3.0/shard_config_server /usr/local/mongodb3.0/bin/mongos --config=/usr/local/mongodb3.0/shard_mongos_server
stop_mongo_shard.sh(先停mongos,再config server,再shard node)
#!/bin/sh kill `cat /tmp/mongos.pid` kill `cat /tmp/mongo_shard_config.pid` kill `cat /tmp/mongo_shard_node1.pid` kill `cat /tmp/mongo_shard_node2.pid`
注意:启停脚本第一行
#!/bin/sh非常重要,如果不写这行,命令行下脚本正常运行,但是在systemctl start xxxx启动mongodb服务时报错。详见后文。
shard开机自动启动
vim /usr/lib/systemd/system/mongodb.service[unit] Description=mongodb After=network.target [Service] Type=forking ExecStart=/usr/local/mongodb3.0/start_mongo_shard.sh ExecStop=/usr/local/mongodb3.0/stop_mongo_shard.sh PrivateTmp=true [Install] WantedBy=multi-user.target
systemctl enable mongodb开机自动启动
启停:systemctl start mongodb // systemctl stop mongodb
错误备录
如果启停脚本不写第一行#!/bin/sh,命令行直接执行start_mongo_shard.sh没问题,但是systemctl start mongodb会报错,如下
[xxx@xxx-centos7 system]$ sudo systemctl status mongodb mongodb.service Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled) Active: failed (Result: exit-code) since 四 2015-06-25 15:03:58 CST; 9s ago Process: 25509 ExecStart=/usr/local/mongodb3.0/start_mongo_shard.sh (code=exited, status=203/EXEC) Main PID: 25426 (code=exited, status=203/EXEC) 6月 25 15:03:58 xxx-centos7 systemd[25509]: Failed at step EXEC spawning /usr/local/mongodb3.0/start_mongo_...rror 6月 25 15:03:58 xxx-centos7 systemd[1]: mongodb.service: control process exited, code=exited status=203 6月 25 15:03:58 xxx-centos7 systemd[1]: Failed to start mongodb.service. 6月 25 15:03:58 xxx-centos7 systemd[1]: Unit mongodb.service entered failed state. Hint: Some lines were ellipsized, use -l to show in full.
加上#!/bin/sh后信息如下
[xxx@xxx-centos7 system]$ sudo systemctl status mongodb mongodb.service Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled) Active: active (running) since 四 2015-06-25 15:08:47 CST; 3s ago Process: 25656 ExecStart=/usr/local/mongodb3.0/start_mongo_shard.sh (code=exited, status=0/SUCCESS) Main PID: 25426 (code=exited, status=203/EXEC) CGroup: /system.slice/mongodb.service ├─25659 /usr/local/mongodb3.0/bin/mongod --config=/usr/local/mongodb3.0/shard_node1_server ├─25674 /usr/local/mongodb3.0/bin/mongod --config=/usr/local/mongodb3.0/shard_node2_server ├─25689 /usr/local/mongodb3.0/bin/mongod --config=/usr/local/mongodb3.0/shard_config_server └─25705 /usr/local/mongodb3.0/bin/mongos --config=/usr/local/mongodb3.0/shard_mongos_server
相关文章推荐
- mongodb集群状态
- MongoDB GridFS
- mongodb 2.6 window 安装启动服务
- python mongodb压力测试脚本
- mongoDB命令
- linux下安装配置mongodb
- MongoDB源码概述——内存管理和存储引擎
- MongoDB源码概述——内存管理和存储引擎
- MongoDB入门篇--增删改查
- mongodb3.1.3安全认证
- Mongodb知识及使用总结(一)
- 8天学通MongoDB——第一天 基础入门
- 利用MongoDB存储scrapy的数据
- mongodb 学习笔记 04 -- 游标、索引
- mongodb维护常用命令
- 【Monkey Run】2015博客keep doing outline
- 用mongodb存储日志
- 10-【MongoDB入门教程】 Journaling日志机制
- MongoDB 在mac上安装
- 为首次部署MongoDB做好准备:容量计划和监控