1、确认要清理的镜像
root@node-32:~# openstack image list |grep -i centos6.7
| e0641ee5-74fc-4340-b6b3-42a5df98a594 | centos6.7 |
| 0e93c4a0-43a5-4873-ad5f-ebca6024246a | Centos6.7 |
2、备份
root@node-32:~# openstack image save --file images-old/Centos6.7.raw 0e93c4a0-43a5-4873-ad5f-ebca6024246a
3、删除
root@node-32:~/images-old# openstack image delete 0e93c4a0-43a5-4873-ad5f-ebca6024246a
409 Conflict: Image 0e93c4a0-43a5-4873-ad5f-ebca6024246a could not be deleted because it is in use: The image cannot be deleted because it is in use through the backend store outside of Glance. (HTTP 409)
root@node-32:~# rbd snap ls images/0e93c4a0-43a5-4873-ad5f-ebca6024246a
SNAPID NAME SIZE
2359 snap 6144 MB
root@node-32:~/images-old# rbd children images/0e93c4a0-43a5-4873-ad5f-ebca6024246a@snap
compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
root@node-32:~/images-old# rbd status compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
Watchers: none
4、备份快照/子卷
root@node-32:~/images-old# rbd export -p compute --image 4f317869-c88b-4798-9869-f275e6ddb5ea_disk
Exporting image: 100% complete...done.
root@node-32:~/images-old# ls
4f317869-c88b-4798-9869-f275e6ddb5ea_disk ubuntu-redis-v2.raw
5、确认子卷状态
root@node-32:~# rbd children images/0e93c4a0-43a5-4873-ad5f-ebca6024246a@snap
compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
root@node-32:~# rbd info compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
rbd image '4f317869-c88b-4798-9869-f275e6ddb5ea_disk':
size 15360 MB in 1920 objects
order 23 (8192 kB objects)
block_name_prefix: rbd_data.2d04ad729da976
format: 2
features: layering, striping
flags:
parent: images/0e93c4a0-43a5-4873-ad5f-ebca6024246a@snap
overlap: 6144 MB
stripe unit: 8192 kB
stripe count: 1
root@node-32:~# rbd info compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
rbd image '4f317869-c88b-4798-9869-f275e6ddb5ea_disk':
size 15360 MB in 1920 objects
order 23 (8192 kB objects)
block_name_prefix: rbd_data.2d04ad729da976
format: 2
features: layering, striping
flags:
parent: images/0e93c4a0-43a5-4873-ad5f-ebca6024246a@snap
overlap: 6144 MB
stripe unit: 8192 kB
stripe count: 1
You have new mail in /var/mail/root
root@node-32:~# cinder list --all |grep 4f317869-c88b
You have new mail in /var/mail/root
root@node-32:~# rados ls -p compute |grep 4f317869-c88b
rbd_id.4f317869-c88b-4798-9869-f275e6ddb5ea_disk
root@node-32:~# glance image-show 0e93c4a0-43a5-4873-ad5f-ebca6024246a
+------------------+----------------------------------------------------------------------------------+
| Property | Value |
+------------------+----------------------------------------------------------------------------------+
| checksum | 5a1807daba68f049e24136ea1966ec70 |
| container_format | bare |
| created_at | 2016-08-10T05:38:35Z |
| description | |
| direct_url | rbd://e0954af1-2185-4a95-ae24-0e61ee658718/images/0e93c4a0-43a5-4873-ad5f- |
| | ebca6024246a/snap |
| disk_format | raw |
| id | 0e93c4a0-43a5-4873-ad5f-ebca6024246a |
| min_disk | 6 |
| min_ram | 512 |
| name | Centos6.7 |
| owner | 9ef6a87bfd4646928543ed8080a242d6 |
| protected | False |
| size | 6442450944 |
| status | active |
| tags | [] |
| updated_at | 2016-09-01T02:35:26Z |
| virtual_size | None |
| visibility | private |
+------------------+----------------------------------------------------------------------------------+
You have new mail in /var/mail/root
mysql> use nova;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+--------------------------------------------+
| Tables_in_nova |
+--------------------------------------------+
| agent_builds |
| aggregate_hosts |
| aggregate_metadata |
| aggregates |
| block_device_mapping |
| bw_usage_cache |
| cells |
| certificates |
| compute_nodes |
| console_pools |
| consoles |
| dns_domains |
| fixed_ips |
| floating_ips |
| instance_actions |
| instance_actions_events |
| instance_extra |
| instance_faults |
| instance_group_member |
| instance_group_policy |
| instance_groups |
| instance_id_mappings |
| instance_info_caches |
| instance_metadata |
| instance_system_metadata |
| instance_type_extra_specs |
| instance_type_projects |
| instance_types |
| instances |
| key_pairs |
| migrate_version |
| migrations |
| networks |
| pci_devices |
| project_user_quotas |
| provider_fw_rules |
| quota_classes |
| quota_usages |
| quotas |
| reservations |
| s3_images |
| security_group_default_rules |
| security_group_instance_association |
| security_group_rules |
| security_groups |
| services |
| shadow_agent_builds |
| shadow_aggregate_hosts |
| shadow_aggregate_metadata |
| shadow_aggregates |
| shadow_block_device_mapping |
| shadow_bw_usage_cache |
| shadow_cells |
| shadow_certificates |
| shadow_compute_nodes |
| shadow_console_pools |
| shadow_consoles |
| shadow_dns_domains |
| shadow_fixed_ips |
| shadow_floating_ips |
| shadow_instance_actions |
| shadow_instance_actions_events |
| shadow_instance_extra |
| shadow_instance_faults |
| shadow_instance_group_member |
| shadow_instance_group_policy |
| shadow_instance_groups |
| shadow_instance_id_mappings |
| shadow_instance_info_caches |
| shadow_instance_metadata |
| shadow_instance_system_metadata |
| shadow_instance_type_extra_specs |
| shadow_instance_type_projects |
| shadow_instance_types |
| shadow_instances |
| shadow_key_pairs |
| shadow_migrate_version |
| shadow_migrations |
| shadow_networks |
| shadow_pci_devices |
| shadow_project_user_quotas |
| shadow_provider_fw_rules |
| shadow_quota_classes |
| shadow_quota_usages |
| shadow_quotas |
| shadow_reservations |
| shadow_s3_images |
| shadow_security_group_default_rules |
| shadow_security_group_instance_association |
| shadow_security_group_rules |
| shadow_security_groups |
| shadow_services |
| shadow_snapshot_id_mappings |
| shadow_snapshots |
| shadow_task_log |
| shadow_virtual_interfaces |
| shadow_volume_id_mappings |
| shadow_volume_usage_cache |
| snapshot_id_mappings |
| snapshots |
| tags |
| task_log |
| virtual_interfaces |
| volume_id_mappings |
| volume_usage_cache |
+--------------------------------------------+
105 rows in set (0.00 sec)
mysql> select * from instances where id='4f317869-c88b-4798-9869-f275e6ddb5ea'
-> ;
Empty set (0.01 sec)
mysql> select * from instances where instance_id='4f317869-c88b-4798-9869-f275e6ddb5ea';
ERROR 1054 (42S22): Unknown column 'instance_id' in 'where clause'
mysql> select * from instances where uuid='4f317869-c88b-4798-9869-f275e6ddb5ea'\G;
*************************** 1. row ***************************
created_at: 2016-08-22 05:36:07
updated_at: 2016-08-25 02:35:35
deleted_at: 2016-08-25 02:35:35
id: 39261
internal_id: NULL
user_id: 274e46fcac7d4e89971f30f59b9876d1
project_id: 74f3bf2affa8443bbcd77b51173bf0de
image_ref: 0e93c4a0-43a5-4873-ad5f-ebca6024246a
kernel_id:
ramdisk_id:
launch_index: 0
key_name: NULL
key_data: NULL
power_state: 1
vm_state: deleted
memory_mb: 8192
vcpus: 2
hostname: centos6
host: node-34.domain.tld
user_data: NULL
reservation_id: r-s170c1br
scheduled_at: NULL
launched_at: 2016-08-22 05:36:13
terminated_at: 2016-08-25 02:35:35
display_name: centos6
display_description: centos6
availability_zone: nova
locked: 0
os_type: NULL
launched_on: node-31.domain.tld
instance_type_id: 780
vm_mode: NULL
uuid: 4f317869-c88b-4798-9869-f275e6ddb5ea
architecture: NULL
root_device_name: /dev/vda
access_ip_v4: NULL
access_ip_v6: NULL
config_drive:
task_state: NULL
default_ephemeral_device: NULL
default_swap_device: NULL
progress: 0
auto_disk_config: 1
shutdown_terminate: 0
disable_terminate: 0
root_gb: 15
ephemeral_gb: 0
cell_name: NULL
node: node-34.domain.tld
deleted: 39261
locked_by: NULL
cleaned: 1
ephemeral_key_uuid: NULL
1 row in set (0.00 sec)
ERROR:
No query specified
mysql> exit
6、确认、删除
root@node-32:~# rbd snap ls images/0e93c4a0-43a5-4873-ad5f-ebca6024246a
SNAPID NAME SIZE
2359 snap 6144 MB
root@node-32:~# rbd children images/0e93c4a0-43a5-4873-ad5f-ebca6024246a@snap
compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
root@node-32:~# rbd status compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
Watchers: none
You have new mail in /var/mail/root
root@node-32:~# rbd rm compute/4f317869-c88b-4798-9869-f275e6ddb5ea_disk
Removing image: 100% complete...done.
root@node-32:~# openstack image list |grep -i centos6.7
| e0641ee5-74fc-4340-b6b3-42a5df98a594 | centos6.7 |
| 0e93c4a0-43a5-4873-ad5f-ebca6024246a | Centos6.7 |
root@node-32:~# openstack image delete 0e93c4a0-43a5-4873-ad5f-ebca6024246a
root@node-32:~# openstack image list |grep -i centos6.7
| e0641ee5-74fc-4340-b6b3-42a5df98a594 | centos6.7 |