Manually update dhis2 database and java on LXC

Dear community,

Following these steps, we had configured the Dhis2 server with LXC containers for two years. GitHub - bobjolliffe/dhis2-tools-ng: Next generation dhis2-tools.

On this server, we now want to update the war file, the database, and Java 11. Please let me know if this is feasible. If yes then how can we do that.
Also, what if we want to add postgres extension btree_gin and pg_trgm along with postgis.

Thanks

Hi @MohinderS

Welcome back to the community. Many in the community have experience with servers so hopefully you’ll get a complete answer from your fellow community members.

May I ask what version of dhis2 are you upgrading from and to which version?

Thanks!

Dear @Gassim,

Thanks for your response.

Currently we have two applications 2.34 and version 2.36 on different servers. We want to update to version 2.38.

Thanks

1 Like

Hello there,

Can anyone guide me please.

Thanks

1 Like

Mohinder,

I will recommend you do the following rather than doing it manually:

  1. creating backups of the database or databases.
  2. Make sure to document all the additional apps you have installed.
  3. Run ./delete_all.sh to remove all containers.
  4. Proceed to git pull the new dhis2-tool-ng version,
  5. Verify the lines again in configs/containers.json to reflect your fqdn, email, and tz:
  6. Run sudo ./lxd_setup.sh to set up the main instances monitor, postgres, and proxy
  7. Run ‘sudo ./ssl_setup.sh’
    5, Execute the commands to create your instance again, and then restore the databases.

Please note: The script will automatically include all the new Postgres extensions that you’ve previously listed.

2 Likes

Thanks @Gerald_Thomas for your response.
Sure, We’ll follow up the given steps.

1 Like

You can also try out the newly developed dhis2-server-tools, which are based on Ansible. However, please follow Gerald’s instructions closely. We have a video recording of one of our Thursday server admin calls that you might find helpful:

dhis2 setup with dhis2-server-tools

1 Like

Thanks @tkipkurgat , its very helpful.
One time setup is fine, but will face issue while updating the current dhis2 and package versions.

1 Like

To ensure a smooth upgrade of your entire stack, the recommended approach would be to create a database backup first. Once the backup is secure, you can proceed with deleting the existing components and then build the stack anew. While you could perform these tasks manually, it might become more complex. It’s best to handle the database upgrade first and then proceed with upgrading the DHIS2 instance. This way, you can minimize any potential risks and ensure a seamless upgrade process.

Manually upgrading database
Here are some general recommendations and steps to follow when upgrading your PostgreSQL database, specifically to version 13, which has been tested with DHIS2:

  1. Backup your database: Take a complete backup of your existing database to ensure you have a copy of the data in case anything goes wrong during the upgrade process. Test the backup to ensure it works fine and consider saving it offsite as a fallback option

  2. Create a new database container: Set up a new database container running PostgreSQL 13 on your server. Make sure your storage can accommodate running two databases in parallel.

  3. Plan for downtime: Prepare for the required downtime during the upgrade process. Inform users and stakeholders about the scheduled maintenance window and the expected duration of the upgrade.

  4. Disable external connections: Temporarily disable external connections to the database during the upgrade. This prevents unwanted interactions or data inconsistencies while the upgrade is in progress.

  5. Restore the backup: Follow the official PostgreSQL documentation or upgrade guides to perform the upgrade. Install the new version, migrate the data, and configure the updated database by restoring the backup you created earlier.

  6. Connect your DHIS2 instance: Once the database is upgraded, connect your DHIS2 instance to the new database.

  7. Test and validate: Thoroughly test the functionality and performance of your applications against the upgraded database. Validate that all critical operations are functioning as expected.

  8. You can easily create the btree_gin and pg_trgm extensions by executing the following SQL commands:
    CREATE EXTENSION IF NOT EXISTS btree_gin;
    CREATE EXTENSION IF NOT EXISTS pg_trgm;

These steps should help guide you through the upgrade process. Make sure to consult the official PostgreSQL documentation and any relevant upgrade guides specific to your environment for detailed instructions and best practices.

To manually upgrade your dhis2 instance, you can follow these steps:

  1. Access the LXD container by executing the following command:

    lxc exec dhis bash
    
  2. Stop Tomcat:

    systemctl stop tomcat8/9
    
  3. Remove Java 8 and install Java 11:

    apt-get remove openjdk-8-jre
    apt-get install openjdk-11-jre
    
  4. Delete the current dhis2 app and deploy the new one. You can use the dhis2-deploy-war script for this:

    dhis2-deploy-war /path/to/your/new/war/file.war
    
  5. Start tomcat
    systemctl start tomcat8/9

These steps will help you manually upgrade your dhis2 instance to the latest version.

2 Likes

Once again a big thanks for your response. :+1:

1 Like