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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

mongodb在线添加移除新的分片复制集.docx

1、mongodb在线添加移除新的分片复制集前面添加新的分片复制集因为版本不一致无法兼容,见:1、在master2上建立3个mongodb 准备3个mongodb进程数,先准备数据目录和日志目录: mkdir -p /data/mongodb/shard37017 mkdir -p /data/mongodb/shard37027 mkdir -p /data/mongodb/shard37037 mkdir -p /data/mongodb/logs 3个启动命令: /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replS

2、et shard3 -port 37017 -dbpath /data/mongodb/shard37017 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37017.log -logappend -fork /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37027 -dbpath /data/mongodb/shard37027 -oplogSize 2048 -logpath /data/mongodb/logs/s

3、hard_m2_37027.log -logappend -fork /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37037 -dbpath /data/mongodb/shard37037 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37037.log -logappend -fork PS:启动mongodb进程可能会卡住,比较慢,不过需要耐心等待,ps -eaf|grep mongodb可能会有好几一个一样的进

4、程在跑(比如37037端口),不过这只是暂时的,没有关系,等一会启动完成了后,就会只有一个37037的端口在运行:# 会有2个37037的端口在运行着rootdb_master_2 # ps -eaf|grep mongo root 52721 752 0 21:27 pts/0 00:00:00 su - mongodb mongodb 52722 52721 0 21:27 pts/0 00:00:00 -bash mongodb 56368 1 0 21:36 ? 00:00:00 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -sha

5、rdsvr -replSet shard3 -port 37017 -dbpath /data/mongodb/shard37017 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37017.log -logappend -fork mongodb 56421 1 0 21:36 ? 00:00:00 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37027 -dbpath /data/mongodb/shard3702

6、7 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37027.log -logappend -fork mongodb 56473 52722 1 21:36 pts/0 00:00:00 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37037 -dbpath /data/mongodb/shard37037 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37

7、037.log -logappend -fork mongodb 56474 56473 0 21:36 ? 00:00:00 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37037 -dbpath /data/mongodb/shard37037 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37037.log -logappend -fork mongodb 56475 56474 17 21:36 ? 00:00

8、:01 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37037 -dbpath /data/mongodb/shard37037 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37037.log -logappend -fork root 56489 55041 0 21:36 pts/1 00:00:00 grep mongo rootdb_master_2 # # 过了一段时间后,等项目启动完后,进程数目变成了正常

9、的3个了。 rootdb_master_2 # rootdb_master_2 # ps -eaf|grep mongo root 52721 752 0 21:27 pts/0 00:00:00 su - mongodb mongodb 52722 52721 0 21:27 pts/0 00:00:00 -bash mongodb 56368 1 0 21:36 ? 00:00:03 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37017 -dbpath /data/mon

10、godb/shard37017 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37017.log -logappend -fork mongodb 56421 1 0 21:36 ? 00:00:03 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37027 -dbpath /data/mongodb/shard37027 -oplogSize 2048 -logpath /data/mongodb/logs/shard

11、_m2_37027.log -logappend -fork mongodb 56475 1 0 21:36 ? 00:00:05 /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongod -shardsvr -replSet shard3 -port 37037 -dbpath /data/mongodb/shard37037 -oplogSize 2048 -logpath /data/mongodb/logs/shard_m2_37037.log -logappend -fork root 61460 55041 0 21:49 pts/1 00:

12、00:00 grep mongo rootdb_master_2 # 2、初始化新的分片集 # 设置新的分片 config = _id:shard3, members: _id:0,host:mongodb_shard3:37017,priority:1, _id:1,host:mongodb_shard3:37027,priority:2, _id:2,host:mongodb_shard3:37037,arbiterOnly:true ; # 初始化副本集 rs.initiate(config); # 执行过程如下: mongodbdb_master_2 $ /usr/local/mong

13、odb-linux-x86_64-2.4.4/bin/mongo mongodb_shard3:37017/admin MongoDB shell version: 2.4.4 connecting to: mongodb_shard3:37017/admin Server has startup warnings: 2016-07-08T17:39:51.888+0800 I CONTROL initandlisten 2016-07-08T17:39:51.888+0800 I CONTROL initandlisten * WARNING: /sys/kernel/mm/transpar

14、ent_hugepage/enabled is always. 2016-07-08T17:39:51.888+0800 I CONTROL initandlisten * We suggest setting it to never 2016-07-08T17:39:51.888+0800 I CONTROL initandlisten 2016-07-08T17:39:51.888+0800 I CONTROL initandlisten * WARNING: /sys/kernel/mm/transparent_hugepage/defrag is always. 2016-07-08T

15、17:39:51.888+0800 I CONTROL initandlisten * We suggest setting it to never 2016-07-08T17:39:51.888+0800 I CONTROL initandlisten config = _id:shard3, members: . _id:0,host:mongodb_shard3:37017,priority:1, . _id:1,host:mongodb_shard3:37027,priority:2, . _id:2,host:mongodb_shard3:37037,arbiterOnly:true

16、 . . ; _id : shard3, members : _id : 0, host : mongodb_shard3:37017, priority : 1 , _id : 1, host : mongodb_shard3:37027, priority : 2 , _id : 2, host : mongodb_shard3:37037, arbiterOnly : true rs.initiate(config); ok : 1 shard3:OTHER 3、mongos上在线添加新的分片shard3添加命令:db.runCommand( addshard : shard3/mong

17、odb_shard3:37017,mongodb_shard3:37027,mongodb_shard3:37037); mongodbdb_m1_slave_1 logs$ /usr/local/mongodb-linux-x86_64-2.4.4/bin/mongo mongodbs1:30000/admin MongoDB shell version: 2.4.4 connecting to: localhost:30000/admin mongos db.runCommand( addshard : shard3/mongodb_shard3:37017,mongodb_shard3:

18、37027,mongodb_shard3:37037); shardAdded : shard1, ok : 1 mongos db.runCommand( addShard: shard3/mongodb_shard3:37017,mongodb_shard3:37027,mongodb_shard3:37037, maxSize: 0, name: shard3 ); sh.addShard(shard3/mongodb_shard3:37017,mongodb_shard3:37027,mongodb_shard3:37037) 执行过程如下:mongodbdb_master_2 $ /

19、usr/local/mongodb-linux-x86_64-2.4.4/bin/mongo mongodbs1:30000/adminMongoDB shell version: 2.4.4connecting to: mongodbs1:30000/adminmongos db.runCommand( addshard : shard3/mongodb_shard3:37017,mongodb_shard3:37027,mongodb_shard3:37037); ok : 0, errmsg : couldnt connect to new shard socket exception

20、CONNECT_ERROR for shard3/mongodb_shard3:37017,mongodb_shard3:37027,mongodb_shard3:37037mongos db.runCommand( removeShard : shard3 ); msg : draining started successfully, state : started, shard : shard3, ok : 1mongos 4、添加移除分片过程添加shard3报错:mongos db.runCommand( addshard : shard3/mongodb_shard3:37017,mo

21、ngodb_shard3:37027,mongodb_shard3:37037); ok : 0, errmsg : E11000 duplicate key error index: config.shards.$_id_ dup key: : shard3 mongos 查看下当前的sharding信息:mongos db.printShardingStatus();- Sharding Status - sharding version: _id : 1, version : 3, minCompatibleVersion : 3, currentVersion : 4, cluster

22、Id : ObjectId(56eec856472f21af28119fdc) shards: _id : shard1, host : shard1/192.168.3.62:27017,192.168.3.63:27017 _id : shard2, host : shard2/192.168.3.62:27018,192.168.3.63:27018 _id : shard3, draining : true, host : shard3/mongodb_shard3:37017,mongodb_shard3:37027 databases: _id : admin, partition

23、ed : false, primary : config _id : report, partitioned : true, primary : shard2 report.print shard key: _id : 1 chunks: shard1 1 shard2 1 _id : $minKey : 1 - _id : ObjectId(5517aac945ce6df1bdf8a508) on : shard1 t : 2, i : 0 _id : ObjectId(5517aac945ce6df1bdf8a508) - _id : $maxKey : 1 on : shard2 t :

24、 2, i : 1 _id : screen, partitioned : true, primary : shard2 _id : search, partitioned : true, primary : shard2 _id : traffice, partitioned : true, primary : shard2 _id : wifi, partitioned : true, primary : shard2 _id : nagios, partitioned : true, primary : shard2 nagios.last_primary_server shard ke

25、y: _id : 1 chunks: shard2 1 _id : $minKey : 1 - _id : $maxKey : 1 on : shard2 t : 1, i : 0 _id : office, partitioned : true, primary : shard1 office.guard shard key: _id : 1 chunks: shard2 1 shard1 1 _id : $minKey : 1 - _id : ObjectId(554dc72f45ce6df1be127ddc) on : shard2 t : 2, i : 0 _id : ObjectId

26、(554dc72f45ce6df1be127ddc) - _id : $maxKey : 1 on : shard1 t : 2, i : 1 _id : receivereceiptdata, partitioned : true, primary : shard2 _id : test, partitioned : false, primary : shard2 _id : app, partitioned : false, primary : shard2 _id : ibeacon, partitioned : false, primary : shard2 _id : leadvid

27、eo, partitioned : false, primary : shard2 _id : parking, partitioned : false, primary : shard2 _id : pos, partitioned : false, primary : shard2 _id : pv, partitioned : false, primary : shard1 _id : im, partitioned : false, primary : shard2 _id : queue, partitioned : false, primary : shard2 _id : rec

28、eiveposinfodata, partitioned : false, primary : shard2 _id : db, partitioned : false, primary : shard2 _id : ibeancon, partitioned : false, primary : shard2 看到还有shard3的信息,再移除remove一次试试看:mongos db.runCommand( removeShard : shard3 ); msg : removeshard completed successfully, state : completed, shard : shard3, ok : 1mongos 再查看Shard信息,没有了shard3的信息了mongos db.printShardingStatus();- Sharding Status - sharding version:

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

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