Oracle by Example brandingPerforming Verification and Backup of a Transactional Environment in Berkeley DB

section 0Before You Begin

This is the second tutorial in the Getting Started with the Graphical User Interface in Berkeley DB series. Perform both these tutorials sequentially as there is a dependency to complete one before starting the other.

In this tutorial, you will open an existing transactional environment, perform backup and recovery, verify data and log integrity, and remove an existing database using the new Graphical User Interface in Berkeley DB 18.1.

This tutorial takes approximately 15 minutes to complete.

Background

Berkeley DB is a family of embedded key-value database libraries providing scalable high-performance data management services to applications. It enables the development of custom data management solutions, without any overhead. You can configure Berkeley DB to address any application need from the hand-held device to the data center, from a local storage solution to a world-wide distributed one, and from kilobytes to petabytes.  

The Oracle Berkeley DB Graphical User Interface (BDB GUI) is introduced in Berkeley DB 18.1 and provides a simple interface for interacting with the Berkeley DB environment.

What Do You Need?

  • Install JDK 8 or higher version in your machine. This is required to build and run Berkeley DB GUI.
  • Install Oracle Berkeley DB 18.1 from the Oracle Technology Network.
  • For Windows only: Install Oracle Berkeley DB 18.1 Windows binary installer from the Oracle Technology Network.
  • For Linux only:
    • After installing, enable GUI with the --enable-gui flag while building Berkeley DB 18.1.
    • Set the following environment variables. Replace [bdb-install_directory] with the path to the directory where you have Berkeley DB 18.1 installed:

      export CLASSPATH=[bdb-install_directory]/lib/db.jar;[bdb-install_directory]/lib/db_gui.jar;$CLASSPATH

      export LD_LIBRARY_PATH=[bdb-install_directory]/lib;$LD_LIBRARY_PATH

section 1Open an Existing Environment and a Database

  1. To open up an existing Environment, click the Environment Page button at the bottom left corner of the screen to return to the Environment page.
    Click the Enivironment Page button.
    Description of the illustration sect_1_01.jpg
  2. Click the Open Environment tab.
    open environment
    Description of the illustration sect_1_02.jpg
  3. Click the Browse button, navigate to the environment home directory, and select the environment that you created at the beginning of this tutorial.
    Click browse
    Description of the illustration sect_1_03.jpg
  4. Enable a 25 megabyte cache by entering 26214400 for Cache Size and click the Open button.
    open the environment
    Description of the illustration sect_1_04.jpg
  5. You see a "Environment successfully opened" message at the bottom of the page, and the GUI will advance to the Database Page.
    Envioronment successfully opened
    Description of the illustration sect_1_05.jpg
  6. To open up an existing Database, after opening the environment on the Database Access page, click the Open Database tab.
    click the Open Database tab
    Description of the illustration sect_1_06.jpg
  7. Click the Browse button to select the database file that we created in the previous sections called test.db and click the Open button.
    browse and open an existing database
    Description of the illustration sect_1_07.jpg
  8. You see a "Database successfully opened" message at the bottom of the page, and the GUI will advance to the Data Access Page. Click the Environment Page button.
    database successfully opened
    Description of the illustration sect_1_08.jpg

section 2 Backup and Recover an Environment

  1. In the Environment page, the Backup tab is used to create a backup of all databases and logs in the environment. Backup can be performed even while other threads are accessing the environment. Note that the environment must be transactional, or backup will fail with an error. Perform the following steps to backup your environment:

    • Click the Browse button by Environment Home and select the environment that you created in this tutorial.
    • Click the Browse button by Backup Directory and select a directory in which you want to create the backup of the environment. Click the Backup button.
      select a backup directory
      Description of the illustration sect_2_02.jpg
    • Various messages describing the backup process will appear at the bottom of the page, ending with the message "Environment backup successful."
      backup successful
      Description of the illustration sect_2_03.jpg
  2. Recovery is used to clean up a transactional environment after an application crash. Recovery restores data consistency and removes any resources left by the crashed application. Perform the following steps to recover your environment.

    Note: Do not perform recovery while other threads are accessing the environment.

    • Click the Recovery tab.
    • Click the Browse button by Environment Home to select the Environment Home directory.
    • Click the Recover button.
    • Messages describing the recovery process will appear at the bottem of the screen, ending in "Environment recovery successful."
    • recover an environment
      Description of the illustration sect_2_04.jpg

section 3Verify Data and Log Integrity

  1. Use the Verify Data tab to confirm data integrity. Do not perform this process while other threads are accessing the environment. To verify data integrity, perform the following tasks:

    • Select the Verify Data tab.
    • Click the Browse button by Environment Home to select the environment we created.
    • Click the Browse button and select the database file test.db.
    • Click the Verify button.
    • Various messages describing the verify process will appear at the bottom of the screen, ending with "Success validating database:test.db".
    verifying data
    Description of the illustration sect_3_01.jpg
  2. Use the Verify Logs tab to confirm that the integrity of the logs. This process only works on transactional environments. Do not perform this process while other threads are accessing the environment.To verify log integrity, perform the following steps:

    • Select the Verify Logs tab.
    • Click the Browse button by Environment Home to select the environment we created.
    • Click the Verify button.
    • Various messages describing the verify process will appear at the bottom of the screen,  ending with "Log verification succeeded".
    verifying logs
    Description of the illustration sect_3_02.jpg

section 4Remove a Database

  1. In the Environment page, click the Open Environment tab, browse and select the environment home directory, and click Open.
    Open the existing environment
    Description of the illustration sect_4_01.jpg
  2. In the Database Access page, click the Remove tab.
    Click the Remove tab
    Description of the illustration sect_4_02.jpg
  3. Click the Browse button to select the database file test.db, and click the Remove button.
    deleting the database
    Description of the illustration sect_4_03.jpg
  4. A message "test.db successfully removed" should appear at the bottom of the screen.
    successfully deleted the database
    Description of the illustration sect_4_04.jpg
  5. Open the environment home directory. The database file test.db should have been deleted from the directory.
    The database file test.db is deleted.
    Description of the illustration sect_4_05.jpg


more informationWant to Learn More?