Newer
Older
# Copying `/var/lib/mysql` to a New Volume and Volume Migration
This documentation provides step-by-step instructions for copying the `/var/lib/mysql` directory to a new volume and migrating the volume from one OpenStack node to another using OpenStack commands.
## Prerequisites
- Access to an OpenStack environment with the necessary permissions to create volumes and manage instances.
- A running OpenStack node with an instance containing the `/var/lib/mysql` directory.
1. Log in to the OpenStack command-line interface (CLI) or a terminal with OpenStack CLI access.
openstack volume create --size <new_volume_size> <new_volume_name>
3. Attach the new volume to the instance that contains the `/var/lib/mysql` directory:
openstack server add volume <instance_id> <new_volume_id>
ssh <instance_ip_address>
sudo mkdir /mnt/new_volume
sudo mount /dev/vdb /mnt/new_volume
5. Copy the contents of `/var/lib/mysql` to the new volume:
sudo cp -a /var/lib/mysql/* /mnt/new_volume
1. Detach the original volume from the instance:
openstack server remove volume <instance_id> <original_volume_id>
openstack server create --flavor <instance_flavor> --image <instance_image> --availability-zone <target_availability_zone> --volume <original_volume_id> <new_instance_name>
3. Wait for the new instance to be in the ACTIVE state:
openstack server show <new_instance_id> -f value -c status
sudo mkdir /mnt/original_volume
sudo mount /dev/vdb /mnt/original_volume