时间:2021-07-01 10:21:17 帮助过:34人阅读
mongo -port 47017 |
---|
rs.initiate({_id:"shard2RS",members:[{_id:1,host:"192.168.141.202:47017",priority:2},{_id:2,host:"192.168.141.201:47017"},{_id:3,host:"192.168.141.203:47017"}]}) |
---|
同上完成端口57017配置
mongo -port 17017 |
---|
>use admin >db.runCommand({"addShard":"shard1RS/192.168.141.201:37017" ,"maxsize":1024}) >db.runCommand({"addShard":"shard2RS/192.168.141.202:47017" ,"maxsize":1024}) >db.runCommand({"addShard":"shard3RS/192.168.141.203:57017" ,"maxsize":1024}) |
---|
>use admin --对库hdctest开启分片 >db.runCommand({"enablesharding":"hdctest"}) --对库hdctest下的表person按字段ID配置hash分库算法 >db.runCommand({"shardcollection":"hdctest.person","key":{_id:‘hashed‘}}) |
---|
注意:登陆从库查看数据信息的时候,可能会报:
not master and slaveOk= false,code=13435 |
---|
执行:
db.getMongo().setSlaveOk() |
---|
monodb分片集群部署
标签:127.0.0.1 option ons group host server1 node 设计 beat