MongoDB学习之旅二十八:MongoDB 新增Shard Server
来源:互联网 发布:欧盟内部贸易数据 编辑:程序博客网 时间:2024/05/22 12:39
1、启动一个新Shard Server 进程
[root@localhost ~]# mkdir /data/shard/s2[root@localhost ~]# /Apps/mongo/bin/mongod --shardsvr --port 20002 --dbpath /data/shard/s2--fork --logpath /data/shard/log/s2.log --directoryperdball output going to: /data/shard/log/s2.logforked process: 67722、配置新Shard Server
[root@localhost ~]# /Apps/mongo/bin/mongo admin --port 40000MongoDB shell version: 1.8.1connecting to: 127.0.0.1:40000/admin> db.runCommand({ addshard:"localhost:20002" }){ "shardAdded" : "shard0002", "ok" : 1 }> printShardingStatus()--- Sharding Status ---sharding version: { "_id" : 1, "version" : 3 }shards:{ "_id" : "shard0000", "host" : "localhost:20000" }{ "_id" : "shard0001", "host" : "localhost:20001" }{ "_id" : "shard0002", "host" : "localhost:20002" } --新增Shard Serverdatabases:{ "_id" : "admin", "partitioned" : false, "primary" : "config" }{ "_id" : "test", "partitioned" : true, "primary" : "shard0000" }test.users chunks:shard0002 2shard0000 21shard0001 21too many chunksn to print, use verbose if you want to force printtest.users_2 chunks:shard0001 46shard0002 1shard0000 45too many chunksn to print, use verbose if you want to force print3、 查看分片表状态,以验证新Shard Server
> use testswitched to db test> db.users_2.stats(){"sharded" : true,"ns" : "test.users_2",……"shard0002" : { --新的Shard Server 已有数据"ns" : "test.users_2","count" : 21848,"size" : 2097408,"avgObjSize" : 96,"storageSize" : 2793472,"numExtents" : 5,"nindexes" : 1,"lastExtentSize" : 2097152,"paddingFactor" : 1,"flags" : 1,"totalIndexSize" : 1277952,"indexSizes" : {"_id_" : 1277952},"ok" : 1}},"ok" : 1}>我们可以发现,当我们新增Shard Server 后数据自动分布到了新Shard 上,这是由MongoDB内部自已实现的。
0 0
- MongoDB学习之旅二十八:MongoDB 新增Shard Server
- Nosql Mongodb之旅(29)—MongoDB新增Shard Server
- MongoDB学习之旅二十九:MongoDB 移除Shard Server
- MongoDB学习之二----模拟shard集群搭建
- MongoDB 分片 (二) Shard
- Nosql Mongodb之旅(30)—MongoDB移除Shard Server
- MongoDB学习之旅十八:索引
- mongodb shard
- mongodb shard
- MongoDB之Shard初步认识
- MongoDB之Shard初步认识
- mongodb 学习笔记 09 -- shard分片
- mongodb之shard集群 balance操作管理
- MongoDB学习之旅二:MongoDB安装及配置
- MongoDB学习之旅二十一:MongoDB Replica Sets
- MongoDB学习之旅二十二:MongoDB Replica oplog
- MongoDB学习之旅二十六:MongoDB Sharding分片
- MongoDB学习之旅二十七:MongoDB 管理维护Sharding
- 在编译FFTW库的时候出现如下错误的解决办法
- Linux内核中的printf的实现
- my.ini(my.cnf)的配置参数详解
- 设置网络打印机
- 《黑马程序员》 文件的深度遍历
- MongoDB学习之旅二十八:MongoDB 新增Shard Server
- 高斯消元
- python Queue
- 老的iPhone项目工程编译只有3.5寸
- state 模式(c++ 实现)
- 《黑马程序员》 properties之程序运行次数限定
- 【仿微盟源码】WeiKuCMS多功能微信营销服务系统
- source insight 实用技巧
- 规范