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, ensure the db_json_exim.py script is available:

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

    Note:

    /tmp/db-dump is a user-defined directory name. You can assign any name to a directory.

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

    The Cassandra database instance on any contrail controller node includes the complete Cassandra database for all contrail controller nodes in the cluster. Steps 2 and 3, therefore, only need to be performed on one contrail controller 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 contrail controller 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 contrail controller 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 contrail controller 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:

    Note:

    The cluster is TLS-enabled if TLS-related files are used during Contrail Networking deployment. The TLS-related files are part of the deployment script. These are custom files and can have any name. For example:

  8. From the container created on the contrail controller 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 contrail controller node. Example:

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

  9. (Optional. Recommended) From the same contrail controller 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 contrail controller node, exit out of the config api container. This will stop the container.

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

    This step must be performed on each individual contrail controller node.

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

    This step must be performed on each individual analytics node.

  13. On each contrail controller 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 configuration 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 contrail controller 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 the contrail controllers.

  6. Stop the Zookeeper service on all the contrail-analytics controllers.

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

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

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

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

  11. Start the Zookeeper service on all the contrail controllers.

  12. Start the Zookeeper service on all the contrail-analytics controllers.

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

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

    Example:

  15. Run a new podman container using the name or ID of the config_api image on the same contrail controller 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 14.

    Example:

  16. Restore the data in the new running container on the same contrail controller node.

    Example:

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

  18. Start config services on all of the controllers:

  19. Start services on all of the analytics nodes:

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

    Note:

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