In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Server architecture: serial number role ip address Note 1 Server 192.168.8.81 (config server) 2 routing 192.168.8.82 (mongos) 3 sharding node 192.168.8.83 (shard) 4 sharding node 192.168.8.84 (shard) server configuration (192.168.8.81):
a. Modify the configuration file:
Vim / etc/mongod.conffork = truepidfilepath = / var/run/mongodb/mongod.pidlogpath = / var/log/mongodb/mongod.logunixSocketPrefix = / var/run/mongodbdbpath = / var/lib/mongodbport=27017configsvr=true
b. Start the service:
Systemctl start mongod routing configuration (192.168.8.82):
a. Modify the configuration file:
Vim / etc / mongod.conffork = truepidfilepath = / var/run/mongodb/mongod.pidlogpath = / var/log/mongodb/mongod.logunixSocketPrefix = / var/run/mongodb#dbpath = / var/lib/mongodb (comment out database) port=27017configdb=192.168.8.81:27017
b. Delete files in the database:
Rm-rf / var/lib/mongodb/*
c. Start the service:
Mongos-f / etc/mongod.conf slicer configuration (192.168.83GP84):
a. Modify the configuration file:
Vim / etc/mongod.conffork = truepidfilepath = / var/run/mongodb/mongod.pidlogpath = / var/log/mongodb/mongod.logunixSocketPrefix = / var/run/mongodbdbpath = / var/lib/mongodb
b. Start the service:
Systemctl start mongod Test:
a. Routing machine (192.168.8.82):
A Mui 1. Enter the terminal: mongo
A Murray 2. Add slicer:
Sh.addShard ("192.168.83VOV 27017") sh.addShard ("192.168.84VOV 27017")
A Murray 3. Check the status of the slicer:
Sh.status ()
A Murray 4. Add a sharding database:
Sh.enableSharding ("testdb")
A Murray 5. Add an index:
Sh.shardCollection ("testdb.user", {name:1,age:1})
A Murray 6. Add test data:
For (I = 1 name:'user'+i,age: (i0), addr:'#'+i}}) {name:'user'+i,age: (i0)
b. Slicer (192.168.8.83GP84):
BMY 1. Enter the terminal:
Mongo
BMY 2. View the sharded data:
Use testdbdb.user.find ()
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.