How upgrade MonogDB Community on AKS
Comment upgrade Mongodb Community sur son AKS
Here we’ll look at how to upgrade Mongodb Community from 4.4.10 to 7.0.0 . No matter how hard I searched, I couldn’t find anything to help me, so I might as well help those who will have to deal with it!
Mongodb Community
- Let’s start with a simple deployment, with one user and one database :
apiVersion: mongodbcommunity.mongodb.com/v1kind: MongoDBCommunitymetadata: name: my-mongo namespace: mongospec: additionalMongodConfig: storage.wiredTiger.engineConfig.journalCompressor: zlib members: 3 security: authentication: ignoreUnknownUsers: true modes: - SCRAM tls: enabled: false statefulSet: spec: template: spec: containers: - name: mongod resources: limits: cpu: '3' memory: 4Gi requests: cpu: '2' memory: 2Gi - name: mongodb-agent resources: limits: cpu: '0.5' memory: 512M requests: cpu: '0.2' memory: 200M type: ReplicaSet users: - name: admin db: admin scramCredentialsSecretName: my-scram-admin passwordSecretRef: name: admin-password roles: - name: clusterAdmin db: admin - name: userAdminAnyDatabase db: admin - name: dev-db db: dev-db scramCredentialsSecretName: my-scram-dev passwordSecretRef: name: dev-db-password roles: - name: readWrite db: dev-db version: 4.4.10 featureCompatibilityVersion: '4.4'Here there are 2 scenarios: in the first, you have this
featureCompatibilityVersionin youryamland in this case bravo, if not you must add it as in the example above.Access the
primarypod, then connect to the database :
mongo -u admin -p PASSWORD --authenticationDatabase admin- Once in the database, place these commands :
# passer en admin use admin
# Verifier le eatureCompatibilityVersion db.adminCommand({getParameter: 1,featureCompatibilityVersion: 1})If all goes well, you should get a result that says :
cspell:disable >cspell:enable >Terminal window {"featureCompatibilityVersion" : {"version" : "4.4" # we're on the right version},"ok" : 1,"$clusterTime" : {"clusterTime" : Timestamp(1692709763, 3),"signature" : {"hash" : BinData(0,"G2h/IOKY+TIMtryV9dDkEt2rlkw="),"keyId" : NumberLong("7263035781982191620")}},"operationTime" : Timestamp(1692709763, 3)}If you get the wrong result, just place this command and test again:
cspell:disable >cspell:enable >Terminal window db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } )Now that the
cspell:disable >featureCompatibilityVersioncorresponds to the mongodb version, you can perform theupgrade. Just change the versions :cspell:disable >version: 5.0.0featureCompatibilityVersion: '5.0'
IMPORTANT NOTE: to upgrade from version 4.4.10 to 7.0.0, for example, you must go through the intermediate major releases, i.e. 4.4.10->5.0.0->6.0.9->7.0.0.
- Wait for all pods to redeploy, then repeat step 4 to check that the mongo version corresponds to the
featureCompatibilityVersionversion, otherwise repeat step 6.
IMPORTANT NOTE: for the
featureCompatibilityVersion, here are the versions to use:4.4,5.0,6.0and7.0.
Conclusion
Now you can upgrade your mongodb without any featureCompatibilityVersion problems.