Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

How to Backup and Restore Contrail Databases in JSON Format in Openstack Environments Using the Openstack 16.1 Director Deployment

This document shows how to backup and restore the Contrail databases—Cassandra and Zookeeper—in JSON format when Contrail Networking is running in Openstack-orchestrated environments that were deployed using the RedHat Openstack 16.1 director deployment.

If you are deploying Contrail Networking in an Openstack-orchestrated environment that was deployed using an Openstack 13-based or Ansible deployer, see How to Backup and Restore Contrail Databases in JSON Format in Openstack Environments Using the Openstack 13 or Ansible Deployer.

Contrail Networking is initially supported in Openstack environments using the Openstack 16.1 director deployment in Contrail Networking Release 2008. See Contrail Networking Supported Platforms for a matrix of Contrail Networking release support within orchestration platforms and deployers.

Before You Begin

The backup and restore procedure must be completed for nodes running the same Contrail Networking release. The procedure is used to backup the Contrail Networking databases only; it does not include instructions for backing up orchestration system databases.

CAUTION:

Database backups must be consistent across all systems because the state of the Contrail database is associated with other system databases, such as OpenStack databases. Database changes associated with northbound APIs must be stopped on all the systems before performing any backup operation. For example, you might block the external VIP for northbound APIs at the load balancer level, such as HAproxy.

Simple Database Backup in JSON Format

This procedure provides a simple database backup in JSON format. This procedure is performed using the db_json_exim.py script located inside the config-api container in /usr/lib/python2.7/site-packages/cfgm_common on the controller node.

To perform this database backup:

  1. From a controller node, enable the db_json_exim.py script:

  2. Log into one of the config nodes. Create the /tmp/db-dump directory on any of the config node hosts.

  3. On the same config node, copy the contrail-api.conf file from the container to the host.

    The Cassandra database instance on any configuration node includes the complete Cassandra database for all configuration nodes in the cluster. Steps 2 and 3, therefore, only need to be performed on one configuration node.

  4. On all Contrail controller nodes, stop the following Contrail configuration services:

    This step must be performed on each individual controller node in the cluster.

  5. On all nodes hosting Contrail Analytics containers, stop the following analytics services:

    This step must be performed on each individual analytics node in the cluster.

  6. Return to the config node where you performed steps 2 and 3.

    Use the podman images command to list the name or ID of the config api image.

    Example:

  7. From the same config node, start the config api container by pointing the entrypoint.sh script to the /bin/bash directory then mapping /tmp/db-dump directory from the host to the /tmp directory inside the container. You perform this step to ensure that the API services are not started on the config node.

    Enter the -v /etc/contrail/ssl:/etc/contrail/ssl:ro command option when cassandra_use_ssl is used as the api-server configuration parameter to ensure TLS certificates are mounted to the Contrail SSL directory. This mounting ensures that the backup procedure succeeds in environments with endpoints that require TLS authentication.

    The registry_name and container_tag variables must match step 6.

    Example:

  8. From the container created on the config node in Step 7, use the db_json_exim.py script to backup data in JSON format. The db dump file will be saved in the /tmp/db-dump/ directory on this config node.

    Example:

    The Cassandra database instance on any configuration node includes the complete Cassandra database for all configuration nodes in the cluster. You, therefore, only need to perform step 4 through 6 from one of the configuration nodes.

  9. (Optional. Recommended) From the same config node, enter the cat /tmp/db-dump.json | python -m json.tool | less command to view a more readable version of the file transfer.

  10. From the same config node, exit out of the config api container. This will stop the container.

  11. On each configuration node, start the following configuration services:

    This step must be performed on each individual config node.

  12. On each analytics node, start the following analytics services:

    This step must be performed on each individual analytics node.

  13. On each config node, enter the contrail-status command to confirm that services are in the active or running states.

    Note:

    Some command output and output fields are removed for readability. Output shown is from a single node hosting config and analytics services.

Restore Database from the Backup in JSON Format

This procedure provides the steps to restore a system using the simple database backup JSON file that was created in Simple Database Backup in JSON Format.

To restore a system from a backup JSON file:

  1. Copy the contrail-api.conf file from the container to the host on any one of the config nodes.

  2. On all of the Contrail controller nodes, stop these configuration services:

  3. On all nodes hosting Contrail Analytics containers, stop the following services:

  4. Stop the Cassandra service on all the config-db controllers.

  5. Stop the Zookeeper service on all controllers.

  6. Backup the Zookeeper data directory on all the controllers.

  7. Delete the Zookeeper data directory contents on all the controllers.

  8. Backup the Cassandra data directory on all the controllers.

  9. Delete the Cassandra data directory contents on all controllers.

  10. Start the Zookeeper service on all of the controllers.

  11. Start the Cassandra service on all of the controllers.

  12. Use the podman images command to list the name or ID of the config api image.

    Example:

  13. Run a new podman container using the name or ID of the config_api image on the same config node.

    Enter the -v /etc/contrail/ssl:/etc/contrail/ssl:ro command option when cassandra_use_ssl is used as api-server configuration parameter to ensure TLS certificates are mounted to the Contrail SSL directory. This mounting ensures that this backup procedure succeeds in environments with endpoints that require TLS authentication.

    Use the registry_name and container_tag from the output of the step 12.

    Example:

  14. Restore the data in the new running container on the same config node.

    Example:

  15. Exit out of the config api container. This will stop the container.

  16. Start config services on all of the controllers:

  17. Start services on all of the analytics nodes:

  18. Enter the contrail-status command on each configuration node and, when applicable, on each analytics node to confirm that services are in the active or running states.

    Note:

    Output shown for a config node. Some command output and output fields are removed for readability.