• Document Up to Date

Upgrading MongoDB

Crafter Profile and Social version 4.0.0 and later uses MongoDB v4.0.28 in the install. When upgrading your 3.1.x install of Crafter Profile and Social to 4.0.0 and later, MongoDB will need to be manually upgraded.

This section describes how to upgrade MongoDB in your Crafter Profile and Social version 3.1.x installed on a server.

Please read through the upgrade instructions here first. The steps for upgrading MongoDB in your Crafter Profile and Social install follows almost exactly the same steps as listed in that document.

Important

Remember to manually shut down and backup CrafterCMS before beginning your upgrades!

Upgrading 3.1.x -> 4.0.x (from MongoDB 3.x)

  1. Download CrafterCMS version 4.0.x, and extract the files.

  2. Upgrade using the upgrade-target.sh script from your newly extracted files. First, we’ll need to set MONGODB_HOME so that the backup script will run with the mongod version 3.4.4 in the old installation before running the upgrade-target.sh:

    Set MONGODB_HOME and Run the upgrade-target script from the newly extracted files
    > MONGODB_HOME=/path/of/3.1.x/install/bin/mongodb ./upgrade-target.sh /path/of/install/to/be/upgraded
    ...
    [o] Overwriting file apache-tomcat/LICENSE with the new release version
    [o] Overwriting file apache-tomcat/BUILDING.txt with the new release version
    ========================================================================
    Upgrade completed
    ========================================================================
    !!! Please read the release notes and make any necessary manual changes, then run the post upgrade script:
    
  3. Manually upgrade MongoDB from version 3.4.4 to version 4.0.280. We need to upgrade from each release version and run the setFeatureCompatibilityVersion command against the admin database.

    Please see https://www.mongodb.com/docs/manual/release-notes/4.0-upgrade-standalone/ for more information on upgrading MongoDB.

    Download and extract the following MongoDB versions available from https://www.mongodb.com/try/download/community:

    Run mongod from each release version /extracted/location/of/mongodb-version-to-be-upgraded-to/bin/mongod starting from the oldest one:

    Run mongod from MongoDB version to be upgraded to
    $ /extracted/location/of/mongodb-linux-x86_64-3.6.23/bin/mongod --dbpath=/path/of/3.1.x/install/data/mongodb --directoryperdb --journal --port 27020
    ...
    2023-12-20T02:38:20.546-0500 I CONTROL  [initandlisten] db version v3.6.23
    2023-12-20T12-03T02:38:20.546-0500 I CONTROL  [initandlisten] git version: d352e6a4764659e0d0350ce77279de3c1f243e5c
    2023-12-20T02:38:20.546-0500 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
    2023-12-20T02:38:20.546-0500 I CONTROL  [initandlisten] allocator: system
    ...
    2023-12-20T02:38:21.687-0500 I NETWORK  [initandlisten] listening via socket bound to /tmp/mongodb-27020.sock
    2023-12-20T02:38:21.687-0500 I NETWORK  [initandlisten] waiting for connections on port 27020
    2023-12-20T02:38:21.687-0500 I STORAGE  [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: fee195e0-b337-498f-8ad9-1c410748bce1
    

    Watch the logs and wait for the message waiting for connections on port 27020, then login as user admin in MongoDB in your 3.1.x install by running the command ./mongosh mongodb://localhost:27020/admin and finally set the compatibility version using the command db.adminCommand( { setFeatureCompatibilityVersion: "{version}" } )

    Set compatibility version from /path/of/3.1.x/install/bin/mongodb/bin/
    > ./mongosh mongodb://localhost:27020/admin
    Current Mongosh Log ID:  659511008267cb24aff1427e
    Connecting to:           mongodb://localhost:27020/admin?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.8.0
    Using MongoDB:           3.6.23
    Using Mongosh:           1.8.0
    admin> db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )
    { ok: 1 }
    admin>exit
    >
    

    Repeat the steps above for all the other versions of MongoDB downloaded in ascending order of version, e.g. run mongod version 4.0.28, then set the feature compatibility version to 4.0.

  4. Before starting CrafterCMS, you’ll need to configure the installation root directory to use Java version 17. Remember to read the release notes or any relevant upgrade articles and make any necessary manual changes before running the post-upgrade.sh` script as described next

  5. Run the post-upgrade.sh script. This will:

    • Remove old data/indexes-es directory (old indexes are not usable by OpenSearch)

    • Start CrafterCMS and ask for signal to continue

    • Once started and CrafterCMS is up (including UM execution), let the post-upgrade continue by typing Y:

      Please make sure Crafter has started successfully before continuing
      > Continue? [(Y)es/(N)o]:
      
    • Post-upgrade will continue to trigger the reindex of all targets by calling the Deployer API /api/1/target/deploy-all

  6. Your install is now upgraded and you may login to Studio to check the version.