openstack导入大镜像方法

修改glance-api配置,添加如下配置,如果是多副本的glance-api,都需要添加

show_image_direct_url = true 
show_multiple_locations = true

然后重启glance-api

镜像导入

root@osd001:/opt/test_vm/172.16.5.13# export IMAGE_UUID=$(uuidgen)
root@osd001:/opt/test_vm/172.16.5.13# echo $IMAGE_UUID
b3b1a856-a64c-4904-b038-59b3c9184daa
root@osd001:/opt/test_vm/172.16.5.9# ll
total 12582916
drwxrwxrwx 1 root root            0 Jun 29 14:33 ./
drwxrwxrwx 1 root root         4096 Jun 29 14:26 ../
-rwxrwxrwx 1 root root 966367641600 Jun 29 14:35 vol-data*
-rwxrwxrwx 1 root root 107374182400 Jun 29 14:30 vol-system*
root@osd001:/opt/test_vm/172.16.5.9# rdb^C
root@osd001:/opt/test_vm/172.16.5.9# export  IMAGE_FILE=vol-system 
root@osd001:/opt/test_vm/172.16.5.9# echo $IMAGE_FILE
vol-system
root@osd001:/opt/test_vm/172.16.5.9# time rbd -p images --image-format 2 import $IMAGE_FILE $IMAGE_UUID 
rbd: --pool is deprecated for import, use --dest-pool
Importing image: 100% complete...done.

real	5m27.313s
user	0m19.472s
sys	0m45.029s
root@osd001:/opt/test_vm/172.16.5.9# 


root@ctl01:~# rbd -p images snap ls $IMAGE_UUID
root@ctl01:~# rbd -p images snap create --snap snap $IMAGE_UUID
root@ctl01:~# rbd -p images snap ls $IMAGE_UUID
SNAPID NAME   SIZE TIMESTAMP                
   527 snap 100GiB Sat Jun 29 15:59:32 2019 
root@ctl01:~# rbd -p images snap protect --image $IMAGE_UUID --snap snap
root@ctl01:~# glance image-create --disk-format raw --container-format bare  --visibility public --name 172.16.5.13-data-2 --id $IMAGE_UUID
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | None                                 |
| container_format | bare                                 |
| created_at       | 2019-06-29T08:02:03Z                 |
| disk_format      | raw                                  |
| id               | b3b1a856-a64c-4904-b038-59b3c9184daa |
| locations        | []                                   |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | 172.16.5.13-data-2                   |
| owner            | 158467e017ab4e50931d8fd77106e0b7     |
| protected        | False                                |
| size             | None                                 |
| status           | queued                               |
| tags             | []                                   |
| updated_at       | 2019-06-29T08:02:03Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+
root@ctl01:~# glance location-add --url rbd://$(sudo ceph fsid)/images/$IMAGE_UUID/snap $IMAGE_UUID
+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | None                                                                             |
| container_format | bare                                                                             |
| created_at       | 2019-06-29T08:02:03Z                                                             |
| direct_url       | rbd://a893b06a-a78b-4064-89cb-                                                   |
|                  | 6bb524d655e6/images/b3b1a856-a64c-4904-b038-59b3c9184daa/snap                    |
| disk_format      | raw                                                                              |
| file             | /v2/images/b3b1a856-a64c-4904-b038-59b3c9184daa/file                             |
| id               | b3b1a856-a64c-4904-b038-59b3c9184daa                                             |
| locations        | [{"url": "rbd://a893b06a-a78b-4064-89cb-                                         |
|                  | 6bb524d655e6/images/b3b1a856-a64c-4904-b038-59b3c9184daa/snap", "metadata": {}}] |
| min_disk         | 0                                                                                |
| min_ram          | 0                                                                                |
| name             | 172.16.5.13-data-2                                                               |
| owner            | 158467e017ab4e50931d8fd77106e0b7                                                 |
| protected        | False                                                                            |
| schema           | /v2/schemas/image                                                                |
| size             | 107374182400                                                                     |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2019-06-29T08:02:35Z                                                             |
| virtual_size     | None                                                                             |
| visibility       | public                                                                           |
+------------------+----------------------------------------------------------------------------------+

上一篇:MySQL 那些常见的错误设计规范


下一篇:Linux分区、挂载