9.2 Maintaining the ZENworks Data Store on PostgreSQL

The following sections provide instructions for backing up and restoring the PostgreSQL Data Store:

9.2.1 Displaying the Password for the Default PostgreSQL Database

The password for the default ZENworks PostgreSQL database is stored as plaintext on your ZENworks Primary Server. You can access the database without the password if you are logged on as Root.

If you need the password for maintenance purposes, you can use the following command to display the password (you must be logged in as Root):

cat /etc/opt/novell/zenworks/serversecret

9.2.2 Understanding Automated Database Maintenance

If you are using a PostgreSQL database, there are some automated maintenance tasks that are performed both daily and monthly.

Daily Maintenance: Once a day, old versions are flagged, allowing the space used by these records to be used for new data; the statistics used by the query engine are updated to achieve the best possible performance. This maintenance runs every day at 2:15 a.m.

Monthly Maintenance: Unlike the daily maintenance, the monthly maintenance actually frees the space used by the old flagged records; this prevents a large disparity between the allocated disk space for the database and the actual space used by the database. Because this is an intensive process, it is scheduled monthly instead of daily. It runs at 3:15 a.m on the first day of each month.

9.2.3 Backing Up the ZENworks Data Store

This section applies only if you are using the PostgreSQL database for your Data Store.

You can use zlm_dbbackup.sh to make a backup of the Data Store. This backup utility is located in /opt/novell/zenworks/sbin.

  1. Make sure you are logged in as root to a ZENworks Server.

  2. On the ZENworks Primary Server with the local data store, enter the following at the command prompt:

    zlm_dbbackup.sh

NOTE:Database backup operation is supported from the Secondary servers only if its PostgreSQL database version is same as the Primary server. For example, you cannot run the backup utility from a SLES 9 secondary server if the primary server is a SLES 10 server. This is because the SLES 9 server's pg_dump utility, which is used by the backup utility, is incompatible with the PostgreSQL database version running on the primary server. You have to run the backup utility on the primary server.

A directory with the current date is created at /var/opt/novell/zenworks/backup/db. The backup file, named timestamp-zenworks-backup.tar.gz, is saved in this directory. For example, if the backup is taken on August 23, 2005 at 11:30 p.m., the following directory and file are created:

/var/opt/novell/zenworks/backup/db/2005-08-23/23:30:00-zenworks-backup.tar.gz

Log information about the backup operation is saved in the /var/opt/novell/log/zenworks/dbbackup.log file.

The utility does not require any user interaction. If desired, you can schedule the database backup operation as a cron job.

9.2.4 Restoring the ZENworks Data Store

This section applies only if you are using the PostgreSQL database for your Data Store.

If necessary, you can restore the ZENworks Data Store from a backup you created. You use zlm_dbrestore.sh, located in /opt/novell/zenworks/sbin, to restore the Data Store from a backup.

The restore operation drops the existing database and creates a new one.

To restore the ZENworks Data Store:

  1. On all ZENworks Servers, stop the ZENworks Server (novell-zenserver) and the ZENworks Loader (novell-zenloader) services by using the following commands:

    /etc/init.d/novell-zenserver stop

    /etc/init.d/novell-zenloader stop

    Because all ZENworks Servers access the Data Store, you need to stop these services on all ZENworks Servers on your system. You must also ensure that external connections, if any, to the database are terminated.

  2. Make sure you are logged in as root to a ZENworks Server.

  3. On the ZENworks Primary Server, enter the following at the command prompt:

    zlm_dbrestore.sh -F path_to_the_backup_file

    NOTE:If you have taken a database backup from the Secondary server, you can restore the database only if the PostgreSQL database version is same on both the Primary and Secondary servers.

    Make sure that the -F option includes the backup file's complete path. For example:

    zlm_dbrestore.sh -F /var/opt/novell/zenworks/backup/db/2005-08-23/23:30:00-zenworks-backup.tar.gz
    
  4. If prompted, enter Y to stop the ZENworks Server (novell-zenserver).

  5. If prompted, enter Y to stop the ZENworks Loader (novell-zenloader).

  6. When prompted to supply a password to drop the database, enter the password configured in /etc/opt/novell/zenworks/hibernate.cfg.xml that is used for authenticating the PostgreSQL database.

  7. When prompted to supply a password to create the new database, enter the password configured in /etc/opt/novell/zenworks/hibernate.cfg.xml that is used for authenticating the PostgreSQL database.

    The log information about the restore operation is saved in the file /var/opt/novell/log/zenworks/dbrestore.log.

  8. After the restore is complete, you need to ensure that the Data Store is synchronized with the Object Store. For instructions, see Section 9.4, Synchronizing the Object Store and Data Store.

  9. On all ZENworks Servers, start the ZENworks Server (novell-zenserver) and the ZENworks Loader (novell-zenloader) by using the following commands:

    /etc/init.d/novell-zenserver start

    /etc/init.d/novell-zenloader start

9.2.5 Optimizing the Server Database

To improve the server database performance, use the zlm-pg-vacuum script, found in the /opt/novell/zenworks/bin directory on the ZENworks Server. When you install a ZENworks Primary Server using a local PostgreSQL database, the installation program creates a script that runs on a daily basis.

The zlm-pg-vacuum script runs the vacuumdb command, which has a significant impact on database performance. You must log in as root before running the zlm-pg-vacuum script. For the optimal performance, run the following vacuum scripts:

  • zlm-pg-vacuum or zlm-pg-vacuum --busy-tables: Depending on the database activity, run the script daily to weekly. Run the script once a week on a lightly loaded server and once a day on a heavily loaded server.

  • zlm-pg-vacuum --full: Run the script during a period of less activity or during downtime for the database server. Depending on the database activity, run the script weekly or bi-weekly. It performs a full vacuum analyze and exclusively locks tables. It is recommended that you manually run the zlm-pg-vacuum --full script once a month by performing the following steps:

    • 1.Stop all the ZENworks services by executing zlm-config --stop.
    • 2. Execute zlm-pg-vacuum --full.
    • 3. Start all the ZENworks services by executing zlm-config --start.

Additionally, you can fine-tune the following parameters depending on your memory requirements and scale:

  • In the /etc/sysctl.conf file, configure kernel.shmmax.

  • In the postgresql.conf file, configure shared_buffer, sort_mem, vacuum_mem, wal_buffers, and checkpoint_segments.

For more information on how to fine-tune the parameters, see the PostgreSQL documentation.

Following is a sample scenario that illustrates how you can fine-tune the database parameters. The values indicated in this scenario are sample values; you must fine-tune it according to your requirements. For more information on how to fine-tune the parameters, see the PostgreSQL documentation

An Example Scenario: In this scenario, assume that the ZENworks server is running on an IBM x346 with two Xeon processors and 4 GB of RAM. The database is running on the same server. 2 GB of RAM is dedicated to the other ZENworks processes, 1 GB of RAM to the operating system and non-ZENworks processes, and the remaining 1 GB of RAM is for PostgreSQL.

To optimize the server database performance:

  1. In the /etc/sysctl.conf file, set the value of kernel.shmmax to 1572864000 so that the process can have 1.5 GB of shared memory.

    The shmmax kernel parameter allows PostgreSQL to consume more shared memory. By default, the kernel only allows a process to consume 32 MB of shared memory.

    NOTE:This step is not applicable if ZENworks 7.2 Linux Management is running on SLES 10 device because the value of kernel.shmmax is 4 GB by default on SLES 10.

  2. In the postgresql.conf file, configure the following parameters:

    • shared_buffers = 131072

    • sort_mem = 10240

    • vacuum_mem = 102400

    • wal_buffers = 20

    • checkpoint_segments = 20

  3. Reboot the server for the changes to take effect.

9.2.6 Restarting Novell Zenworks Server Services After Restarting the Database

After restarting the PostgresSQL database on the ZENworks Linux Management Server, the database connections will be restored in approximately 15 minutes. During this time, the ZENworks Control Center and zlman utility might display database-connection errors.

To restore the connections immediately, restart the novell zenworks services by running the following command:

/opt/novell/zenworks/bin/zlm-config --restart