Upgrading the PEM backend Postgres database v9
If you're updating PEM components and the PEM backend database, perform PEM component updates on the server and agent before updating the backend database. For more information about updating PEM component software, see Upgrading a PEM installation.
Note
From PEM 8.0 onwards, PostgreSQL or EPAS versions 11 or later are only supported as backend database servers. As a result, if your backend database server is earlier than version 11, you need to first upgrade your backend database server and then upgrade the PEM components.
After upgrading the backend database server, if you encounter this error while creating the server in the PEM web interface:
Error - User does not have enough permission to add new server. Please contact the administrator to grant 'pem_database_server_registration' role to the 'enterprisedb' user.
Resolve the error by updating the roles and granting appropriate permissions:
UPDATE pem.roles SET rolid = pr.oid FROM pg_roles pr WHERE pr.rolname = 'pem_' || component;
The update process uses the pg_upgrade utility to migrate from one version of the backend server to a more recent version. pg_upgrade enables migration between any supported version of Postgres and any subsequent release of Postgres that's supported on the same platform.
If the source PEM server is earlier than the 7.16 version, then you need to replace the following functions before you run pg_upgrade:
The
abstime
,reltime
, andtinterval
datatypes are deprecated from Postgres version 12 or later, hence to replace those dataypes withtimestamptz
data type use this command:DO $$ DECLARE rec record; cnt integer; BEGIN -- Check for the deprecated type in our user info probe SELECT count(*) INTO cnt FROM pem.probe_column WHERE sql_data_type = ‘abstime’ AND internal_name = ‘valuntil’; IF cnt = 0 THEN RETURN; END IF; ALTER TABLE pemdata.user_info ALTER COLUMN valuntil SET DATA TYPE timestamptz; ALTER TABLE pemhistory.user_info ALTER COLUMN valuntil SET DATA TYPE timestamptz; -- Now update the pem.probe_column itself UPDATE pem.probe_column SET sql_data_type = ‘timestamptz’ WHERE sql_data_type = ‘abstime’ AND internal_name = ‘valuntil’; END; $$ LANGUAGE ‘plpgsql’;
Replace this function to avoid any alert errors:
CREATE OR REPLACE FUNCTION pem.check_alert_params_array_size( template_id pem.alert_template.id%type, params text[] ) RETURNS bool AS $FUNC$ DECLARE res bool := TRUE; BEGIN /* * During restoring the pem database, it does not maintain the order while * inserting data in the table, and uses the sort table based on the * names. * Hence - we need to check the foreign key constraint is present before * validating these values. */ IF EXISTS( SELECT 1 FROM information_schema.table_constraints WHERE constraint_name='alert_template_id_fkey' AND table_name='alert' AND table_schema='pem' ) THEN /* * Need to use the IS TRUE construct outside the main query, because * otherwise if there's no template by that ID then the query would return * 0 rows and the result of the function would be undefined and CHECK * constraint would succeed. * Probably this is being over-cautious, because pem.alert.template_id * references pem.alert_template.id. But the SQL standard (probably) does * not define the order in which the CHECK or the FOREIGN KEY constraints * should be validated; in case CHECK is validated first, we want it to * fail. */ EXECUTE $SQL$ SELECT ( SELECT pem.check_array_size_equal(t.param_names, $2) FROM pem.alert_template AS t WHERE id = $1 ) IS TRUE $SQL$ INTO res USING template_id, params; END IF; RETURN res; END $FUNC$ LANGUAGE 'plpgsql';
pg_upgrade supports a transfer of data between servers of the same type. For example, you can use pg_upgrade to move data from a PostgreSQL 10 backend database to a PostgreSQL 11 backend database but not to an EDB Postgres Advanced Server 11 backend database. If you want to migrate to a different type of backend database (such as from a PostgreSQL server to EDB Postgres Advanced Server), see Moving the Postgres Enterprise Manager server.
You can find more information about using pg_upgrade at pg_upgrade.
Download and invoke the updated installer. Installers for PostgreSQL and EDB Postgres Advanced Server are available through the EDB website.
After downloading the installer for the server version you are upgrading to, invoke the installer on the host of the PEM server. Follow the onscreen instructions of the installation wizard to configure and install the Postgres server.
You can optionally use a custom-built PostgreSQL server as a host of the PEM backend database. If you're upgrading from a PostgreSQL backend database listening on port 5432, the new server must be configured to listen on a different port.
Configure SSL utilities on the new server. The new backend database must be running the same version of sslutils that the current backend database is running. You can download the SSL Utils package from the EDB website.
You don't need to manually add the sslutils extension when using the EDB Postgres Advanced Server as the new backend database. The process of configuring sslutils is platform specific.
On Linux
On an EDB Postgres Advanced Server backend database, the sslutils extension is installed by default.
If you're using PostgreSQL as a PEM backend database, verify that you have access to the PostgreSQL community repository, and use the command:
yum install sslutils_<X>
Where
<X>
is the server version.If you're using a EDB one-click installer of PostgreSQL as a PEM backend database, use the command:
yum install gcc openssl-devel
Set the value of PATH so it can locate the pg_config program
export PATH=$PATH:/opt/postgres_inst_dir/<X>/bin/
Move into the
sslutils
folder, and enter:make USE_PGXS=1 make USE_PGXS=1 install
Use psql to create the sslutils extension