Chinaunix首页 | 论坛 | 博客
  • 博客访问: 435194
  • 博文数量: 121
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 540
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-16 16:28
文章分类

全部博文(121)

文章存档

2021年(3)

2018年(1)

2017年(5)

2016年(9)

2015年(23)

2014年(80)

我的朋友

分类: 数据库开发技术

2014-06-17 11:21:19



预制信息:
/home/mongodb/replSet/
         standard01  standard02  standard03
           20031       20032      20033
/home/mongodb/replSet/logs/
        standard01.log
        standard02.log
        standard03.log

[root@roothomes /home/mongodb]$ /home/mongodb/bin/mongod -dbpath /home/mongodb/replSet/standard01/ -logpath /home/mongodb/replSet/logs/standard01.log -port 20033 -replSet roothomesReplSet/192.168.1.75:20032 -maxConns=2000 -fork -logappend
forked process: 10422
all output going to: /home/mongodb/replSet/logs/standard01.log

[root@roothomes /home/mongodb]$ /home/mongodb/bin/mongod -dbpath /home/mongodb/replSet/standard02/ -logpath /home/mongodb/replSet/logs/standard02.log -port 20032 -replSet roothomesReplSet/192.168.1.75:20032 -maxConns=2000 -fork -logappend
forked process: 10436
all output going to: /home/mongodb/replSet/logs/standard02.log

[root@roothomes /home/mongodb]$ /home/mongodb/bin/mongod -dbpath /home/mongodb/replSet/standard03/ -logpath /home/mongodb/replSet/logs/standard03.log -port 20033 -replSet roothomesReplSet/192.168.1.75:20032 -maxConns=2000 -fork -logappend
forked process: 10448
all output going to: /home/mongodb/replSet/logs/standard03.log


[root@roothomes /home/mongodb]$ /home/mongodb/bin/mongo 192.168.1.75:20031/admin
MongoDB shell version: 2.0.2
connecting to: 192.168.1.75:20031/admin
> db.runCommand({"replSetInitiate" : { "_id" : "roothomesReplSet",
... "members" : [
... { "_id" : 0,  "host" : "192.168.1.75:20031" },
...  { "_id" : 1,  "host" : "192.168.1.75:20032" },
... { "_id" : 2,  "host" : "192.168.1.75:20033" }
... ]}})
{
        "info" : "Config now saved locally.  Should come online in about a minute.",
        "ok" : 1
}
> rs.status()
{
        "set" : "roothomesReplSet",
        "date" : ISODate("2012-02-15T01:13:30Z"),
        "myState" : 2,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "192.168.1.75:20031",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "optime" : {
                                "t" : 1329268399000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:13:19Z"),
                        "self" : true
                },
                {
                        "_id" : 1,
                        "name" : "192.168.1.75:20032",
                        "health" : 1,
                        "state" : 5,
                        "stateStr" : "STARTUP2",
                        "uptime" : 8,
                        "optime" : {
                                "t" : 0,
                                "i" : 0
                        },
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:13:28Z"),
                        "pingMs" : 5
                },
                {
                        "_id" : 2,
                        "name" : "192.168.1.75:20033",
                        "health" : 1,
                        "state" : 6,
                        "stateStr" : "UNKNOWN",
                        "uptime" : 8,
                        "optime" : {
                                "t" : 0,
                                "i" : 0
                        },
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:13:28Z"),
                        "pingMs" : 21,
                        "errmsg" : "still initializing"
                }
        ],
        "ok" : 1
}
SECONDARY> rs.status()
{
        "set" : "roothomesReplSet",
        "date" : ISODate("2012-02-15T01:13:46Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "192.168.1.75:20031",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "optime" : {
                                "t" : 1329268399000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:13:19Z"),
                        "self" : true
                },
                {
                        "_id" : 1,
                        "name" : "192.168.1.75:20032",
                        "health" : 1,
                        "state" : 3,
                        "stateStr" : "RECOVERING",
                        "uptime" : 24,
                        "optime" : {
                                "t" : 0,
                                "i" : 0
                        },
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:13:44Z"),
                        "pingMs" : 16,
                        "errmsg" : "initial sync need a member to be primary or
                },
                {
                        "_id" : 2,
                        "name" : "192.168.1.75:20033",
                        "health" : 1,
                        "state" : 3,
                        "stateStr" : "RECOVERING",
                        "uptime" : 24,
                        "optime" : {
                                "t" : 0,
                                "i" : 0
                        },
                        "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:13:44Z"),
                        "pingMs" : 11,
                        "errmsg" : "initial sync need a member to be primary or
                }
        ],
        "ok" : 1
}
PRIMARY> rs.status()
{
        "set" : "roothomesReplSet",
        "date" : ISODate("2012-02-15T01:14:08Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "192.168.1.75:20031",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "optime" : {
                                "t" : 1329268399000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:13:19Z"),
                        "self" : true
                },
                {
                        "_id" : 1,
                        "name" : "192.168.1.75:20032",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 46,
                        "optime" : {
                                "t" : 1329268399000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:13:19Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:14:07Z"),
                        "pingMs" : 18
                },
                {
                        "_id" : 2,
                        "name" : "192.168.1.75:20033",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 46,
                        "optime" : {
                                "t" : 1329268399000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:13:19Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:14:06Z"),
                        "pingMs" : 1
                }
        ],
        "ok" : 1
}
PRIMARY>



阅读(1228) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~