|
1 | 1 | = Upgrade MongoDB |
2 | 2 | :page-platform: Server 4.9, Server Admin |
3 | | -:page-description: Learn how to upgrade MongoDB up to v4.4.15 in an installation of CircleCI server 4.9. |
| 3 | +:page-description: Learn how to upgrade MongoDB up to v7.0.15 in an installation of CircleCI server 4.9. |
4 | 4 | :experimental: |
5 | 5 |
|
6 | | -MongoDB is a database service used by CircleCI server. This page describes how to upgrade MongoDB to version `4.4.15`. |
| 6 | +MongoDB is a database service used by CircleCI server. This page describes how to upgrade MongoDB from version `3.6.22` to `7.0.15`. |
7 | 7 |
|
8 | 8 | MongoDB `3.6.22` is shipped with CircleCI server 4.9. |
9 | 9 |
|
10 | | -[#prerequisites] |
11 | | -== Prerequisites |
| 10 | +[#upgrade-mongodb-to-4.4] |
| 11 | +== Upgrade MongoDB to 4.4 |
12 | 12 |
|
13 | | -* Ensure backups have been taken. You will need a backup of MongoDB to restore to in case anything goes wrong during the upgrade progress |
14 | | -* You are prepared to modify the `values.yaml` |
15 | | -* `helm upgrade` will work from your system to upgrade the cluster |
16 | | -* MongoDB root password is available |
| 13 | +[#prerequisites-4.4] |
| 14 | +=== Prerequisites |
17 | 15 |
|
18 | | -[#script-upgrade] |
19 | | -== Scripted upgrade |
20 | | -We have created a shell script which may be used to upgrade your cluster's MongoDB instance link:https://github.com/CircleCI-Public/server-scripts/tree/main/upgrade-mongo-to-4.4[here]. |
21 | | -If you wish, you may use the following instructions to manually upgrade your cluster's MongoDB |
| 16 | +* Ensure backups have been taken. You need a backup of MongoDB to restore in case anything goes wrong during the upgrade progress. |
| 17 | +* You are able to modify your `values.yaml` file. |
| 18 | +* `helm upgrade` works from your system to upgrade the cluster. |
| 19 | +* Your MongoDB root password is available |
22 | 20 |
|
23 | | -[#manual-upgrade] |
24 | | -== Manual upgrade |
| 21 | +[#script-upgrade-4.4] |
| 22 | +=== Scripted upgrade |
| 23 | +We have created a shell script that you can use to upgrade your cluster's MongoDB instance link:https://github.com/CircleCI-Public/server-scripts/tree/main/upgrade-mongo-to-4.4[here]. |
25 | 24 |
|
26 | | -=== 1. Upgrade from MongoDB 3.6 to 4.0 |
| 25 | +Alternatively, you can use the following instructions to manually upgrade your cluster's MongoDB: |
| 26 | + |
| 27 | +[#manual-upgrade-4.4] |
| 28 | +=== Manual upgrade |
| 29 | + |
| 30 | +==== 1. Upgrade from MongoDB 3.6 to 4.0 |
27 | 31 |
|
28 | 32 | . Your `values.yaml` should contain the following snippet: |
29 | 33 | + |
30 | | -```yaml |
| 34 | +[source,yaml] |
| 35 | +---- |
31 | 36 | mongodb: |
32 | 37 | image: |
33 | 38 | tag: 3.6.22-debian-9-r38 |
34 | | -``` |
| 39 | +---- |
35 | 40 | + |
36 | 41 | To begin the upgrade process, change the tag to `4.0.27-debian-9-r118`: |
37 | 42 | + |
38 | | -```yaml |
| 43 | +[source,yaml] |
| 44 | +---- |
39 | 45 | mongodb: |
40 | 46 | image: |
41 | 47 | tag: 4.0.27-debian-9-r118 |
42 | | -``` |
| 48 | +---- |
43 | 49 |
|
44 | 50 | . Run `helm upgrade` to update your installation. |
45 | 51 |
|
46 | 52 | . Once the `helm upgrade` has completed and MongoDB has rolled, you will need to `exec` into the pod (with the root password handy) to modify the compatibility version. (Be sure to replace `<password>` with your MongoDB root password.) |
47 | 53 | + |
48 | | -```bash |
49 | | -kubectl exec -it mongodb-0 -- mongo -u root -p <password> |
| 54 | +[source,console] |
| 55 | +---- |
| 56 | +$ kubectl exec -it mongodb-0 -- mongo -u root -p <password> |
50 | 57 | db.adminCommand( { setFeatureCompatibilityVersion: "4.0" } ) |
51 | | -``` |
| 58 | +---- |
52 | 59 |
|
53 | 60 | . You should get a `{ "ok" : 1 }` response from Mongo. Exit out of the MongoDB shell and pod. |
54 | 61 |
|
55 | | -=== 2. Upgrade from MongoDB 4.0 to 4.2 |
| 62 | +==== 2. Upgrade from MongoDB 4.0 to 4.2 |
56 | 63 |
|
57 | 64 | . Change the tag to `4.2.21-debian-10-r8`: |
58 | 65 | + |
59 | | -```yaml |
| 66 | +[source,yaml] |
| 67 | +---- |
60 | 68 | mongodb: |
61 | 69 | image: |
62 | 70 | tag: 4.2.21-debian-10-r8 |
63 | | -``` |
| 71 | +---- |
64 | 72 |
|
65 | 73 | . Run `helm upgrade` to update your installation. |
66 | 74 |
|
67 | 75 | . Once the `helm upgrade` has completed and MongoDB has rolled, you will need to `exec` into the pod (with the root password handy) to modify the compatibility version. (Be sure to replace `<password>` with your MongoDB root password.) |
68 | 76 | + |
69 | | -```bash |
70 | | -kubectl exec -it mongodb-0 -- mongo -u root -p <password> |
| 77 | +[source,console] |
| 78 | +---- |
| 79 | +$ kubectl exec -it mongodb-0 -- mongo -u root -p <password> |
71 | 80 | db.adminCommand( { setFeatureCompatibilityVersion: "4.2" } ) |
72 | | -``` |
| 81 | +---- |
73 | 82 |
|
74 | 83 | . You should get `{ "ok" : 1 }` again. Exit out of the shell and pod. |
75 | 84 |
|
76 | | -=== 3. Upgrade from MongoDB 4.2 to 4.4 |
| 85 | +==== 3. Upgrade from MongoDB 4.2 to 4.4 |
77 | 86 |
|
78 | 87 | . Change the tag one more time to `4.4.15-debian-10-r8`: |
79 | 88 | + |
80 | | -```yaml |
| 89 | +[source,yaml] |
| 90 | +---- |
81 | 91 | mongodb: |
82 | 92 | image: |
83 | 93 | tag: 4.4.15-debian-10-r8 |
84 | | -``` |
| 94 | +---- |
85 | 95 |
|
86 | 96 | . Run `helm upgrade` to update your installation. |
87 | 97 |
|
88 | 98 | . Once the `helm upgrade` has completed and MongoDB has rolled, you will need to `exec` into the pod (with the root password handy) to modify the compatibility version. (Be sure to replace `<password>` with your MongoDB root password.) |
89 | 99 | + |
90 | | -```bash |
91 | | -kubectl exec -it mongodb-0 -- mongo -u root -p <password> |
| 100 | +[source,console] |
| 101 | +---- |
| 102 | +$ kubectl exec -it mongodb-0 -- mongo -u root -p <password> |
92 | 103 | db.adminCommand( { setFeatureCompatibilityVersion: "4.4" } ) |
93 | | -``` |
| 104 | +---- |
94 | 105 |
|
95 | 106 | . Once you receive `{ "ok" : 1 }`, you have successfully upgraded your MongoDB to 4.4.15. |
| 107 | + |
| 108 | +[#upgrade-mongodb-to-7.0] |
| 109 | +== Upgrade MongoDB to 7.0 |
| 110 | + |
| 111 | +[#prerequisites-7.0] |
| 112 | +=== Prerequisites |
| 113 | + |
| 114 | +* You have completed the `4.4.15` upgrade above. |
| 115 | +* Ensure backups have been taken. You need a backup of MongoDB to restore in case anything goes wrong during the upgrade progress. |
| 116 | +* You are able to modify your `values.yaml` file. |
| 117 | +* `helm upgrade` works from your system to upgrade the cluster. |
| 118 | +* Your MongoDB root password is available. |
| 119 | + |
| 120 | +[#script-upgrade-7.0] |
| 121 | +=== Scripted upgrade |
| 122 | +We have created a shell script that you can use to upgrade your cluster's MongoDB instance link:https://github.com/CircleCI-Public/server-scripts/tree/main/upgrade-mongo-to-7.0[here]. |
| 123 | + |
| 124 | +Alternatively, you can use the following instructions to manually upgrade your cluster's MongoDB: |
| 125 | + |
| 126 | +[#manual-upgrade-7.0] |
| 127 | +=== Manual upgrade |
| 128 | + |
| 129 | +==== 1. Upgrade from MongoDB 4.4 to 5.0 |
| 130 | + |
| 131 | +. Your `values.yaml` should contain the following snippet: |
| 132 | ++ |
| 133 | +[source,yaml] |
| 134 | +---- |
| 135 | +mongodb: |
| 136 | + image: |
| 137 | + tag: 4.4.15-debian-10-r8 |
| 138 | +---- |
| 139 | ++ |
| 140 | +To begin the upgrade process, change the tag to `5.0.24-debian-11-r20` and update the probes to use `mongosh`: |
| 141 | ++ |
| 142 | +[source,yaml] |
| 143 | +---- |
| 144 | +mongodb: |
| 145 | + image: |
| 146 | + tag: 5.0.24-debian-11-r20 |
| 147 | + livenessProbe: |
| 148 | + enabled: false |
| 149 | + readinessProbe: |
| 150 | + enabled: false |
| 151 | + customLivenessProbe: |
| 152 | + exec: |
| 153 | + command: |
| 154 | + - mongosh |
| 155 | + - --eval |
| 156 | + - "db.adminCommand('ping')" |
| 157 | + initialDelaySeconds: 30 |
| 158 | + periodSeconds: 10 |
| 159 | + timeoutSeconds: 5 |
| 160 | + successThreshold: 1 |
| 161 | + failureThreshold: 6 |
| 162 | + customReadinessProbe: |
| 163 | + exec: |
| 164 | + command: |
| 165 | + - bash |
| 166 | + - -ec |
| 167 | + - | |
| 168 | + mongosh --eval 'db.hello().isWritablePrimary || db.hello().secondary' | grep -q 'true' |
| 169 | + initialDelaySeconds: 5 |
| 170 | + periodSeconds: 10 |
| 171 | + timeoutSeconds: 5 |
| 172 | + successThreshold: 1 |
| 173 | + failureThreshold: 6 |
| 174 | +---- |
| 175 | + |
| 176 | +. Run `helm upgrade` to update your installation. |
| 177 | + |
| 178 | +. Once the `helm upgrade` has completed and MongoDB has rolled, you will need to `exec` into the pod (with the root password handy) to modify the compatibility version. Note that MongoDB 5.0+ uses `mongosh` instead of `mongo`. (Be sure to replace `<password>` with your MongoDB root password.) |
| 179 | ++ |
| 180 | +[source,console] |
| 181 | +---- |
| 182 | +$ kubectl exec -it mongodb-0 -- mongosh -u root -p <password> |
| 183 | +db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } ) |
| 184 | +---- |
| 185 | + |
| 186 | +. You should get an `{ "ok" : 1 }` response from MongoDB. Exit out of the MongoDB shell and pod. |
| 187 | + |
| 188 | +==== 2. Upgrade from MongoDB 5.0 to 6.0 |
| 189 | + |
| 190 | +. Change the tag to `6.0.13-debian-11-r21` while being sure to keep the new `customLivenessProbe` and `customReadinessProbe` parameters.: |
| 191 | ++ |
| 192 | +[source,yaml] |
| 193 | +---- |
| 194 | +mongodb: |
| 195 | + image: |
| 196 | + tag: 6.0.13-debian-11-r21 |
| 197 | +---- |
| 198 | + |
| 199 | +. Run `helm upgrade` to update your installation. |
| 200 | + |
| 201 | +. Once the `helm upgrade` has completed and MongoDB has rolled, you will need to `exec` into the pod (with the root password handy) to modify the compatibility version. (Be sure to replace `<password>` with your MongoDB root password.) |
| 202 | ++ |
| 203 | +[source,console] |
| 204 | +---- |
| 205 | +$ kubectl exec -it mongodb-0 -- mongosh -u root -p <password> |
| 206 | +db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } ) |
| 207 | +---- |
| 208 | + |
| 209 | +. You should get `{ "ok" : 1 }`` again. Exit out of the shell and pod. |
| 210 | + |
| 211 | +==== 3. Upgrade from MongoDB 6.0 to 7.0 |
| 212 | + |
| 213 | +. Change the tag to `7.0.15-debian-12-r2`: |
| 214 | ++ |
| 215 | +[source,yaml] |
| 216 | +---- |
| 217 | +mongodb: |
| 218 | + image: |
| 219 | + tag: 7.0.15-debian-12-r2 |
| 220 | +---- |
| 221 | + |
| 222 | +. Run `helm upgrade` to update your installation. |
| 223 | + |
| 224 | +. Once the `helm upgrade` has completed and MongoDB has rolled, you will need to `exec` into the pod (with the root password handy) to modify the compatibility version (be sure to replace `<password>` with your MongoDB root password.) |
| 225 | ++ |
| 226 | +CAUTION: MongoDB 7.0+ upgrade is one-way and cannot be downgraded. |
| 227 | ++ |
| 228 | +NOTE: MongoDB 7.0+ requires the `confirm: true` parameter. |
| 229 | ++ |
| 230 | +[source,console] |
| 231 | +---- |
| 232 | +$ kubectl exec -it mongodb-0 -- mongosh -u root -p <password> |
| 233 | +db.adminCommand( { setFeatureCompatibilityVersion: "7.0", confirm: true } ) |
| 234 | +---- |
| 235 | + |
| 236 | +. Once you receive `{ "ok" : 1 }``, you have successfully upgraded your MongoDB to 7.0.15. |
0 commit comments