nosql数据库入门第9周实验副本集,初始化副本集时为什么一直出错不成功

用户名:dengwang123
文章数:141
访问量:54036
注册日期:
阅读量:1297
阅读量:3317
阅读量:581033
阅读量:465355
51CTO推荐博文
副本集相关1.搭建副本集。(1)为副本集中的副本配置以下参数这些参数必须配置的,之后重启副本。&&replSet=rs0&&&&&&&&&#&副本的名称&&oplogSize=1024&&&&&#&oplog的初始大小&&keyFile=/home/mongodb261/data38017/mongodb-keyfile&&#&&keyfile文件的路径用户副本之间通信。&(2)登陆,初始化副本。&rsconf={"_id":"rs0","members":[{"_id":0,"host":"10.0.26.90:38017"}]}&rs.initiate(rsconf)&&然后执行查看副本集状态。rs0:PRIMARY&&rs.status(){&&&&&&&&"set"&:&"rs0",&&&&&&&&"date"&:&ISODate("T08:23:02Z"),&&&&&&&&"myState"&:&1,&&&&&&&&"members"&:&[&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38017",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"PRIMARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&2063,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T08:22:56Z"),&&&&&&&&&&&&&&&&&&&&&&&&"electionTime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"electionDate"&:&ISODate("T07:49:32Z"),&&&&&&&&&&&&&&&&&&&&&&&&"self"&:&true&&&&&&&&&&&&&&&&}&&&&&&&&],&&&&&&&&"ok"&:&1}stateStr:这个字段为表明初始化成功。现在的副本集中只有一个主库,所以需要添加副本。&Note:keyFile文件必须是同一个文件可以使用方法生成一个,然后到其他服务器中。cd&/mnt/mongodb/rs/config&&openssl&rand&-base64&741&&&mongodb-keyfile&&chmod&300&mongodb-keyfile&&&&&(3)添加副本rs0:PRIMARY&&rs.add("10.0.26.90:38018"){&"ok"&:&1&}rs0:PRIMARY&&rs.status(){&&&&&&&&"set"&:&"rs0",&&&&&&&&"date"&:&ISODate("T08:27:55Z"),&&&&&&&&"myState"&:&1,&&&&&&&&"members"&:&[&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38017",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"PRIMARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&2356,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T08:27:14Z"),&&&&&&&&&&&&&&&&&&&&&&&&"electionTime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"electionDate"&:&ISODate("T07:49:32Z"),&&&&&&&&&&&&&&&&&&&&&&&&"self"&:&true&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38018",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"SECONDARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&41,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T08:27:14Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeat"&:&ISODate("T08:27:54Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatRecv"&:&ISODate("T08:27:53Z"),&&&&&&&&&&&&&&&&&&&&&&&&"pingMs"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"syncingTo"&:&"10.0.26.90:38017"&&&&&&&&&&&&&&&&}&&&&&&&&],&&&&&&&&"ok"&:&1}&从的输出结果中可以看到已经添加到副本集中。&2.副本集的维护&&1&.添加节点仲裁数据删除节点添加数据节点添加仲裁节点rs.addArb("10.0.26.90:38020")&也可以添加仲裁服务器rs0:PRIMARY&&rs.status(){&&&&&&&&"set"&:&"rs0",&&&&&&&&"date"&:&ISODate("T08:54:08Z"),&&&&&&&&"myState"&:&1,&&&&&&&&"members"&:&[&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38017",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"PRIMARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&3929,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T08:43:36Z"),&&&&&&&&&&&&&&&&&&&&&&&&"electionTime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"electionDate"&:&ISODate("T07:49:32Z"),&&&&&&&&&&&&&&&&&&&&&&&&"self"&:&true&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38018",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"SECONDARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&649,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T08:43:36Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeat"&:&ISODate("T08:54:06Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatRecv"&:&ISODate("T08:54:07Z"),&&&&&&&&&&&&&&&&&&&&&&&&"pingMs"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"syncingTo"&:&"10.0.26.90:38017"&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38019",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"SECONDARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&649,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T08:43:36Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeat"&:&ISODate("T08:54:08Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatRecv"&:&ISODate("T08:54:06Z"),&&&&&&&&&&&&&&&&&&&&&&&&"pingMs"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"syncingTo"&:&"10.0.26.90:38017"&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&10,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38020",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&7,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"ARBITER",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&3,&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeat"&:&ISODate("T08:54:07Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatRecv"&:&ISODate("T08:54:07Z"),&&&&&&&&&&&&&&&&&&&&&&&&"pingMs"&:&8&&&&&&&&&&&&&&&&}&&&&&&&&],&&&&&&&&"ok"&:&1}从状态可以看出数据节点,仲裁节点都已经成功&(2)手动指定设置优先级并且重新加载配置文件cfg=rs.conf()&&&&cfg.members[0].priority=6&&#对需要提升为的副本甚至更高的rs.reconfig(cfg)&&&#&重新加载配置强制重新选举&以下示例是将设置为rs0:PRIMARY&&cfg=rs.conf(){&&&&&&&&"_id"&:&"rs0",&&&&&&&&"version"&:&46,&&&&&&&&"members"&:&[&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"host"&:&"10.0.26.90:38017",&&&&&&&&&&&&&&&&&&&&&&&&"priority"&:&6&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"host"&:&"10.0.26.90:38018",&&&&&&&&&&&&&&&&&&&&&&&&"priority"&:&6&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"host"&:&"10.0.26.90:38019"&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&10,&&&&&&&&&&&&&&&&&&&&&&&&"host"&:&"10.0.26.90:38020",&&&&&&&&&&&&&&&&&&&&&&&&"arbiterOnly"&:&true&&&&&&&&&&&&&&&&}&&&&&&&&]}rs0:PRIMARY&&&cfg.members[1].priority=1010rs0:PRIMARY&&rs.reconfig(cfg)T01:20:36.680-0800&DBClientCursor::init&call()&failedT01:20:36.696-0800&trying&reconnect&to&10.0.26.90:3.26.90)&failedT01:20:36.698-0800&reconnect&10.0.26.90:3.26.90)&okreconnected&to&server&after&rs&command&(which&is&normal)rs0:SECONDARY&&rs.status(){&&&&&&&&"set"&:&"rs0",&&&&&&&&"date"&:&ISODate("T09:20:46Z"),&&&&&&&&"myState"&:&2,&&&&&&&&"syncingTo"&:&"10.0.26.90:38018",&&&&&&&&"members"&:&[&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&0,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38017",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"SECONDARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&5527,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T09:20:36Z"),&&&&&&&&&&&&&&&&&&&&&&&&"infoMessage"&:&"syncing&to:&10.0.26.90:38018",&&&&&&&&&&&&&&&&&&&&&&&&"self"&:&true&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38018",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"PRIMARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&10,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T09:20:36Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeat"&:&ISODate("T09:20:44Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatRecv"&:&ISODate("T09:20:45Z"),&&&&&&&&&&&&&&&&&&&&&&&&"pingMs"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"electionTime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"electionDate"&:&ISODate("T09:20:42Z")&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38019",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&2,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"SECONDARY",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&10,&&&&&&&&&&&&&&&&&&&&&&&&"optime"&:&Timestamp(,&1),&&&&&&&&&&&&&&&&&&&&&&&&"optimeDate"&:&ISODate("T09:20:36Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeat"&:&ISODate("T09:20:44Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatRecv"&:&ISODate("T09:20:44Z"),&&&&&&&&&&&&&&&&&&&&&&&&"pingMs"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatMessage"&:&"syncing&to:&10.0.26.90:38018",&&&&&&&&&&&&&&&&&&&&&&&&"syncingTo"&:&"10.0.26.90:38018"&&&&&&&&&&&&&&&&},&&&&&&&&&&&&&&&&{&&&&&&&&&&&&&&&&&&&&&&&&"_id"&:&10,&&&&&&&&&&&&&&&&&&&&&&&&"name"&:&"10.0.26.90:38020",&&&&&&&&&&&&&&&&&&&&&&&&"health"&:&1,&&&&&&&&&&&&&&&&&&&&&&&&"state"&:&7,&&&&&&&&&&&&&&&&&&&&&&&&"stateStr"&:&"ARBITER",&&&&&&&&&&&&&&&&&&&&&&&&"uptime"&:&10,&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeat"&:&ISODate("T09:20:46Z"),&&&&&&&&&&&&&&&&&&&&&&&&"lastHeartbeatRecv"&:&ISODate("T09:20:45Z"),&&&&&&&&&&&&&&&&&&&&&&&&"pingMs"&:&0&&&&&&&&&&&&&&&&}&&&&&&&&],&&&&&&&&"ok"&:&1}&从状态中可以看出已经是了&&&(3)设置副本可读有两种方法可以使副本可读。方法一:在需要读的服务器上执行以下脚本db.getMongo().setSlaveOk();但是这个方法具有易失性副本重启又变成不可读了方法二在副本中找到文件这是一个隐藏文件,在这个文件中添加一下命令rs.slaveOk()&.这个方法永久有效。&&(4).快速添加一个副本集以备份的方式添加副本集或是直接文件方法一从副本集中分离出一个副本将即将添加的副本中的数据目录清空将的数据目录文件复制到的数据目录中然后重启副本的服务。最后以此将副本和副本添加至副本集中该方法已经验证过&方法二以的方式备份还原初始化副本#使用方式备份一个副本产生一个日志文件mongodump&--host=10.0.26.90&--port=38018&--username=root&&--password=anyu@2014&&--authenticationDatabase=admin&--out=/home/bckup/backup_all&--oplog&#使用还原一个备份应用mongorestore&--host=10.0.26.90&--port=38019&--username=root&--password=anyu@2014&&&/home/bckup/backup_all&&--oplogReplay&--drop&&#local&库中如果没有集合就手动创建一个。use&localdb.createCollection("oplog.rs",&{"capped"&:&true,&"size"&:&})#将记录还原到中。mongorestore&&--host=10.0.26.90&--port=38019&--authenticationDatabase=admin&--username=root&--password=anyu@2014&-d&local&-c&oplog.rs&/home/bckup/backup_all/oplog.bson&参看链接&&(5)副本的几种状态解释startup:加载副本集配置。之后进入startup2:副本创建几个线程用于处理复制和选举在初始化副本时会比较常见这种状态。recovering:副本运行正常但不能处理一些请求。ARBITER:在正常情况下仲裁者始终处于这个状态。down/unkown:处于次状态下副本无法和其他副本通信有可能副本挂掉了也有可能网络故障remove:被移除的成员会处于这个状态rollback:副本正在进行数据回滚fatal:副本遇到致命的错误一般情况只能重新同步副本Primary:主库的正常状态可对完提供服务Secondary:从库的正常状态可对外提供服务&&(6)rs.status()输出解读health:表示是否服务器可达,可达是,不可达是state:副本状态数值表示stateStr:副本状态等uptime:副本不间断可达经过的时间单位是秒。self:这个信息出现在执行函数的成员信息中pingMs:心跳从当前服务器达到某个成员所花费的平均时间health:表示是否服务器可达,可达是,不可达是syncingTo:表示当前服务器从哪个节点在做同步。lastHeartbeat:当前服务器最后一次收到其他成员心跳的时间electionDate/electionTime:选举时间optime与表达的信息也是一样的,只是表示的方式不同,一个是用新纪元开始的毫秒数表示的,一个是用一种更容易阅读的方式表示。Errmsg:成员在心跳请求中返回的状态信息,通过是一些状态信息,不全是错误信息。&&(7)调整的大小。&1&.关闭当前服务器&2&.修改配置文件使其以单机模式运行。&3&.将中的最后一条记录保存到其他集合中var&lastlog=db.oplog.rs.find().sort({ts:-1}).limit(1)#这个语句也可以获得最后的oplog,而且更快db.oplog.rs.find().sort({$natural:-1}).limit(1)db.temp.save(lastlog.next())&db.temp.find()&//确认是否插入成功&4&.删除集合db.oplog.rs.drop()&5&.创建集合db.createCollection("oplog.rs",{capped:true,size:})&6&.将中的记录插入中并且确认插入是否成功var&tt=db.temp.find()&;db.oplog.rs.insert(tt.next())&;db.oplog.rs.find();&7&.添加至副本集中修改配置重启服务&(8).常用维护命令rs.stepDown():在上执行使退位。rs.freeze(1200):将每个不想让它成为的机器让它在秒内无法成为这步也可以不做&&(9)副本配置选项priority=0:禁止副本成为主结点优先级为的结点永远都不会成为主节点slaveDelay:延迟备份结点要求的成员的优先级为最好设置为隐藏hidden:true(将结点设置为隐藏客服端无法将读请求发送给它可以使用验证buildIndexes:false(禁止在备份节点上创建索引votes:禁止副本投票消除副本的投票权禁止副本选举取消副本的选举和被选举权&通过以下方式配置:cfg=rs.conf()&&&&cfg.members[1].votes=0rs.reconfig(cfg)&&&&&(10)一些比较重要的概念选举机制(选举必须满足一下条件(1)自身是否能于主结点连通(2)希望被选举为主节点的备份结点的数据是否最新(3)有没有其他更高优先级的成员可以被选举为主节点仲裁服务器:当故障出现的时候确保有一部分服务器满足大多数只有当集群中的服务器数量为偶数时才有必要添加仲裁服务器。优先级:表示一个成员渴望成为主节点的程度。大多数:只有得到副本集中一半以上的支持才能被选举为&(11)初始化同步(1).找一个同步源副本集中的任意可用副本并且删除所有已存在的除外(2).克隆复制数据数据复制过程中最耗时的部分(3).将克隆过程中的所有操作都记录到中第一步(4).将第一个同步中的操作记录下来感觉有问题第二步(5).数据复制完毕开始创建索引。(6).将创建索引期间的所有操作全部同步过来。第三步(7).完成初始化状态切换到普通状态。&(12)副本集中创建索引:1.关闭一个节点服务器2.当机模式运行这个服务器3.在单机模式下创建索引.4.将节点作为副本集成员重新启动5.依次对副本集中的其他副本进行同样操作。6.最后在primary上创建索引(primary上的索引创建完成后,其他副本同样会复制创建索引的操作,但是副本已经创建了相同的索引,实际上不会应用该操作.)&副本集的搭建相关参考副本集维护相关参考&&&&本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)后使用快捷导航没有帐号?
查看: 2761|回复: 4
nosql第9周实验副本集,初始化副本集时为什么一直出错不成功
论坛徽章:13
本帖最后由 gigas 于
10:14 编辑
在第一个窗口中启动第1个节点
[root@localhost ~]# mongod --dbpath /var/lib/mongo/dbs/node1&&--port 20001 --nojournal --replSet blort
Thu Aug 29 10:07:27.304 [initandlisten] MongoDB starting : pid=9054 port=20001 dbpath=/var/lib/mongo/dbs/node1 32-bit host=localhost.localdomain
Thu Aug 29 10:07:27.304 [initandlisten]
Thu Aug 29 10:07:27.304 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Thu Aug 29 10:07:27.304 [initandlisten] **& && & 32 bit builds are limited to less than 2GB of data (or less with --journal).
Thu Aug 29 10:07:27.304 [initandlisten] **& && & Note that journaling defaults to off for 32 bit and is currently off.
Thu Aug 29 10:07:27.304 [initandlisten] **& && & See http://dochub.mongodb.org/core/32bit
Thu Aug 29 10:07:27.304 [initandlisten]
Thu Aug 29 10:07:27.304 [initandlisten] db version v2.4.5
Thu Aug 29 10:07:27.304 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed06602b
Thu Aug 29 10:07:27.304 [initandlisten] build info:
bs-linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST
BOOST_LIB_VERSION=1_49
Thu Aug 29 10:07:27.304 [initandlisten] allocator: system
Thu Aug 29 10:07:27.304 [initandlisten] options: { dbpath: &/var/lib/mongo/dbs/node1&, nojournal: true, port: 20001, replSet: &blort& }
Thu Aug 29 10:07:27.315 [FileAllocator] allocating new datafile /var/lib/mongo/dbs/node1/local.ns, filling with zeroes...
Thu Aug 29 10:07:27.315 [FileAllocator] creating directory /var/lib/mongo/dbs/node1/_tmp
Thu Aug 29 10:07:27.845 [FileAllocator] done allocating datafile /var/lib/mongo/dbs/node1/local.ns, size: 16MB,&&took 0.526 secs
Thu Aug 29 10:07:27.846 [FileAllocator] allocating new datafile /var/lib/mongo/dbs/node1/local.0, filling with zeroes...
Thu Aug 29 10:07:28.289 [FileAllocator] done allocating datafile /var/lib/mongo/dbs/node1/local.0, size: 16MB,&&took 0.443 secs
Thu Aug 29 10:07:28.290 [initandlisten] command local.$cmd command: { create: &startup_log&, size: , capped: true } ntoreturn:1 keyUpdates:0&&reslen:37 977ms
Thu Aug 29 10:07:28.290 [initandlisten] waiting for connections on port 20001
Thu Aug 29 10:07:28.293 [websvr] admin web console waiting for connections on port 21001
Thu Aug 29 10:07:28.293 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:07:28.293 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
Thu Aug 29 10:07:38.296 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:07:48.296 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
复制代码
在第二个窗口中启动 第2个节点
[root@localhost ~]# mongod --dbpath /var/lib/mongo/dbs/node2&&--port 20002 --nojournal --replSet blort
Thu Aug 29 10:07:53.947 [initandlisten] MongoDB starting : pid=9095 port=20002 dbpath=/var/lib/mongo/dbs/node2 32-bit host=localhost.localdomain
Thu Aug 29 10:07:53.948 [initandlisten]
Thu Aug 29 10:07:53.948 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Thu Aug 29 10:07:53.948 [initandlisten] **& && & 32 bit builds are limited to less than 2GB of data (or less with --journal).
Thu Aug 29 10:07:53.948 [initandlisten] **& && & Note that journaling defaults to off for 32 bit and is currently off.
Thu Aug 29 10:07:53.949 [initandlisten] **& && & See http://dochub.mongodb.org/core/32bit
Thu Aug 29 10:07:53.949 [initandlisten]
Thu Aug 29 10:07:53.949 [initandlisten] db version v2.4.5
Thu Aug 29 10:07:53.949 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed06602b
Thu Aug 29 10:07:53.949 [initandlisten] build info: Linux bs-linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST
BOOST_LIB_VERSION=1_49
Thu Aug 29 10:07:53.949 [initandlisten] allocator: system
Thu Aug 29 10:07:53.950 [initandlisten] options: { dbpath: &/var/lib/mongo/dbs/node2&, nojournal: true, port: 20002, replSet: &blort& }
Thu Aug 29 10:07:54.068 [FileAllocator] allocating new datafile /var/lib/mongo/dbs/node2/local.ns, filling with zeroes...
Thu Aug 29 10:07:54.068 [FileAllocator] creating directory /var/lib/mongo/dbs/node2/_tmp
Thu Aug 29 10:07:54.563 [FileAllocator] done allocating datafile /var/lib/mongo/dbs/node2/local.ns, size: 16MB,&&took 0.493 secs
Thu Aug 29 10:07:54.563 [FileAllocator] allocating new datafile /var/lib/mongo/dbs/node2/local.0, filling with zeroes...
Thu Aug 29 10:07:54.993 [FileAllocator] done allocating datafile /var/lib/mongo/dbs/node2/local.0, size: 16MB,&&took 0.43 secs
Thu Aug 29 10:07:54.994 [initandlisten] command local.$cmd command: { create: &startup_log&, size: , capped: true } ntoreturn:1 keyUpdates:0&&reslen:37 926ms
Thu Aug 29 10:07:54.995 [initandlisten] waiting for connections on port 20002
Thu Aug 29 10:07:54.997 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:07:54.997 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
Thu Aug 29 10:07:54.997 [websvr] admin web console waiting for connections on port 21002
Thu Aug 29 10:08:04.998 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:08:14.999 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:08:25.001 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:08:35.004 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:08:45.005 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:08:55.007 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
复制代码
在第三个窗口中启动第3个节点
[root@localhost ~]# mongod --dbpath /var/lib/mongo/dbs/node3&&--port 20003 --nojournal --replSet blort
Thu Aug 29 10:08:40.283 [initandlisten] MongoDB starting : pid=9143 port=20003 dbpath=/var/lib/mongo/dbs/node3 32-bit host=localhost.localdomain
Thu Aug 29 10:08:40.283 [initandlisten]
Thu Aug 29 10:08:40.283 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Thu Aug 29 10:08:40.283 [initandlisten] **& && & 32 bit builds are limited to less than 2GB of data (or less with --journal).
Thu Aug 29 10:08:40.284 [initandlisten] **& && & Note that journaling defaults to off for 32 bit and is currently off.
Thu Aug 29 10:08:40.284 [initandlisten] **& && & See http://dochub.mongodb.org/core/32bit
Thu Aug 29 10:08:40.284 [initandlisten]
Thu Aug 29 10:08:40.284 [initandlisten] db version v2.4.5
Thu Aug 29 10:08:40.284 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed06602b
Thu Aug 29 10:08:40.284 [initandlisten] build info: Linux bs-linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST
BOOST_LIB_VERSION=1_49
Thu Aug 29 10:08:40.284 [initandlisten] allocator: system
Thu Aug 29 10:08:40.284 [initandlisten] options: { dbpath: &/var/lib/mongo/dbs/node3&, nojournal: true, port: 20003, replSet: &blort& }
Thu Aug 29 10:08:40.291 [FileAllocator] allocating new datafile /var/lib/mongo/dbs/node3/local.ns, filling with zeroes...
Thu Aug 29 10:08:40.291 [FileAllocator] creating directory /var/lib/mongo/dbs/node3/_tmp
Thu Aug 29 10:08:40.756 [FileAllocator] done allocating datafile /var/lib/mongo/dbs/node3/local.ns, size: 16MB,&&took 0.46 secs
Thu Aug 29 10:08:40.756 [FileAllocator] allocating new datafile /var/lib/mongo/dbs/node3/local.0, filling with zeroes...
Thu Aug 29 10:08:41.275 [FileAllocator] done allocating datafile /var/lib/mongo/dbs/node3/local.0, size: 16MB,&&took 0.518 secs
Thu Aug 29 10:08:41.276 [initandlisten] command local.$cmd command: { create: &startup_log&, size: , capped: true } ntoreturn:1 keyUpdates:0&&reslen:37 984ms
Thu Aug 29 10:08:41.276 [initandlisten] waiting for connections on port 20003
Thu Aug 29 10:08:41.279 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:08:41.279 [rsStart] replSet info you may need to run replSetInitiate -- rs.initiate() in the shell -- if that is not already done
Thu Aug 29 10:08:41.279 [websvr] admin web console waiting for connections on port 21003
Thu Aug 29 10:08:51.280 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Thu Aug 29 10:09:01.281 [rsStart] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
复制代码
在第四个窗口中,通过mongo localhost:20001登录 ,进行初始化副本集
[root@localhost ~]# mongo localhost:20001
MongoDB shell version: 2.4.5
connecting to: localhost:20001/test
Server has startup warnings:
Thu Aug 29 10:07:27.304 [initandlisten]
Thu Aug 29 10:07:27.304 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Thu Aug 29 10:07:27.304 [initandlisten] **& && & 32 bit builds are limited to less than 2GB of data (or less with --journal).
Thu Aug 29 10:07:27.304 [initandlisten] **& && & Note that journaling defaults to off for 32 bit and is currently off.
Thu Aug 29 10:07:27.304 [initandlisten] **& && & See http://dochub.mongodb.org/core/32bit
Thu Aug 29 10:07:27.304 [initandlisten]
& rs.initiate({&_id& : &blort&,&members& : [
... {&_id& : 1,&host& : &:20001&},
... {&_id& : 2,&host& : &:20002&},
... {&_id& : 3,&host& : &:20003&}
... ]})
{
& && &&&&ok& : 0,
& && &&&&errmsg& : &couldn't initiate : can't find self in the replset config my port: 20001&
}
&
复制代码提示 &errmsg& : &couldn't initiate : can't find self in the replset config my port: 20001&的错误
请教大家怎么会这样?
论坛徽章:13
求大侠们帮忙!
高级会员, 积分 616, 距离下一级还需 384 积分
论坛徽章:2
你用的是test数据库没有权限,切换到admin下面去就OK了,我也遇到过这问题
论坛徽章:13
kgc1982 发表于
你用的是test数据库没有权限,切换到admin下面去就OK了,我也遇到过这问题
不是这个问题,原因是 这里应该填IP地址,改成localhost就成功了。

我要回帖

更多关于 nosql数据库有哪些 的文章

 

随机推荐