Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

3.0.2 → 3.2.12 Sharded Cluster upgrade

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Preliminary preparation:

1) version 3.2.12 is ready

2) during the upgrade process, make sure that client will not modify the collection metadata. For example, you cannot do the following:

Sh.enableSharding ()

Sh.shardCollection ()

Sh.addShard ()

Db.createCollection ()

Db.collection.drop ()

Db.dropDatabase ()

Any operation that creates a database

Any other operation that modifies the cluster metadata in any way.

3) close balancer

4) back up the config database

Steps: 1. Close balancermongos > db.setBalancerState (false)

2. Upgrade shards

Upgrade one of the Secondary members

Close the mongod instance and replace the 3.0command with 3.2command

Restart the member. Wait for the status in the member cluster to be SECONDARY, and then upgrade the second Secondary

Step Down primary node.

When rs.status () shows that the master node is already another member of the shard, it starts to upgrade the master node of the stepped-down (at this time, only the role is Secondary)

Close the mongod instance and replace the 3.0command with 3.2command

Restart

3. Upgrade config server

There is a sequence of config server upgrades. If you start the config server specified by mongos in the following order

/ / mongod_config.confsharding: configDB: db-test01:20001,db-test02:20001,db-test03:20001

Then, the order of the upgrade is: db-test03 → db-test02 → db-test01

Close db-test03 config server and replace 3. 0 commands with 3. 2

Launch version 3.2 of config server, specifying configsvr and port

Start using the command line

Mongod-configsvr-port 20001-dbpath / data/mongodb/config

Start using the configuration file

Sharding: clusterRole: configsvrnet: port: 20001storage: dbpath: / data/mongodb/config

Start other configDB:db-test02 and db-test01 repeatedly in turn

4. Upgrade mongos instance

Out of order. Replace version 3.2 of mongos and restart (a mongos for replacement)

When shutting down mongos, the program will report an error. Because the mongos is closed, the current connection will be disconnected, and then the mongos that the program attempts to connect to will not be connected to other mongos (for example, there are multiple mongos nodes and the program configuration accesses multiple mongos), without affecting the business.

5. Open balancermongos > db.setBalancerState (true)

During the upgrade process, use a script to write one piece of data to the database every second. Observe the writing of data

/ / error message WriteResult ({"nInserted": 0, "writeError": {"code": 94, "errmsg": "Request contains sharding metadata, but the server has not been made sharding aware."}})

Possible reason: stepDown shuts down the node without switching to another node.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report