Moving the data is a two step process:
IMPORTANT:While moving the database, we refer the source database server as PSDB1 and the destination database server as PSDB2.
NOTE:ZENworks no longer supports Windows Server as a Primary Server from version 24.2 onwards. For more information, see End of Support Windows Primary Server.
Before executing the following steps, ensure that you have reviewed the information documented in the section Important Commands and Locations.
Ensure that you have noted the database username, password of the source Primary Server by running the zman dgcs command. Also, copy the target Primary Server’s GUID details, which is required while restoring the database.
Stop the ZENworks Services on all the Primary Servers by running the following configure action:
microfocus-zenworks-configure -c Start
After running the command, under Action, select Stop.
Log in to the Primary Server that has the database role.
On the Primary Server on which the Embedded Database is installed (PSDB1), start the Micro Focus ZENworks Embedded Datastore service using the following command on SLES 12 and later:
systemctl start zenpostgresql.service
Run the following commands to back up the databases (ZENworks and Audit):
docker exec -e PGUSER=<super user retrieved from zman dgcs> -e PGDATABASE=postgres -e PGPASSWORD=<password retrieved from zman dgcs> zenpostgres pg_dumpall > /tmp/dump.sql
Example: docker exec -e PGUSER=zenpostgres -e PGDATABASE=postgres -e PGPASSWORD=Zw0#3dde8547adb388306de141850 zenpostgres pg_dumpall > /tmp/dump.sql
NOTE:You can ignore the no version information available error message.
Start the Micro Focus ZENworks Embedded Datastore service using the following command:
On SLES 12 and later: systemctl start zenpostgresql.service
NOTE:Keep the /tmp/dump.sql in a safe place as it has the database backup.
Depending on the target database platform, refer to the following section to restore the database:
On a Linux Primary Server or an Appliance Server, perform the following steps:
Before executing the following steps, ensure that you have reviewed the information documented in the section Important Commands and Locations.
Ensure that you have noted the database username, password of the source Primary Server by running the zman dgcs command.
Stop all the ZENworks services on all Primary Servers by running the following configure action:
microfocus-zenworks-configure -c Start
Load zenpostgres docker by running the following commands:
docker load -i /opt/microfocus/zenworks/docker-images/zenpostgres.tar.gz
docker run --name tmp_postgres -d zenpostgres
docker cp /tmp/dump.sql tmp_postgres:/var/opt/microfocus/pgsql/
NOTE:The /tmp/dump.sql file is created in the backup step 5 of the Backup the Database on the Embedded Primary Server (PSDB1)
Get into the temporary postgres container by running the following command:
docker exec -it tmp_postgres bash
To check whether the database server is ready to accept connections, run the following commands:
cd /var/opt/microfocus/pgsql/data
cat postmaster.log
After executing the commands, the last line should say Database system is ready to accept connections
. If you did not see this message, wait for some time, and then execute the cat postmaster.log
command again.
Perform the following steps to prepare the default database, for restore.
Run the psql -W postgres command. When prompted for a password, enter novell as the password.
To change the default password, run the following SQL query:
ALTER USER zenpostgres with PASSWORD '<Password>';
Replace the <Password> in the above SQL query with the password you noted down in step 1 of the Backup the Database on the Embedded Primary Server (PSDB1).
Example: ALTER USER zenpostgres with PASSWORD 'Zw0#3dde8547adb388306de141850';
Drop the following default databases and users:
drop database zenworks;
drop database zenworksaudit;
drop user zenadmin;
drop user zenauditadmin;
drop database zenamdatabase;
drop user zenamadmin;
NOTE:Ignore errors related to missing database or users if any.
Exit the Postgres interactive terminal by executing the exit command.
To restore the database, run the following commands:
export PGPASSWORD= <password retrieved from zman dgcs>
psql -w postgres -v ON_ERROR_STOP=0 -f /var/opt/microfocus/pgsql/dump.sql -o /var/opt/microfocus/pgsql/dump.log -L /var/opt/microfocus/pgsql/dump.log >/var/opt/microfocus/pgsql/dump.err 2>&1
NOTE:Execution of the above command may take time depending on the amount of data in the database.
Once the restore is completed successfully, exit the docker container by running the exit command.
To copy the database folder from the container to the host, run the following commands:
rm -rf /var/opt/microfocus/pgsql
docker cp tmp_postgres:/var/opt/microfocus/pgsql/ /var/opt/microfocus/
rm -f /var/opt/microfocus/pgsql/data/postmaster.pid /var/opt/microfocus/pgsql/data/postmaster.log
To clean up the temporary container, run the following commands:
docker kill tmp_postgres
docker container rm tmp_postgres
To change the ownership of the data directory, run the following command:
chown -R 1026:1026 /var/opt/microfocus/pgsql/data
In the postgresql.conf file, under /var/opt/microfocus/pgsql/data/, uncomment the listen_addresses and port entry keys, and update the values as shown below:
listen_addresses = '*'
Port= 54327
max_connections = Number of primary severs * 500
Edit the pg_hba.conf file as shown below:
The pg_hba.conf file is available in the following location:
/var/opt/microfocus/pgsql/data
In the pg_hba.conf file, update the content as shown below:
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. local replication all md5 host replication all 127.0.0.1/32 md5 host replication all ::1/128 md5 host all all 0.0.0.0/0 md5
In the local primary server, change the server key in zdm.xml and zenaudit.xml, available in /etc/opt/microfocus/zenworks/datamodel folder with the local host address Jdbc_Url:
<entry key="Server">Jdbc_Url</entry>
<entry key="Embedded">true</entry>
If you have configured antimalware in the zone, modify the database.server.address property in /etc/opt/microfocus/zenworks/antimalware/amedatasource.properties file to have the server IP as 127.0.0.1
To create the Postgres service, create the file in /usr/lib/systemd/system/zenpostgresql.service with the following contents:
[Unit]
Description=PostgreSQL Daemon for ZENworks Databases
After=syslog.target network.target docker.service
[Service]
Type=simple
ExecStart=/opt/microfocus/zenworks/lib/systemd/system/zenpostgresql-systemd
Restart=on-failure
RestartSec=20
StartLimitBurst=5
StartLimitInterval=120
[Install]
WantedBy=multi-user.target
To reset the file/folder permissions, run the following command:
permissions.sh
Start the zenpostgres service by running the following commands:
systemctl enable zenpostgresql.service
systemctl start zenpostgresql.service
Run the following configure actions to update OSP/Content Configurations:
microfocus-zenworks-configure -c GenerateOSPProperties
microfocus-zenworks-configure -c RegenerateOSPAuthCfgXml
microfocus-zenworks-configure -c GenerateContentDatasourceConfigureAction
(Conditional) If Antimalware is configured, run the following commands:
microfocus-zenworks-configure -c ZENServicesFirewallConfigureAction -Dservice=antimalware -Doperation=ADD
microfocus-zenworks-configure -c AntimalwareServiceConfigureAction -Dam.service.action=start
On the Primary Server (PSDB2), start the ZENworks services by running the following command:
microfocus-zenworks-configure -c Start
Assign the database role to the destination database server (PSDB2) by running the following configure action:
microfocus-zenworks-configure -c MigrateServerRoleConfigureAction -DsourceGuid=<GUID of PSDB1> -DdestGuid=<GUID of PSDB2> -Drole=Database
To setup Automatic Maintenance, run the following configure action:
microfocus-zenworks-configure -c AutomaticPostgresMaintenanceConfigureAction
(Conditional) If you have enabled Kafka, then run zman server-role-kafka-recreate-connectors -f true command to recreate the Kafka connectors.
For more information, see Server Commands in the ZENworks Command Line Utilities guide.
If you have the firewall enabled on the server, ensure that port 54327 is open.
NOTE:With this, we complete the Restoring of the Database to the Target Primary Server (PSBD2). Continue further to update other Primary Servers in the zone.
Do the following on all the other primary servers in the zone:
Change the server key in zdm.xml and zenaudit.xml, available in /etc/opt/microfocus/zenworks/datamodel folder with the IP address of PSDB2:
<entry key="Server">IP OF PSDB2</entry>
If you have configured Antimalware in the zone, modify the database.server.address property in /etc/opt/microfocus/zenworks/antimalware/amedatasource.properties file to have the server IP as IP of PSDB2.
To update OSP/Content Configurations, run the following configure actions:
microfocus-zenworks-configure -c GenerateOSPProperties
microfocus-zenworks-configure -c RegenerateOSPAuthCfgXml
microfocus-zenworks-configure -c GenerateContentDatasourceConfigureAction
(Conditional) If Antimalware is configured, run the following:
microfocus-zenworks-configure -c ZENServicesFirewallConfigureAction -Dservice=antimalware -Doperation=ADD
microfocus-zenworks-configure -c AntimalwareServiceConfigureAction -Dam.service.action=start
Run the following commands:
systemctl stop zenpostgresql.service
systemctl disable zenpostgresql.service
NOTE:This step is applicable only on PSDB1.
Start all the zenworks services by running the following command:
microfocus-zenworks-configure -c Start