測試環境vue
四臺測試服務器10.151.151.150:27017(主節點),10.151.151.151:27017(從節點),10.151.151.152:27018(從節點),10.151.151.152:27017(仲裁節點),10.151.151.143:30000(mongos),10.151.151.143:10000(configserver)mongodb
1.首先創建副本集,按照上邊的節點創建服務器
創建過程(略)測試
2.其次創建configserverserver
在143服務器上開啓mongos服務route
/media/mongo/mongodb/bin/mongod --configsvr --port 10000 --dbpath /media/mongo/configdata --fork --logpath /media/mongo/configlog/config.log --directoryperdbgdb
3.創建mongosdb
./mongos --port 30000 --configdb 10.151.151.143:10000 --fork --logpath /media/mongo/route.log --chunkSize 100di
4.添加副本集mongod
進入mongos
./mongo 10.151.151.143:30000
db.runCommand({addshard:"rep1/10.151.151.150:27017,10.151.151.151:27017,10.151.151.152:27017,10.151.151.152:27018"})
若是出現錯誤:can't find a shard to put new db on
切換爲主庫
use admin
再運行分片
運行成功以後,能夠在vue中進行測試