设为首页 加入收藏

TOP

MongoDB集群架构之分片架构(二)
2018-10-23 00:06:06 】 浏览:847
Tags:MongoDB 集群 架构 分片
.


forked process: 6705


child process started successfully, parent exiting


启动路由服务器节点后需要将三个分片服务器节点加入到这个路由中。


[root@coe2coe data]# mongo  --quiet --port=27217


mongos> sh.addShard("11.1.1.11:27017");


{


"shardAdded" : "shard0000",


"ok" : 1,


"operationTime" : Timestamp(1538403870, 4),


"$clusterTime" : {


"clusterTime" : Timestamp(1538403870, 4),


"signature" : {


"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),


"keyId" : NumberLong(0)


}


}


}


mongos> sh.addShard("11.1.1.11:27018");


{


"shardAdded" : "shard0001",


"ok" : 1,


"operationTime" : Timestamp(1538403879, 3),


"$clusterTime" : {


"clusterTime" : Timestamp(1538403879, 4),


"signature" : {


"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),


"keyId" : NumberLong(0)


}


}


}


mongos> sh.addShard("11.1.1.11:27019");


{


"shardAdded" : "shard0002",


"ok" : 1,


"operationTime" : Timestamp(1538403887, 2),


"$clusterTime" : {


"clusterTime" : Timestamp(1538403887, 2),


"signature" : {


"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),


"keyId" : NumberLong(0)


}


}


}


此时可以查看分片状态:


mongos> sh.status();


--- Sharding Status --- 


  sharding version: {


  "_id" : 1,


  "minCompatibleVersion" : 5,


  "currentVersion" : 6,


  "clusterId" : ObjectId("5bb22c83322f90f844d3defc")


  }


  shards:


        {  "_id" : "shard0000",  "host" : "11.1.1.11:27017",  "state" : 1 }


        {  "_id" : "shard0001",  "host" : "11.1.1.11:27018",  "state" : 1 }


        {  "_id" : "shard0002",  "host" : "11.1.1.11:27019",  "state" : 1 }


  active mongoses:


        "4.0.2-76-g279a1f51b9" : 3


  autosplit:


        Currently enabled: yes


  balancer:


        Currently enabled:  yes


        Currently running:  no


        Failed balancer rounds in last 5 attempts:  0


        Migration Results for the last 24 hours: 


                No recent migrations


  databases:


        {  "_id" : "config",  "primary" : "config",  "partitioned" : true }


三个分片节点27017,27018,27019均处于正常状态。至此一个正常的分片环境基本搭建完毕。


对数据库启用分片功能


在实际应用分片前,首先应该对含有需要分片的集合所在的数据库启用分片功能。在启用分片功能之后可以对其中的集合进行分片的实际操作。



图5


3.范围分片


对t1集合进行范围分片,分片字段为shard。



图6


4.哈希分片


对t1表进行哈希分片,分片字段为shard。



图7


向t2集合中插入一些数据:


mongos> db.t2.find();


{ "_id" : ObjectId("5bb2341df116ff2bb6014822"), "name" : "a", "shard" : 2 }


{ "_id" : ObjectId("5bb2341ff116ff2bb6014823"), "name" : "a", "s

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 2/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇hql优化教程 下一篇MySQL递归查询_函数语法检查_GROU..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目