System Update

PostgreSQL

Note

Below is an example of updating PostgreSQL from version 9.6 to version 13.2 and sample commands for CentOS 7. If your environment is different, use the official PostgreSQL documentation

Tip

It is recommended that you use pg_dump and pg_dumpall from a newer version of PostgreSQL

These instructions assume that the current installation is in /usr/local/pgsql and the data area is in /usr/local/pgsql/data. Replace the paths accordingly.

Example of updating PostgreSQL with pg_dumpall:

  1. Create database backup (step can be skipped if backup was done earlier):

    pg_dumpall > outputfile.sql
    
  2. Back up the pg_hba.conf and postgresql.conf configuration files from <POSTGRESQL9.6_HOME>/data.

  3. Stop postgresql-9.6:

    systemctl stop postgresql-9.6
    
  4. Rename the directory if postgresql-9.6 was installed in the default directory:

    mv /usr/local/pgsql /usr/local/pgsql.old
    
  5. Postgresql-13 will be installed from source. Install git:

    yum install git
    
  6. Download the source code from the official repository (the postgres directory will be created automatically in the active directory):

    git clone https://github.com/postgres/postgres
    
  7. Navigate to the created postgres directory and switch to the repository branch with version 13:

    cd postgres/.
    git checkout REL_13_STABLE
    
  8. To ensure correct configuration and builds, install the following:

    yum install readline-devel zlib-devel flex bison uuid-devel libxml2 libxml2-devel systemd systemd-devel
    
  9. Start the configuration:

    ./configure --with-uuid=ossp --with-libxml --with-systemd
    

The additional parameters --with-uid=ossp and --with-libxml are needed to install the necessary extensions later on, the --with-systemd parameter is needed to control the launch of Postgresql via systemctl (described below in step 23).

  1. Run the build: make.

  2. Run autotests under a user account (this functionality does not work under the root account): make check.

  3. Run the install: sudo make install.

  4. Create a directory where the database files will be stored:

    mkdir /usr/local/pgsql/data
    
  5. Assign user rights to this directory:

    chown postgres /usr/local/pgsql/data/
    
  6. Go to the directory:

    cd /usr/local/pgsql/bin
    
  7. Do the following:

    export PATH=/usr/local/pgsql/bin/:$PATH
    export PGDATA=/usr/local/pgsql/data/
    
  8. Under the user account, initialize the database:

    initdb -k -D /usr/local/pgsql/data/
    
  9. Move the saved pg_hba.conf and postgresql.conf configuration files to <POSTGRESQL13_HOME>/data.

  10. Run postgresql13:

    pg_ctl start
    
  11. Install the extensions for the database:

    a. cd .../postgres/contrib
    b. make
    c. make install
    
  12. Restore data from the backup created (example restore with pg_restore):

    /usr/local/pgsql/bin/psql -d postgres -f outputfile.sql
    
  13. Stop postgresql13:

    pg_ctl stop
    
  14. Add the following system file /etc/systemd/system/postgresql-13.service to autorun and control the application using systemctl commands with the contents:

    [Unit]
    Description=PostgreSQL database server
    Documentation=man:postgres(1)
    [Service]
    Type=notify
    User=postgres
    ExecStart=/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data ExecReload=/bin/kill -HUP $MAINPID
    KillMode=mixed
    KillSignal=SIGINT
    TimeoutSec=0
    [Install]
    WantedBy=multi-user.target
    
  15. Perform the following:

    systemctl enable postgresql-13 && systemctl start postgresql-13
    
  16. Check the status:

    systemctl status postgresql-13
    

If the status failed, restart the operating system.

  1. Remove postgresql-9.6 from the autorun:

    systemctl disable postgresql-9.6
    
  2. If necessary, remove postgresql-9.6:

    yum remove pgdg-centos96 postgresql96 postgresql96-server postgresql96-libs postgresql96-devel postgresql96-contrib postgresql96-jdbc
    
  3. Check the version of the installed PostgreSQL:

    postgres --version
    

Further run the database migration from 9.6 to 13:

  1. Stop the service:

    systemctl stop postgresql-9.6
    
  2. Check the ability to update:

    su postgres
    cd /var/lib/pgsql
    /usr/pgsql-13/bin/pg_upgrade --old-bindir=/usr/pgsql-9.6/bin/ -- new-bindir=/usr/pgsql-13/bin/ --old- datadir=/var/lib/pgsql/9.6/data/ --new- datadir=/var/lib/pgsql/13/data/ --check
    
  3. If the response message shows Clusters are compatible, run the migration:

    su postgres
    cd /var/lib/pgsql
    /usr/pgsql-13/bin/pg_upgrade --old-bindir=/usr/pgsql-9.6/bin/ -- new-bindir=/usr/pgsql-13/bin/ --old- datadir=/var/lib/pgsql/9.6/data/ --new- datadir=/var/lib/pgsql/13/data/
    
  4. After successful completion version 9.6 can be removed:

    yum remove pgdg-centos96 postgresql96 postgresql96-server postgresql96-libs postgresql96-devel postgresql96-contrib postgresql96-jdbc postgresql-jdbc
    
  5. Recheck the version of the installed PostgreSQL:

    yum list installed | egrep "postgres|pgdg"
    

Application and Configuration Files

Before you start: make sure that all required backup configuration copies are created.

Note

When copying new libraries it is necessary to delete the old ones, because in some cases when updating the system the old version of the library is used instead of the new one, which causes errors in the system operation

  1. Remove all files from the directories:

    • <TOMCAT_HOME>/work;

    • <TOMCAT_HOME>/temp;

    • <TOMCAT_HOME>/webapps;

  2. Update the configuration files:

  • Copy from <TOMCAT_HOME>/conf/Catalina/localhost distribution to the <UNIDATA_CONF_DIR> directory of the previously backed up universe-backend.xml file. Example command:

    cp <UNIDATA_PACKAGE_DIR>/conf/Catalina/localhost/universe-backend.xml <TOMCAT_HOME>/conf/Catalina/localhost/
    
  • Copy from <TOMCAT_HOME>/conf/universe/ distribution to the <UNIDATA_CONF_DIR>/ directory the backend.properties file you created earlier. Example command:

    cp <UNIDATA_PACKAGE_DIR>/conf/universe/backend.properties <TOMCAT_HOME>/conf/universe/
    
  • In the backend.properties file, comment out the universe.licensing.gpg.license.file parameter to ensure that the license is updated correctly through the system interface. After starting the updated system, you must reactivate the existing license.

  • Copy the current external-routing.xml file from the distribution to the <TOMCAT_HOME>/conf/universe/ directory, or modify it as follows:

    cp <UNIDATA_PACKAGE_DIR>/conf/universe/external-routing.xml <TOMCAT_HOME>/conf/universe/
    
  • If necessary, restore personal configuration settings from file backups.

  1. Copy the contents of the <TOMCAT_HOME>/webapps/ directory and <TOMCAT_HOME>/lib/ directory (WAR application files, libraries) from the installation package using the following commands:

    cp <UNIDATA_PACKAGE>/Tomcat/lib/* <TOMCAT_HOME>/lib/
    cp <UNIDATA_PACKAGE>/Tomcat/webapps/universe-*.war <TOMCAT_HOME>/webapps/
    
  2. Make sure that all required integration files for the project in <TOMCAT_HOME>/universe_integration are up to date. If necessary, use the backup of the directory created earlier.

  3. When upgrading to a new version of PostgreSQL, remove the obsolete standard .lib files. File example: postgresql-13-1200.jdbc41.lib.

  4. Create backups of the configuration files (if they have changed), which are located at addresses:

    • <TOMCAT_HOME>/webapps/universe-backend;

    • <TOMCAT_HOME>/webapps/universe-frontend.

(For example, changes may have been made to the <TOMCAT_HOME>/webapps/universe-frontend/customer.json file)

  1. Remove Elasticsearch indexes:

    $ curl -XDELETE 'http://localhost:9200/_all'
    
  2. Restart Tomcat:

    systemctl restart tomcat
    

Note

The updating procedure must be performed on each cluster node if Universe MDM is installed in a cluster configuration

Apache Tomcat

To upgrade Tomcat from version 7 to version 9:

  1. Stop Tomcat 7 and remove it from the autorun:

    systemctl stop tomcat && systemctl disable tomcat
    
  2. Create a system user:

    useradd -m -U -d /opt/tomcat -s /bin/false tomcat
    
  3. Download and unpack the archive (the current version can be found at the official website. Command example:

    wget https://downloads.apache.org/tomcat/tomcat9/v9.0.48/bin/apache- tomcat-9.0.48.tar.gz
    tar -zxpvf apache-tomcat-9.0.48.tar.gz -C /opt/ (or other necessary directory)
    
  4. Move to /opt/tomcat (or other required directory):

    mv apache-tomcat-9.0.48 tomcat-9
    
  5. Change the directory owner to tomcat:

    chown -R tomcat: /opt/tomcat-9
    
  6. Create the system module file:

    nano /etc/systemd/system/tomcat.service
    
  7. Write the following into the file:

    [Unit]
    Description=Tomcat 9 servlet container
    After=network.target
    [Service]
    Type=forking
    User=tomcat
    Group=tomcat
    Environment="JAVA_HOME=/usr/lib/jvm/jre" Environment="JAVA_OPTS=Djava.security. egd=file:///dev/urandom" Environment="CATALINA_BASE=/opt/tomcat-9" Environment="CATALINA_HOME=/opt/tomcat-9" Environment="CATALINA_PID=/opt/tomcat-9/temp/tomcat.pid" Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server - XX:+UseParallelGC"
    ExecStart=/opt/tomcat-9/bin/startup.sh ExecStop=/opt/tomcat-9/bin/shutdown.sh
    [Install]
    WantedBy=multi-user.target
    

Search Index

Note

In version 6.9 migration from Elasticsearch to Opensearch was made. See instruction by the link