1创建replica set的配置server
如果使用配置文件,设置 sharding.clusterRole to configsvr,replication.replSetName 为控制server的名称。
2连接到一个配置server
mongo –host –port
3初始化rs
rs.initiate(
{
_id: “”,
configsvr: true,
members: [
{ _id : 0, host : “cfg1.example.net:27017” },
{ _id : 1, host : “cfg2.example.net:27017” },
{ _id : 2, host : “cfg3.example.net:27017” }
]
}
)
4创建分片replica set
在分片的控制文件中设置下面的参数
sharding:
clusterRole: shardsvr
replication:
replSetName:
5启动 连接到rs中的一个成员
6初始化shared rs
rs.initiate(
{
_id : ,
members: [
{ _id : 0, host : “s1-mongo1.example.net:27017” },
{ _id : 1, host : “s1-mongo2.example.net:27017” },
{ _id : 2, host : “s1-mongo3.example.net:27017” }
]
}
)
7mongos的配置文件中,需要设置参数:
sharding:
configDB: /cfg1.example.net:
搭建sharded cluster
最新推荐文章于 2022-09-04 17:18:21 发布