Mongodb分片
參考網址
Windows搭建MongoDB分片以及復制集
mongod --port 3000 --shardsvr --replSet rs-a --dbpath “D:\software\MongoDB\data\data\rs-a-0” --logpath “D:\software\MongoDB\data\log\rs-a-0.log”
mongod --port 3001 --shardsvr --replSet rs-a --dbpath “D:\software\MongoDB\data\data\rs-a-1” --logpath “D:\software\MongoDB\data\log\rs-a-1.log”
mongod --port 3002 --shardsvr --replSet rs-a --dbpath “D:\software\MongoDB\data\data\rs-a-2” --logpath “D:\software\MongoDB\data\log\rs-a-2.log”
副本集配置
rs.status()
rs.initiate()
rs.isMaster()
rs.add(“localhost:3001”)
rs.add(“localhost:3002”)
rs.remove(“localhost:3001”)
rs.remove(“localhost:3002”)
rs.add(“172.16.1.9:3001”)
rs.add(“172.16.1.9:3002”)
rs.status()
配置服務器 配置Config——server
mongod --port 27019 --configsvr --replSet rs-conf --dbpath “D:\software\MongoDB\data\data\config0” --logpath “D:\software\MongoDB\data\log\config0.log”
mongod --port 27020 --configsvr --replSet rs-conf --dbpath “D:\software\MongoDB\data\data\config1” --logpath “D:\software\MongoDB\data\log\config1.log”
新開一個視窗 連接27019
rs.initiate()
回車 到RPIMARY
rs.add(“localhost:27020”)
配置路由服務器 注意加上埠號
mongos --port 27088 --configdb rs-conf/localhost:27019,localhost:27020 --logpath “D:\software\MongoDB\data\log\mongos.log”
添加創建的分片
連接時加上mongos的埠號 連接成功會顯示 mongos>
將我們前面創建的分片添加進去,使用命令 mongo --port 27088
登錄mongos,使用sh.addShard添加分片
sh.status() 查看分片的狀態
sh.addShard(“rs-a/172.16.1.9:3000, 172.16.1.9:3001, 172.16.1.9:3002”)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/275857.html
標籤:其他
上一篇:【資料庫原理及應用】經典題庫附答案(14章全)——第一章:資料庫基礎知識
下一篇:SSM框架技術
