Upgrading X-Road Metrics packages when upgrading Ubuntu 20.04 to 22.04
This document describes the steps required to upgrade X-Road Metrics packages on Ubuntu 20.04 LTS host to Ubuntu 22.04.
Refer to Security Server Ubuntu 20.04 to 22.04 In-place Upgrade. as a base document for in-place upgrades.
Preparations
Review the Ubuntu release notes and upgrade instructions: Jammy Jellyfish Release Notes
Update all packages to the latest versions:
sudo apt update && sudo apt full-upgrade
Recommended: Make sure that you have an up-to-date backup (or virtual machine snapshot) of the server and database
For MongoDB database backup see Backup Methods for a Self-Managed Deployment - Database Manual - MongoDB Docs
For PostgresSQL database backup see Chapter 25. Backup and Restore
Gradually migrate MongoDB 4.4 to 5.0, then to 6.0 as Upgrade a Standalone to 6.0 - Database Manual - MongoDB Docs suggests. Ensure all needed roles are given to MongoDB admin user:
mongo
use admin
db.auth(“root”)
db.grantRolesToUser("root", [{ role: "clusterMonitor", db: "admin" }])
db.grantRolesToUser("root", [{ role: "clusterAdmin", db: "admin" }])
Upgrade MongoDB from 4.4 to 5.0 Upgrade a Standalone to 5.0 - Database Manual - MongoDB Docs
Check Feature Compatibility Version:
mongo
use admin
db.auth(“root”)
db.adminCommand({getParameter: 1, featureCompatibilityVersion: 1})
# should return { "featureCompatibilityVersion" : { "version" : "4.4" }, "ok" : 1 }
Edit
/etc/apt/sources.list
and comment out the repository setting for Ubuntu 20.04 and MongoDB 4.4:
# deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse
Add key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv b00a0bd1e2c63c11
Add repo for MongoDB 5.0:
sudo apt-add-repository "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse"
sudo apt update
Stop MongoDB:
sudo systemctl stop mongod.service
Upgrade MongoDB to 5.0:
sudo apt upgrade
Start MongoDB:
sudo systemctl start mongod.service
Set Feature Compatibility Version:
mongo
use admin
db.auth(“root”)
db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )
Upgrade MongoDB from 5.0 to 6.0 Upgrade a Standalone to 6.0 - Database Manual - MongoDB Docs
Edit
/etc/apt/sources.list
and comment out the repository setting for Ubuntu 20.04 and MongoDB 5.0:
# deb [arch=amd64,arm64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse
Add key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 6a26b1ae64c3c388
Add repo for MongoDB 6.0:
sudo apt-add-repository "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/6.0 multiverse"
sudo apt update
Stop MongoDB:
sudo systemctl stop mongod.service
Upgrade MongoDB to 6.0:
sudo apt upgrade
Start MongoDB:
sudo systemctl start mongod.service
Set Feature Compatibility Version:
mongosh
use admin
db.auth(“root”)
db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } )
Recommended: mark xroad-metrics-*
deb packages as hold to prevent it from being updated/removed
echo "xroad-metrics-collector hold" | sudo dpkg --set-selections
echo "xroad-metrics-corrector hold" | sudo dpkg --set-selections
echo "xroad-metrics-anonymizer hold" | sudo dpkg --set-selections
echo "xroad-metrics-networking hold" | sudo dpkg --set-selections
echo "xroad-metrics-opendata hold" | sudo dpkg --set-selections
Optional: mark MongoDB deb packages as hold to prevent them from being updated/removed
echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-database hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-mongosh hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
Stop X-Road Metrics services
Systemd services:
sudo systemctl list-units "xroad-metrics-*"
sudo systemctl stop xroad-metrics-corrector
Cron-based tasks:
sudo service cron stop
Upgrading Ubuntu 20.04 to 22.04
Install
update-manager-core
if it is not already installed.Make sure the Prompt line in
/etc/update-manager/release-upgrades
is set to 'lts'Launch the upgrade tool with the command
sudo do-release-upgrade
Follow the on-screen instructions.
When the upgrade is finished, reboot when prompted.
Upgrade PostgreSQL database
Upgrade MongoDB
If MongoDB deb packages were marked to hold:
echo "mongodb-org install" | sudo dpkg --set-selections echo "mongodb-org-database install" | sudo dpkg --set-selections echo "mongodb-org-server install" | sudo dpkg --set-selections echo "mongodb-mongosh install" | sudo dpkg --set-selections echo "mongodb-org-mongos install" | sudo dpkg --set-selections echo "mongodb-org-tools install" | sudo dpkg --set-selections
Add repository for MongoDB 6.0 on Ubuntu 22.04:
sudo apt-add-repository "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse"
sudo apt update
Stop MongoDB:
sudo systemctl stop mongod.service
Do upgrade:
sudo apt upgrade
Start MongoDB:
sudo systemctl start mongod.service
Upgrade X-Road Metrics packages
Remove package holding:
echo "xroad-metrics-collector install" | sudo dpkg --set-selections
echo "xroad-metrics-corrector install" | sudo dpkg --set-selections
echo "xroad-metrics-anonymizer install" | sudo dpkg --set-selections
echo "xroad-metrics-networking install" | sudo dpkg --set-selections
echo "xroad-metrics-opendata install" | sudo dpkg --set-selections
Add apt repository:
sudo apt-add-repository "deb https://artifactory.niis.org/xroad-extensions-release-deb jammy main"
sudo apt update
Upgrade X-Road Metrics packages:
sudo apt upgrade
Start X-Road Metrics services
Systemd services:
sudo systemctl list-units "xroad-metrics-*"
sudo systemctl start xroad-metrics-corrector
Cron-based tasks:
sudo service cron start