Chinaunix首页 | 论坛 | 博客
  • 博客访问: 611514
  • 博文数量: 103
  • 博客积分: 2269
  • 博客等级: 大尉
  • 技术积分: 1108
  • 用 户 组: 普通用户
  • 注册时间: 2011-09-23 16:32
文章分类

全部博文(103)

文章存档

2012年(61)

2011年(42)

分类: 数据库开发技术

2012-02-15 09:37:17


PRIMARY> use roothomesDB
switched to db roothomesDB
PRIMARY> db.createCollection("myCollection")
{ "ok" : 1 }
PRIMARY> roothomesInfo = {"name":"roothomes","email":"roothomes@xxx.com"}
{ "name" : "roothomes", "email" : "roothomes@xxx.com" }
PRIMARY> db.myCollection.insert(roothomesInfo);
PRIMARY> db.myCollection.find()
{ "_id" : ObjectId("4f3b0b0543992fd8ebaad142"), "name" : "roothomes", "email" : "roothomes@xxx.com" }

查看实际硬盘信息:
[root@roothomes /home/mongodb]$ ls /home/mongodb/replSet/standard01/
journal   local.15  local.22  local.3   local.37  local.44  local.8
local.0   local.16  local.23  local.30  local.38  local.45  local.9
local.1   local.17  local.24  local.31  local.39  local.46  local.ns
local.10  local.18  local.25  local.32  local.4   local.47  mongod.lock
local.11  local.19  local.26  local.33  local.40  local.48  roothomesDB.0
local.12  local.2   local.27  local.34  local.41  local.5   roothomesDB.1
local.13  local.20  local.28  local.35  local.42  local.6   roothomesDB.ns
local.14  local.21  local.29  local.36  local.43  local.7   _tmp
[root@roothomes /home/mongodb]$ ls /home/mongodb/replSet/standard02/
journal   local.15  local.22  local.3   local.37  local.44  mongod.lock
local.0   local.16  local.23  local.30  local.38  local.45  roothomesDB.0
local.1   local.17  local.24  local.31  local.39  local.5   roothomesDB.1
local.10  local.18  local.25  local.32  local.4   local.6   roothomesDB.ns
local.11  local.19  local.26  local.33  local.40  local.7   _tmp
local.12  local.2   local.27  local.34  local.41  local.8
local.13  local.20  local.28  local.35  local.42  local.9
local.14  local.21  local.29  local.36  local.43  local.ns
[root@roothomes /home/mongodb]$ ls /home/mongodb/replSet/standard03/
journal   local.15  local.22  local.3   local.37  local.5        roothomesDB.1
local.0   local.16  local.23  local.30  local.38  local.6        roothomesDB.ns
local.1   local.17  local.24  local.31  local.39  local.7        _tmp
local.10  local.18  local.25  local.32  local.4   local.8
local.11  local.19  local.26  local.33  local.40  local.9
local.12  local.2   local.27  local.34  local.41  local.ns
local.13  local.20  local.28  local.35  local.42  mongod.lock
local.14  local.21  local.29  local.36  local.43  roothomesDB.0
[root@roothomes /home/mongodb]$

连接副本节点:
[root@roothomes /home/mongodb]$ /home/mongodb/bin/mongo 192.168.1.75:20032/admin
MongoDB shell version: 2.0.2
connecting to: 192.168.1.75:20032/admin
SECONDARY> db.myCollection.find()
error: { "$err" : "not master and slaveok=false", "code" : 13435 }
SECONDARY> db.myCollection.find()
error: { "$err" : "not master and slaveok=false", "code" : 13435 }


PRIMARY>  db.isMaster()
{
        "setName" : "mychReplSet",
        "ismaster" : true,
        "secondary" : false,
        "hosts" : [
                "192.168.1.75:20031",
                "192.168.1.75:20033",
                "192.168.1.75:20032"
        ],
        "primary" : "192.168.1.75:20031",
        "me" : "192.168.1.75:20031",
        "maxBsonObjectSize" : 16777216,
        "ok" : 1
}
PRIMARY> rs.status()
{
        "set" : "mychReplSet",
        "date" : ISODate("2012-02-15T01:35:21Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "192.168.1.75:20031",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "optime" : {
                                "t" : 1329269509000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:31:49Z"),
                        "self" : true
                },
                {
                        "_id" : 1,
                        "name" : "192.168.1.75:20032",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 1319,
                        "optime" : {
                                "t" : 1329269509000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:31:49Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:35:21Z"),
                        "pingMs" : 12
                },
                {
                        "_id" : 2,
                        "name" : "192.168.1.75:20033",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 1319,
                        "optime" : {
                                "t" : 1329269509000,
                                "i" : 1
                        },
                        "optimeDate" : ISODate("2012-02-15T01:31:49Z"),
                        "lastHeartbeat" : ISODate("2012-02-15T01:35:20Z"),
                        "pingMs" : 10
                }
        ],
        "ok" : 1
}
PRIMARY>
阅读(3394) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~