Moving the PEM server v9
You can move a PEM server from one host machine to a new host machine. The PEM server on the new host (the target) must be installed with the same version of the PEM server installer as the original host (the source). If you don't use the same installer version, you might encounter a schema-mismatch error.
The backend database of the target server (either PostgreSQL or EDB Postgres Advanced Server) can have the same type and version or a different type and version from the backend database of the source PEM server. You can migrate a PEM server that resides on a PostgreSQL host to an EDB Postgres Advanced Server host and vice versa.
Before starting the server migration, make sure that the firewalls between the source host, the target host, and the host of any PEM agent allows connections between the services.
Prepare the target host.
Invoke the installer for the PEM server on the target host. You must use the same version of the PEM server installer that you used when installing the source PEM server.
The backend database of the target server can have a different version or type from the backend database of the source. If the new PEM server doesn't reside on the same type of backend database as the original server, you must ensure that the same version of the sslutils extension is installed on the new server host. The version of sslutils that's distributed with the PEM installers is freely available for download from the EDB website.
For information about installing the PEM server or the sslutils extension, see the PEM installation steps.
Drop existing schemas from the new PEM server.
The migration process re-creates the
pem
,pemdata
, andpemhistory
schemas from the source PEM server on the target PEM server. To prepare for the move, use the psql client to delete these schemas from thepem
database on the target host. You can open the psql client at the command line or by selecting Postgres Enterprise Manager > SQL Shell (psql).When the psql client opens, connect to the
pem
backend database as the database superuser. After connecting to thepem
database on the target host, drop the schemas:When dropping the schemas, you must include the
CASCADE
keyword, instructing the server to delete all dependent objects. When executing the command, the psql client displays a list of the dependent objects. The client confirms each the schema is removed by displayingDROP SCHEMA
.Prepare the PEM agents on the new PEM server.
Before moving the PEM server, you must identify the number of agents that are monitored by the source PEM server and create identities for that number of agents, less one, on the target server. To discover the total number of PEM agents monitored by the PEM server, connect to the
pem
database on the source host with the psql client, and query thepem.agent
table.You must manually create the number of agents that reside on the original PEM server, less one. (The PEM server installer creates one agent on the target host.) For example, if the source server contains three agents, you must manually create two more agents. Open a psql session with the
pem
database on the target server, and create the required agents:Where
<X>
specifies an agent number.agent1
is created on the target host by the PEM server installer.Then, use the
GRANT
command to assign each agent that resides on the target PEM serverpem_agent
permissions:Where
<X>
specifies an agent number.Generate a backup script of the source PEM server.
You can use the pg_dump utility to generate a script that contains the commands required to re-create the
pem
database on the target host. By default, pg_dump is installed in thebin
directory under your Postgres installation. To invoke pg_dump, in thebin
directory, enter:Where:
<user_name>
specifies the name of the database superuser for the PEM backend database.<db_name>
specifies the name of the PEM backend database.<file_name>
specifies the name of the script generated by pg_dump.
When prompted, provide the password associated with the user specified.
The command shown instructs pg_dump to generate a script that, when executed, re-creates the
pem
database. The script is namedbackup.sql
and is created in thetmp
directory. pg_dump is connecting to the server using the credentials of the user postgres.Invoking the pg_dump utility doesn't interrupt current database users.
Note
If the source PEM server is earlier than the 7.16 version, then you need to replace the following functions before you run pg_dump to take backup:
- The
abstime
,reltime
, andtinterval
datatypes are deprecated from Postgres version 12 or later. To replace those dataypes withtimestamptz
data type, use this command:
- Replace the this function to avoid any alert errors:
Move the backup to the target host.
Move the script generated by the pg_dump utility to the target host of the PEM server.
Restore the backup on the target host.
On the target host, in the
bin
directory under the Postgres backend database installation directory, start psql, executing the script generated by the pg_dump utility:Where:
<user_name>
specifies the name of the database superuser. The user specified must have connection privileges for the backend database.<file_name>
specifies the complete path to the backup script generated by pg_dump.
When prompted, provide the password associated with the database superuser.
The example shown uses the psql client to invoke a script named
backup.sql
to recreate thepem
database. The script is invoked using the privileges associated with the database superuser postgres.Stop the database server on the target host.
To stop the PEM server on RHEL 8.x, use the command:
Where
<service_name>
specifies the name of the backend database server. For a PostgreSQL backend database, the service name ispostgresql-<x>
. For an EDB Postgres Advanced Server backend database, the service name isedb-as-<X>
, where<X>
specifies the version number.If you're using Windows, you can use the Services dialog box to control the service. To open the Services dialog box, from the Control Panel, select System and Security > Administrative Tools. Double-click the Services icon. In the Services dialog box, select the service name in the list, and select Stop.
Copy the certificate files to the target host.
You must replace the certificate files that are created when the target host is installed with the certificate files of the source host. Copy the following files from the source PEM server to the target PEM server:
ca_certificate.crt
ca_key.key
root.crt
root.crl
server.key
server.crt
Copy the files to the
data
directory under the Postgres installation that provides the backend database for the target cluster.On Linux, the files reside in:
On Windows, the files reside in:
Where:
<X>
specifies the version of PostgresSQL on your system.The files already exist on the target cluster. Delete the existing files before performing the copy, or overwrite the existing files with the files from the source server. Once in place on the target server, the files must have the platform-specific permissions shown.
On Linux
File name Owner Permissions ca_certificate.crt postgres -rw------- ca_key.key postgres -rw------- root.crt postgres -rw------- root.crl postgres -rw------- server.key postgres -rw------- server.crt postgres -rw-r--r-- On Linux, the certificate files must be owned by postgres. Use the following command to modify the ownership of the files:
Where
file_name
specifies the name of the certificate file.Only the owner of the
server.crt
file can modify the file, but any user can read it. Use the following command to set the file permissions for theserver.crt
file:Only the owner of the other certificate files can modify or read the files. Use the following command to set the file permissions: