openstack team mailing list archive
-
openstack team
-
Mailing list archive
-
Message #21637
So you ran stack.sh...
I thought I would send this out since I did not see anything on it already.
If you are running devstack and accidentally run stack.sh you will lose
your LVMs and all configuration. Sure there is that one line you can edit
in stack.sh to not delete LVMs, but it still drops the db so you lose your
configuration anyhow.
Don't panic all is not lost.
Your data is probably still there. Linux does not “clear” data, it merely
marks it as unallocated.
The LVM config files are stored in /etc/lvm/ prior files are in
/etc/lvm/archive .
If you run ls in /etc/lvm/archive notice the files are called
volume_group_XXX.vg
root@stack-1:/etc/lvm/archive# ls -altr
-rw------- 1 root root 1587 Mar 4 12:57 stack-volumes_00069.vg
-rw------- 1 root root 1237 Mar 4 12:57 stack-volumes_00070.vg
-rw------- 1 root root 1524 Mar 5 10:25 stack-volumes_00072.vg
-rw------- 1 root root 805 Mar 5 10:25 stack-volumes_00071.vg
Open a file and look for volume groups that contain your data, look for
volume size or the description line stating “Created *before*…"
root@stack-1:/etc/lvm/archive# grep description *
stack-volumes_00069.vg:description = "Created *before* executing 'lvremove
-f stack-volumes/volume-d767236b-b1c2-4511-ad59-b503a01b24ba'"
Restore the volumes using vgcfgrestore .
root@stack-1:/etc/lvm/archive# vgcfgrestore stack-volumes -f
stack-volumes_00069.vg
Verify they are online using lvscan
root@stack-1:/dev/stack-volumes# lvscan
ACTIVE '/dev/stack-volumes/volume-f7c1d207-8688-4b1e-a8fd-dbe67c923da2'
[10.00 GiB]
ACTIVE '/dev/stack-volumes/volume-d767236b-b1c2-4511-ad59-b503a01b24ba'
[20.00 GiB]
ACTIVE '/dev/stack-volumes/volume-73bd1860-8940-4091-8539-c4251b7b0823'
[20.00 GiB]
ACTIVE '/dev/stack-volumes/volume-0d649e69-3c76-44c9-8e5a-bc0a331820c1'
[40.00 GiB]
Now time to recreate database entries. Use nova list to pick an image to
create a new image.
root@stack-1:/dev/stack-volumes# nova image-list
+--------------------------------------+--------------------------------------+--------+
| ID | Name
| Status |
+--------------------------------------+--------------------------------------+--------+
| 2606f66c-29f0-4dcb-abf4-b19519dd4835 | precise-server-cloudimg-amd64
| ACTIVE |
| 716ae8a4-08aa-46ba-8d80-654d93e193af |
precise-server-cloudimg-amd64-kernel | ACTIVE |
+--------------------------------------+--------------------------------------+--------+
Cinder create
root@stack-1:/dev/stack-volumes# cinder create --image-id
2606f66c-29f0-4dcb-abf4-b19519dd4835 --display-name example-volume 20
+---------------------+--------------------------------------+
| Property | Value |
+---------------------+--------------------------------------+
| attachments | [] |
| availability_zone | nova |
| bootable | false |
| created_at | 2013-03-05T20:06:35.616902 |
| display_description | None |
| display_name | example-name |
| id | f52dc1ea-b6da-4aab-8464-50a1a11840b1 |
| image_id | 2606f66c-29f0-4dcb-abf4-b19519dd4835 |
| metadata | {} |
| size | 20 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| volume_type | None |
+---------------------+--------------------------------------+
Nova image
root@stack-1:/dev/stack-volumes# nova boot
--image=2606f66c-29f0-4dcb-abf4-b19519dd4835 --flavor 2
--block-device-mapping vda=f52dc1ea-b6da-4aab-8464-50a1a11840b1 --key-name
joem-openstack-key example-instance
+------------------------+--------------------------------------+
| Property | Value |
+------------------------+--------------------------------------+
| status | BUILD |
| updated | 2013-03-05T21:08:07Z |
| OS-EXT-STS:task_state | scheduling |
| key_name | joem-openstack-key |
| image | precise-server-cloudimg-amd64 |
| hostId | |
| OS-EXT-STS:vm_state | building |
| flavor | m1.small |
| id | 74f88463-aba9-4208-86ed-ad24f1052d0c |
| security_groups | [{u'name': u'default'}] |
| user_id | 4473cecb13f746a88f08bfaab19ce828 |
| name | example-instance |
| adminPass | sbK3vbeTDCch |
| tenant_id | 40931001789540ca955d353f3c42bcfc |
| created | 2013-03-05T21:08:07Z |
| OS-DCF:diskConfig | MANUAL |
| accessIPv4 | |
| accessIPv6 | |
| progress | 0 |
| OS-EXT-STS:power_state | 0 |
| metadata | {} |
| config_drive | |
+------------------------+--------------------------------------+
Stop the VM
root@stack-1:~# nova list
+--------------------------------------+-------------------------+--------+-----------------------------------+
| ID | Name | Status |
Networks |
+--------------------------------------+-------------------------+--------+-----------------------------------+
| 74f88463-aba9-4208-86ed-ad24f1052d0c | example-instance | ACTIVE |
private=10.11.12.2, 192.168.157.2 |
+--------------------------------------+-------------------------+--------+-----------------------------------+
root@stack-1:~# nova stop 74f88463-aba9-4208-86ed-ad24f1052d0c
Copy old data to new LVM.
root@stack-1:~# cd /dev/stack-volumes/
root@stack-1:/dev/stack-volumes# ls -1
volume-0d649e69-3c76-44c9-8e5a-bc0a331820c1
volume-73bd1860-8940-4091-8539-c4251b7b0823
volume-d767236b-b1c2-4511-ad59-b503a01b24ba
volume-f52dc1ea-b6da-4aab-8464-50a1a11840b1
volume-f7c1d207-8688-4b1e-a8fd-dbe67c923da2
root@stack-1:/dev/stack-volumes# mkdir /mnt/source ; mkdir /mnt/dest
root@stack-1:/dev/stack-volumes# mount –o ro
volume-d767236b-b1c2-4511-ad59-b503a01b24ba /mnt/source
root@stack-1:/dev/stack-volumes# mount
volume-f52dc1ea-b6da-4aab-8464-50a1a11840b1 /mnt/dest
root@stack-1:/dev/stack-volumes# cp –vr --preserve=all /mnt/source/*
/mnt/dest
root@stack-1:/dev/stack-volumes# umount /mnt/dest; umount /dev/source
Restart
root@stack-1:/dev/stack-volumes# nova start
74f88463-aba9-4208-86ed-ad24f1052d0c
Now that I typed all of that, someone will chime in pointing out a tool
that already exists and reimports LVMs to openstack...
Hope this helps someone out.
Cheers,
-Joe