Openstack is deployed for multiple purposes such as Learning Openstack, Training Openstack, Exploring certain features on Openstack, Developing or Enhancing Openstack Projects, Integrating Openstack with other Systems, Running Test or Production Workloads etc.
We often require to deploy and redeploy Openstack in same Physical Server for multiple purposes such as
2. Problems in Deployment
3. Perfecting the Configurations
4. Change in Hypervisor
5. Trying other Configuration Options for tuning
6. Openstack deployment training
The challenge with redeployment is that we need to trace back all the packages installed as part of Openstack and uninstall all of them. It is a tedious and cumbersome process. The other option is to reinstall the Operating system but that is time consuming effort. The optimal way to do that activity repeatedly again and again is to restore the physical server to old state using Snapper Tool. This blog outlines the procedure for installing snapper, creating a Snapshot of Physical Server similar to Virtual Image, deploying Openstack and restoring the Physical Server to Old state for redeployment of Openstack.
OpenStack is a leading open-source software platform for cloud computing, mostly deployed as an infrastructure-as-a-service (IaaS). The software platform consists of interrelated components that control diverse, multi-vendor hardware pools of processing, storage, and networking resources throughout a Data Center
Snapper is a Linux command line tool to create and manage snapshots of your filesystems. It allows to create read only snapshots of a physical machines which can be used to restore the state of the server during any disaster situation.
Steps for Deploying Openstack with Snapper and Restoring to original State
The block diagram outlines the various layer involved in the setup.
- File system should be a BTRFS file system.
- OS : Ubuntu14.04,16.04
- Snapper Version 0.1.8
- Resource requirement 4GB RAM 20GB HDD
Note:Snapper has full support in Open SUSE platform
Step-1 : Installing Snapper
Install Snapper using the below command
apt-get install snapper -y
Step-2 : Prepare script for creating Config and Mount point
Create below script with name snapperconfigandmountpoint.sh.
#Snapper with btrfs filesystem in ubuntu 14.04 ARGS=$(getopt -o a:b -l "configname:,mountpoint:" -- "$@"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--mountpoint) shift; if [ -n "$1" ]; then mountpoint=$1; shift; fi ;; --) shift; break; ;; esac done #creating a config file echo $configname echo $mountpoint snapper -c $configname create-config $mountpoint snapper list-configs
Step-3 : Run script for creating Config and Mount point
Run script using the below command. Use the same configname and mount point till the end.
bash snapperconfigandmountpoint.sh –configname –mountpoint
bash snapperconfigandmountpoint.sh –config name snapconfig –mountpoint /
snapperconfigandmountpoint.sh – script name
Snapconfig- config name
/- mount point
Step-4 : Prepare script for creating snapshot
Create below script with name Snapshotcreation.sh
ARGS=$(getopt -o a:b -l "configname:,snapshotname:" -- "$@"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--snapshotname) shift; if [ -n "$1" ]; then snapshotname=$1; shift; fi ;; --) shift; break; ;; esac done echo $configname echo $snapshotname snapper --config $configname create --description "$snapshotname " snapper --config $configname list
Step-5 : Run script to create a Snapshot using Snapper
Run script using the below command
bash snapshotcreation.sh –configname –snapshotname
bash snapshotcreation.sh –configname snapconfig –snapshotname snap1
Snapshotcreation.sh – script name
Snapconfig- config name
snap1- snapshot name
The execution with create a snapshot and list the created snapshots. Create a snapshot name of choice but ensure to provide the same config name used earlier
Step-6 : Deploy Openstack
Deploy Openstack Mitaka by following the instruction available in https://docs.openstack.org/mitaka/install-guide-ubuntu/
Step-7 : Prepare a Script to restore snapshot
Create below script with name Restore.sh for restoring the physical server to older state
ARGS=$(getopt -o a:b:c -l "configname:,state_to_revert:,state_to_modify:," -- "$@"); eval set -- "$ARGS"; while true; do case "$1" in -a|--configname) shift; if [ -n "$1" ]; then configname=$1; shift; fi ;; -b|--state_to_revert) shift; if [ -n "$1" ]; then state_to_revert=$1; shift; fi ;; -c|--state_to_modify) shift; if [ -n "$1" ]; then state_to_modify=$1; shift; fi ;; --) shift; break; ;; esac done echo $configname echo $state_to_revert echo $state_to_modify snapper -c $configname -v undochange $state_to_revert..$state_to_modify
Step-8 : Run script to restore older snapshot using Snapper
Run script using the below command specifying the config name and Snapshot number to which we need to restore.
bash restore.sh –configname –state_to_revert –state_to_modify
bash restoretest.sh –configname snapconfig –state_to_revert 1 –state_to_modify 2
If everything works correctly, you will able to deploy Openstack and restore server to original State and redeploy again and again.