ImageVerifierCode 换一换
格式:DOCX , 页数:9 ,大小:17.32KB ,
资源ID:6259817      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6259817.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(何小伟向Mongodb集群添加新的成员节点.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

何小伟向Mongodb集群添加新的成员节点.docx

1、何小伟向Mongodb集群添加新的成员节点 向Mongodb集群添加新的成员节点 向集群添加新节点有两种方法:方 法第一种方法拷贝其他节点的数据文件到新的节点第二种方法向已有的replica set 添加新成员一第一种方法(拷贝其他节点的数据文件到新的节点) 我们在启动mongod服务之前一定要拷贝数据文件到本机。下面是空库添加到一个replica set中的日志记录:第一步:# 连接 Primary库Tue Nov 1 14:22:57 initandlisten connection accepted from 10.250.7.220:54235 #2Tue Nov 1 14:22:57

2、 initandlisten connection accepted from 10.250.7.220:54236 #3Tue Nov 1 14:22:57 initandlisten connection accepted from 10.250.7.220:54237 #4Tue Nov 1 14:22:57 rsStart trying to contact 10.250.7.220:27018Tue Nov 1 14:22:57 rsStart trying to contact 10.250.7.220:27019Tue Nov 1 14:22:57 rsStart trying

3、to contact 10.250.7.220:27020第二步:#从primary库复制replica set的配置信息,并保存到本地 -dbpath 指定的文件目录#Tue Nov 1 14:22:57 rsStart replSet got config version 2 from a remote, saving locallyTue Nov 1 14:22:57 rsStart replSet info saving a newer config version to local.system.replsetTue Nov 1 14:22:57 FileAllocator allo

4、cating new datafile /opt/mongodata/r1/local.ns, filling with zeroes.Tue Nov 1 14:22:57 FileAllocator creating directory /opt/mongodata/r1/_tmpTue Nov 1 14:22:57 FileAllocator done allocating datafile /opt/mongodata/r1/local.ns, size: 16MB, took 0.118 secsTue Nov 1 14:22:57 FileAllocator allocating n

5、ew datafile /opt/mongodata/r1/local.0, filling with zeroes.Tue Nov 1 14:23:01 FileAllocator done allocating datafile /opt/mongodata/r1/local.0, size: 64MB, took 3.807 secsTue Nov 1 14:23:01 FileAllocator allocating new datafile /opt/mongodata/r1/local.1, filling with zeroes.Tue Nov 1 14:23:02 rsStar

6、t replSet saveConfigLocally doneTue Nov 1 14:23:02 FileAllocator done allocating datafile /opt/mongodata/r1/local.1, size: 128MB, took 1.068 secsTue Nov 1 14:23:02 rsStart replSet STARTUP2Tue Nov 1 14:23:02 rsMgr replSet total number of votes is even - add arbiter or give one member an extra voteTue

7、 Nov 1 14:23:02 rsSync *第三步:#创建oplog 日志文件#Tue Nov 1 14:23:02 rsSync creating replication oplog of size: 944MB.Tue Nov 1 14:23:02 FileAllocator allocating new datafile /opt/mongodata/r1/local.2, filling with zeroes.Tue Nov 1 14:23:04 rsHealthPoll replSet info member 10.250.7.220:27018 is upTue Nov 1

8、14:23:04 rsHealthPoll replSet member 10.250.7.220:27018 is now in state SECONDARYTue Nov 1 14:23:04 rsHealthPoll replSet info member 10.250.7.220:27019 is upTue Nov 1 14:23:04 rsHealthPoll replSet member 10.250.7.220:27019 is now in state SECONDARYTue Nov 1 14:23:04 rsHealthPoll replSet info member

9、10.250.7.220:27020 is upTue Nov 1 14:23:04 rsHealthPoll replSet member 10.250.7.220:27020 is now in state PRIMARYTue Nov 1 14:23:49 FileAllocator done allocating datafile /opt/mongodata/r1/local.2, size: 1024MB, took 46.28 secsTue Nov 1 14:23:50 rsSync *第四步:#应用主库的日志,复制数据文件#Tue Nov 1 14:23:50 rsSync

10、replSet initial sync pendingTue Nov 1 14:23:50 rsSync replSet syncing to: 10.250.7.220:27020Tue Nov 1 14:23:50 rsSync build index local.me _id: 1 Tue Nov 1 14:23:50 rsSync build index done 0 records 0.003 secsTue Nov 1 14:23:50 rsSync replSet initial sync drop all databasesTue Nov 1 14:23:50 rsSync

11、dropAllDatabasesExceptLocal 1Tue Nov 1 14:23:50 rsSync replSet initial sync clone all databasesTue Nov 1 14:23:50 rsSync replSet initial sync cloning db: testTue Nov 1 14:23:50 FileAllocator allocating new datafile /opt/mongodata/r1/test.ns, filling with zeroes.Tue Nov 1 14:23:51 FileAllocator done

12、allocating datafile /opt/mongodata/r1/test.ns, size: 16MB, took 0.8 secsTue Nov 1 14:23:51 FileAllocator allocating new datafile /opt/mongodata/r1/test.0, filling with zeroes.Tue Nov 1 14:23:55 FileAllocator done allocating datafile /opt/mongodata/r1/test.0, size: 64MB, took 3.643 secsTue Nov 1 14:2

13、3:55 FileAllocator allocating new datafile /opt/mongodata/r1/test.1, filling with zeroes.Tue Nov 1 14:23:55 rsSync build index test.yql _id: 1 Tue Nov 1 14:23:56 rsSync build index done 1 records 0.006 secsTue Nov 1 14:23:56 rsSync replSet initial sync query minValidTue Nov 1 14:23:56 rsSync replSet

14、 initial oplog application from 10.250.7.220:27020 starting at Nov 1 14:14:05:1 to Nov 1 14:14:05:1Tue Nov 1 14:23:57 rsSync replSet initial sync finishing upTue Nov 1 14:23:57 rsSync replSet set minValid=4eaf8e2d:1Tue Nov 1 14:23:57 rsSync build index local.replset.minvalid _id: 1 Tue Nov 1 14:23:5

15、7 rsSync build index done 0 records 0.023 secsTue Nov 1 14:23:57 rsSync replSet initial sync doneTue Nov 1 14:23:58 rsSync replSet syncing to: 10.250.7.220:27020Tue Nov 1 14:23:58 rsSync replSet SECONDARYTue Nov 1 14:24:02 FileAllocator done allocating datafile /opt/mongodata/r1/test.1, size: 128MB,

16、 took 7.428 secsTue Nov 1 14:24:16 clientcursormon mem (MB) res:16 virt:2848 mapped:1312Tue Nov 1 14:24:42 initandlisten connection accepted from 127.0.0.1:21141 #5Tue Nov 1 14:29:16 clientcursormon mem (MB) res:16 virt:2849 mapped:1312Tue Nov 1 14:34:16 clientcursormon mem (MB) res:16 virt:2913 map

17、ped:1312Tue Nov 1 14:39:16 clientcursormon mem (MB) res:16 virt:2913 mapped:1312第五步:=下面是删除节点以后的日志=Tue Nov 1 14:39:28 conn2 end connection 10.250.7.220:54235Tue Nov 1 14:39:29 rsMgr replset msgReceivedNewConfig version: version: 3Tue Nov 1 14:39:29 rsMgr replSet info saving a newer config version to

18、local.system.replsetTue Nov 1 14:39:29 rsMgr replSet saveConfigLocally doneTue Nov 1 14:39:29 rsMgr replSet error self not present in the repl set configuration:Tue Nov 1 14:39:29 rsMgr _id: myset, version: 3, members: _id: 0, host: 10.250.7.220:27018 , _id: 1, host: 10.250.7.220:27019 , _id: 2, hos

19、t: 10.250.7.220:27020 -这是拷贝replica set myset 中其他节点的数据文件!(记住是数据文件,一定不要mongod.lock ,每个mongod进程都需要自己的数据目录,如果你要运行3个mongod的实例,那么就需要3个独自的目录。mongod启动的时候会在数据目录创建一个mongod.lock文件,阻止其他进程使用此目录.)第六步:#连接primary库Tue Nov 1 15:53:24 initandlisten connection accepted from 10.250.7.220:54761 #2Tue Nov 1 15:53:28 inita

20、ndlisten connection accepted from 10.250.7.220:54763 #3Tue Nov 1 15:53:28 initandlisten connection accepted from 10.250.7.220:54764 #4Tue Nov 1 15:53:34 clientcursormon mem (MB) res:31 virt:2606 mapped:1232Tue Nov 1 15:53:34 rsStart trying to contact 10.250.7.220:27018Tue Nov 1 15:53:34 rsStart tryi

21、ng to contact 10.250.7.220:27019Tue Nov 1 15:53:34 rsStart trying to contact 10.250.7.220:27020第七步:#拷贝配置文件,并保存。Tue Nov 1 15:53:34 rsStart replSet got config version 6 from a remote, saving locallyTue Nov 1 15:53:34 rsStart replSet info saving a newer config version to local.system.replsetTue Nov 1 1

22、5:53:34 rsStart replSet saveConfigLocally doneTue Nov 1 15:53:34 rsStart replSet STARTUP2Tue Nov 1 15:53:34 rsMgr replSet total number of votes is even - add arbiter or give one member an extra voteTue Nov 1 15:53:34 rsSync replSet SECONDARYTue Nov 1 15:53:34 rsHealthPoll replSet info member 10.250.

23、7.220:27018 is upTue Nov 1 15:53:34 rsHealthPoll replSet member 10.250.7.220:27018 is now in state SECONDARYTue Nov 1 15:53:34 rsHealthPoll replSet info member 10.250.7.220:27019 is upTue Nov 1 15:53:34 rsHealthPoll replSet member 10.250.7.220:27019 is now in state SECONDARYTue Nov 1 15:53:34 rsHeal

24、thPoll replSet info member 10.250.7.220:27020 is upTue Nov 1 15:53:34 rsHealthPoll replSet member 10.250.7.220:27020 is now in state PRIMARYTue Nov 1 15:53:34 rsMgr replSet cant see a majority, will not try to elect selfTue Nov 1 15:53:38 rsSync replSet syncing to: 10.250.7.220:27020 从上面的日志来看,这种方法初始

25、化的速度比较快。当然考虑拷贝数据文件的时间,在大量数据的时候,我们可以选择里面一种方案!二第二种方法(向已有的replica set 添加新成员) 向已有的replica set 添加新成员是很简单的,新加的成员可以是空的。下面介绍一下如何添加新成员: 添加新成员时,必须在新的机器上先起来一个mongodb服务,必须指出要加入的replica set 集群的名字基本语法如下(其他是默认的),然后再在replica set的master 库上执行添加操作:./mongod -dbpath=/opt/mongodata/r1 -port 27017 -replSet myset当然也可以使用下面的

26、命令,将输出日志记录到/opt/mongodata/r1/rac3.27017.log 里面!mongodbrac3 bin$./mongod -dbpath=/opt/mongodata/r1 -port 27017 -replSet myset -logpath=/opt/mongodata/r1/rac3.27017.log -logappend &第一步:在主节点上执行添加操作mongodbrac4 bin$ ./mongo 127.0.0.1:27020MongoDB shell version: 2.0.1connecting to: 127.0.0.1:27020/testPRI

27、MARY rs.status(); set : myset, date : ISODate(2011-11-01T06:13:01Z), myState : 1, syncingTo : 10.250.7.220:27018, members : _id : 0, name : 10.250.7.220:27018, health : 1, state : 2, stateStr : SECONDARY, uptime : 62668, optime : t : 1320066230000, i : 1 , optimeDate : ISODate(2011-10-31T13:03:50Z),

28、 lastHeartbeat : ISODate(2011-11-01T06:13:01Z), pingMs : 0 , _id : 1, name : 10.250.7.220:27019, health : 1, state : 2, stateStr : SECONDARY, uptime : 63887, optime : t : 1320066230000, i : 1 , optimeDate : ISODate(2011-10-31T13:03:50Z), lastHeartbeat : ISODate(2011-11-01T06:13:01Z), pingMs : 0 , _i

29、d : 2, name : 10.250.7.220:27020, health : 1, state : 1, stateStr : PRIMARY, optime : t : 1320066230000, i : 1 , optimeDate : ISODate(2011-10-31T13:03:50Z), self : true , ok : 1PRIMARY rs.add(10.250.7.241:27017); ok : 1 -添加成功添加之后,mongodb 会自动执行新加节点的恢复操作,所以第一次查询rs.status()时候,新加节点的信息为空,等待恢复完成之后再次查询就有了基

30、本信息了。PRIMARY rs.status(); .省略. _id : 2, name : 10.250.7.220:27020, health : 1, state : 1, stateStr : PRIMARY, optime : t : 1320128045000, i : 1 , optimeDate : ISODate(2011-11-01T06:14:05Z), self : true , _id : 3, name : 10.250.7.241:27017, health : 0, state : 8, stateStr : (not reachable/healthy), uptime : 0, optime : t : 0, i : 0 ,

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1