In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
With the growth of business, MongoDB can change a collection that was not sharded into a sharding collection, but it is important to note that once shard key is specified, it cannot be changed directly. Here are the specific steps from adding shard server to shard key
1) add shard server
Add context:
1.1) insufficient data storage directory 1.2) unable to meet the current production write operations 1.3) too many chunk
3) change the collection into a fragmented collection
The key to add a part needs to create an index, otherwise an error please create an index that starts with the shard key before sharding will be reported.
According to the above error, you need to create an index on the shard key. The index should be built under the corresponding library. If you build it under the admin library of mongos, you will get an error: "errmsg": "{configs1/10.9.33.70:26017,10.9.161.65:26017:\" result without error message returned: {}\ "}".
4) migrate data manually
If balance is enabled, the data will be broken up automatically. If it is not enabled, you need to manually move the data for the first time:
5) Delete the sharding of the sharding collection
Sh.setBalancerState (true); ensure that balance is enabled before the data on the deleted shard is automatically migrated to other shards. Draining ": true,-- data is being migrated.
This command can be repeated to see the status of the migration, and the remaining field indicates the number of blocks remaining
6) delete the main shard that is not sliced
If the database is not shredded, the database will select a shard as the primary shard. The "primary": "mg-test-shard01" display in Db.collection.stats () is the main shard. To delete this master shard, you need to change the collection master shard to another shard before deleting the master shard.
Click (here) to collapse or open
Db.runCommand ({movePrimary: "db_name", to: "new_shard"}) db.runCommand ({removeshard: "mg-test-shard01/10.9.161.65:27019,10.9.33.70:27019"})
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.