码迷,mamicode.com
首页 > 数据库 > 详细

mongdb副本集部署

时间:2019-11-26 09:22:04      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:inter   配置文件   仲裁   set   worker   protoc   efault   setname   lis   

两台机器

1.在/etc/hosts文件中写上
192.168.255.133 worker1
192.168.255.134 worker2

2.修改配置文件/etc/mongdb.conf
bindIp: 0.0.0.0 #供所有机器访问
replication:
replSetName: rs # 给副本集取名字叫rs

3.启动
mongod

4.初始化副本集

mongo

rs.initiate()

5.添加成员节点
rs.add("worker2:27017")

rs.addArb("182.48.115.239:27017") #添加仲裁节点

6.进入mongodb shell中查看配置

mongo

rs.conf()
MongoDB Enterprise rs:PRIMARY> rs.conf()
{
"_id" : "rs",
"version" : 2,
"protocolVersion" : NumberLong(1),
"writeConcernMajorityJournalDefault" : true,
"members" : [
{
"_id" : 0,
"host" : "worker1:27017",
"arbiterOnly" : false,
"buildIndexes" : true,
"hidden" : false,
"priority" : 1,
"tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            },
            {
                    "_id" : 1,
                    "host" : "worker2:27017",
                    "arbiterOnly" : false,
                    "buildIndexes" : true,
                    "hidden" : false,
                    "priority" : 1,
                    "tags" : {

                    },
                    "slaveDelay" : NumberLong(0),
                    "votes" : 1
            }
    ],
    "settings" : {
            "chainingAllowed" : true,
            "heartbeatIntervalMillis" : 2000,
            "heartbeatTimeoutSecs" : 10,
            "electionTimeoutMillis" : 10000,
            "catchUpTimeoutMillis" : -1,
            "catchUpTakeoverDelayMillis" : 30000,
            "getLastErrorModes" : {

            },
            "getLastErrorDefaults" : {
                    "w" : 1,
                    "wtimeout" : 0
            },
            "replicaSetId" : ObjectId("5dd12530c247798c40d9cfef")
    }

}

mongdb副本集部署

标签:inter   配置文件   仲裁   set   worker   protoc   efault   setname   lis   

原文地址:https://blog.51cto.com/9237101/2453448

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!