Been running mysql server inside Amazon EC2 throught an Elastic Block store and needs to be migrated to a new instance.
The tasks include:
1. Stopping mysql server.
2. Assume /var/lib/mysql and /var/log/mysql are symbolic links to
/ebs1/MYSQLDB/var/lib/mysql and /ebs1/MYSQLDB/var/log/mysq respectively.
Create a snapshot of a volume which is attached to the running instance.
3. Create new Volume from generated snapshot.
4. Install mysql-server. Stop mysql-server first, then
5. Attach new volume to the the new running instance. /dev/sdh and mount to /ebs1 directory.
6. Configure the symlink to /var/log/mysql and /var/lib/mysql point to
/ebs1/MYSQLDB//var/log/mysql and /ebs1/MYSQLDB/var/lib/mysql repectively.
In some cases, I got the error in debian-sys-maint when starting mysql, which can easily fix
by checking the password at /etc/mysql/debian.cnf for Ubuntu machines and granting
admin permissions for this user.
I tried also attaching EBS Volumes with the same data inside and get the error:
Filesystem "sdi": Disabling barriers, not supported by the underlying device XFS: Filesystem sdi has duplicate UUID - can't mount sdi: unknown partition table<br />
Where my /etc/fstab says:
# Legacy /etc/fstab # Supplied by: ec2-ami-tools-1.3-30748 /dev/sda1 / ext3 defaults 1 1 /dev/sda2 /mnt ext3 defaults 0 0 /dev/sda3 swap swap defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 /dev/sdh /ebs1 xfs noatime 0 0 /dev/sdi /ebs2 xfs noatime 0 0
To get the /ebs2 work, I need to add nouuid to fstab options.
/dev/sdi /ebs2 xfs noatime,nouuid 0 0