服务器准备:

主节点192.168.100.106

从节点192.168.100.107

仲裁节点192.168.100.108

三台服务器:

关闭防火墙

service iptables stop

chkconfig iptables off

创建文件夹

mkdir -p /export/mongo/data/db

mkdir -p /export/mongo/log

mkdir -p /export/mongo/key

mkdir -p /export/mongo/run

mkdir -p /export/mongo/conf

上传mongodb-linux-x86_64-3.4.6.tgz并解压在/export/mongo目录下

tar -zxvf mongodb-linux-x86_64-3.4.6.tgz

mv mongodb-linux-x86_64-3.4.6 mongodb

cd /export/mongo/log

创建mongod.log文件

主节点:

vim /export/mongo/conf/mongo.conf

port =28007

fork =true

dbpath =/export/mongo/data/db

logpath =/export/mongo/log/mongod.log

pidfilepath=/export/mongo/run/28007.pid

logappend =true

shardsvr =true

replSet =shard1

bind_ip=主节点IP

oplogSize=10000

noprealloc=true

从节点:

vim /export/mongo/conf/mongo.conf

port =28008

fork =true

dbpath =/export/mongo/data/db

logpath =/export/mongo/log/mongod.log

pidfilepath=/export/mongo/run/28008.pid

logappend =true

shardsvr =true

replSet =shard1

bind_ip=从节点IP

oplogSize=10000

noprealloc=true

仲裁节点:

vim /export/mongo/conf/mongo.conf

port =28009

fork =true

dbpath =/export/mongo/data/db

logpath =/export/mongo/log/mongod.log

pidfilepath=/export/mongo/run/28009.pid

logappend =true

shardsvr =true

replSet =shard1

bind_ip=仲裁节点IP

oplogSize=10000

noprealloc=true

三台服务启动mongodb:

cd /export/mongo/mongodb/bin

./mongod -f /export/mongo/conf/mongo.conf

主节点:

cd /export/mongo/mongodb/bin

./mongo 主节点IP:28007

use admin

config={_id:'shard1',members:[{_id:0,host:'118.1.2.81:28007'},{_id:1,host:'118.1.2.82:28008'},{_id:2,host:'118.1.2.74:28009', arbiterOnly:true}]}

rs.initiate(config)

--查看副本集情况

rs.status()

测试写入数据:
use db_test
db.tb_test01.insert( {"name":"yiibai tutorials"})
db.tb_test01.find()

最新文章

  1. GDB调试汇编分析
  2. gridView RowDataBound事件 鼠标经过行颜色变化及根据字段值显示指定内容
  3. W5500 keep-alive的用途与用法--新华龙电子
  4. 【CMD】日常总结
  5. linux下安装python环境
  6. phpStorm支持CodeIgniter代码提示/自动完成
  7. CentOS7安装Docker,运行Nginx镜像、Centos镜像
  8. Ibatis 异常:Unable to open connection to "oledb , provider V2.0.0.0 in framework .NET V2.0".
  9. githup在线预览demo
  10. java 表格项的删除、编辑、增加 修改版
  11. Linux 编译安装 apache 2.4
  12. Exception in thread "main" java.io.IOException: Failed to set permissions of path
  13. c++11 新特性之 autokeyword
  14. strutsprepareAndExecuteFiter
  15. Tsinsen-1487:分配游戏【树状数组】
  16. java内存管理(堆、栈、方法区)
  17. ssh免密验证,shell批量设置
  18. ubuntu升级显卡驱动
  19. 如何实现Activiti的分支条件的自定义配置(转)
  20. SpringData使用与整合

热门文章

  1. [USACO08JAN]Haybale Guessing(LuoguP2898)
  2. apache 二级域名设置
  3. D. Mahmoud and Ehab and another array construction task 因子分界模板+贪心+数学
  4. node.js 和 yarn 安装
  5. 题解 P5587 【打字练习】
  6. opencv:联通组件扫描
  7. python+pygame的导弹追踪鼠标游戏设置和说明
  8. Go断点续传
  9. SOA架构设计
  10. Kali2.0中peda与pwntools的安装