Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP Open Source Middleware Stacks Blueprint:: Directory Services on HP ProLiant and HP Integrity Servers with Red Hat Linux Enterprise Version 5

Performing Backups and Recovery with Berkeley DB

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

Performing a Hot Backup and Reloading the Berkeley DB

Hot backups offer a convenient way to back up data when the CDS server is running. Performing a hot backup does not require downtime and it does not impact the CDS server. Use the slapcat command, which is provided with the CDS distributions, to perform a hot backup. The following steps explain how to perform a hot backup and, when the Berkeley DB is damaged, reload data.

CAUTION: If data is being altered or updated when you perform a hot backup, a mismatch can occur between the backup file and CDS server's final data. There is a risk of inconsistent data when performing a hot backup.
  1. To view the data in the Berkeley Database, enter the following command:

    # /opt/symas/bin/slapcat

  2. To perform a hot backup of the Berkeley Database to an LDIF file, while the CDS server is running enter the following command:

    # /opt/symas/bin/slapcat –l backup.ldif

  3. To view the file, enter the following command:

    # vi backup.ldif

  4. When the CDS server has a problem or the data file is damaged, the data can be reloaded from the LDIF file. To mimic a damaged data file for this example, manually delete the data using the following command:

    # /opt/symas/bin/ldapdelete -x -D 'cn=Manager,dc=example,dc=com' \

    -w secret -r dc=example,dc=com

  5. Verify the data has been deleted using the slapcat command. The query result should be empty.

    # /opt/symas/bin/slapcat

  6. Before you reload the data from the LDIF file, shut down the CDS server by entering the following command:

    # /etc/init.d/cdsserver stop

  7. Reload data from the LDIF file using the slapadd utility by entering the following command:

    # /opt/symas/bin/slapadd -l backup.ldif

  8. Restart the CDS server and check the restored data by entering the following commands:

    # /etc/init.d/cdsserver start

    # /opt/symas/bin/slapcat

Recovering the Berkeley DB

The db_archive and db_recover utilities are used for normal recovery or disaster recovery for the Berkeley DB data, which is the back-end database of CDS server. The following example procedure shows how to use the db_archive and db_recover utilities to backup and recover data.

  1. Stop the CDS server and force a checkpoint of the log or archive using the db_checkpoint utility by entering the following commands:

    # /etc/init.d/cdsserver stop

    # /opt/symas/bin/db_checkpoint -1 -h /var/symas/openldap-data/example/

  2. Archive the data files by entering the following command:

    # /opt/symas/bin/db_archive -s -h /var/symas/openldap-data/example/

  3. To back up the Berkeley DB data files, copy these files to another directory or server, for example /databackup, using the following commands:

    # mkdir /databackup

    # cp /var/symas/openldap-data/example/*db.00* /databackup

    # cp /var/symas/openldap-data/example/*.bdb /databackup

  4. Archive and copy the log files by entering the following commands:

    # mkdir /logbackup

    # /opt/symas/bin/db_archive -l -h /var/symas/openldap-data/example/

    # cp /var/symas/openldap-logs/example/log.0000000001 /logbackup

  5. For the test in this example, delete all CDS data manually and verify the results by entering the following commands:

    # /etc/init.d/cdsserver start

    # /opt/symas/bin/ldapdelete -x -D 'cn=Manager,dc=example,dc=com' \

    -w secret -r dc=example,dc=com

    # /opt/symas/bin/slapcat

  6. To recover the data from the backup using the db_recover utility, restore data files from the backup media by entering the following commands:

    # /etc/init.d/cdsserver stop

    # cp /databackup/*db.00* /var/symas/openldap-data/example/

    # cp /databackup/*.bdb /var/symas/openldap-data/example/

  7. Restore the transaction log files from the backup media by entering the following command:

    # cp /logbackup/log.0000000001 /var/symas/openldap-logs/example/

  8. To place the data files and log files in a consistent state, run the following command:

    # /opt/symas/bin/db_recover –c –h /var/symas/openldap-data/example/

  9. Start the CDS server and verify the recover results by entering the following commands:

    # /etc/init.d/cdsserver start

    # /opt/symas/bin/slapcat

Obtaining Statistics for the Berkeley DB

Use the db_stat utility, contained in the CDS distribution, to obtain statistics and state information for the Berkeley DB environment. The db_stat utility is located in the /opt/symas/bin directory.

  1. To get the Berkeley database version information, enter the following command:

    # /opt/symas/bin/db_stat -V

  2. Display the lock region parameter and information for the Berkeley database by entering the following command:

    # /opt/symas/bin/db_stat -C A -h /var/symas/openldap-data/example

  3. To display detailed statistical information for a specified file, use the db_stat utility with the –d option as follows:

    # /opt/symas/bin/db_stat -d dn2id.bdb -h \

    /var/symas/openldap-data/example

  4. To monitor the current transaction's information, use the db_stat utility with the –t option as follows:

    # /opt/symas/bin/db_stat -t -h /var/symas/openldap-data/example

  5. To check additional Berkeley DB information, such as environment version, log region, lock region, and transaction region, enter the following command:

    # /opt/symas/bin/db_stat -e -h /var/symas/openldap-data/example

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 2007 Hewlett-Packard Development Company, L.P.