In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Mongodb version 3.2.7
Resource division:
192.168.1.11Rose 27017-"config server"
192.168.1.11 27018 Murray-"mongos"
192.168.1.11 27019 "mongod Service"
192.168.1.11 27020 "mongod Service"
Since they are all built on the same machine, a single mode is adopted here. Of course, you can make mongod services into replica sets, and config server can also be used as replica sets, so I won't repeat them here.
Direct posting configuration:
192.168.1.11:27017
Path: / var/log/mongodb/mongod.log
DbPath: / mongodb/data
PidFilePath: / var/run/mongodb/mongod1.pid
Port: 27017
BindIp: 192.168.1.11
Sharding:
ClusterRole: configsvr
Then start config server
Mongod-f / etc/mongod.conf
192.168.1.11 27018 UV-> mongos
# storage:
# dbPath: / mongodb2/data
# journal:
# enabled: true
Comment out the above options, and the following error will occur if you do not comment:
Path: / var/log/mongodb/mongod2.log
PidFilePath: / var/run/mongodb/mongod2.pid
Port: 27018
BindIp: 192.168.1.11
Sharding:
ConfigDB: 192.168.1.11:27017
Then start the service:
Mongos-config mongod.conf
192.168.1.11:27019
Path: / var/log/mongodb/mongod3.log
DbPath: / mongodb3/data
PidFilePath: / var/run/mongodb/mongod3.pid
Port: 27019
BindIp: 192.168.1.11
Sharding:
ClusterRole: shardsvr
Then start the service:
Mongod-f
192.168.1.11:27020
Path: / var/log/mongodb/mongod4.log
DbPath: / mongodb4/data
PidFilePath: / var/run/mongodb/mongod4.pid
Port: 27020
BindIp: 192.168.1.11
Sharding:
ClusterRole: shardsvr
Then start the service:
Mongod-f
Check to see if the port is listening
Then log in to mongos
Mongo-host 192.168.1.11-port 27018
Then add sharding
Then check the sharding status again as shown below:
You can clearly see that two partitions sharding have been added.
Mongos > sh.enableSharding (testdb)-> enable sharding partitions for testdb
Mongos > sh.shardCollection (fullName,key,unique)-> Partition collection
Sh.shardCollection ("huangdb.testcoll", {Age:1,Name:1}): partition sequentially by age and first name
For (iTunes 1)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.