制作的windows鏡像至少7G以上幢痘,通過(guò)命令行上傳(實(shí)際走的還是http通訊)服務(wù)器經(jīng)常返回502唬格。
502 Bad Gateway: Bad Gateway: The proxy server received an invalid: response from an upstream server.: Apache/2.4.18 (Ubuntu) Server at 192.168.18.61 Port 80 (HTTP 502)
經(jīng)驗(yàn)證,通過(guò)以下方式可以輕松上傳大鏡像
1.首先創(chuàng)建一個(gè)dummy文件(0 byte)
cd /opt/image/
touch dummy
2.后把dummy文件作為鏡像上傳(秒速)
glance image-create --name win7 --file /opt/image/dummy --disk-format qcow2 --container-format bare --visibility public --progress
3.查詢image id
+------------------+--------------------------------------+
| Property | Value |
+------------------+--------------------------------------+
| checksum | d41d8cd98f00b204e9800998ecf8427e |
| container_format | bare |
| created_at | 2018-05-17T01:23:36Z |
| disk_format | qcow2 |
| id | f7fbe797-184a-4c5d-ad67-67cb254539a2 |
| min_disk | 0 |
| min_ram | 0 |
| name | win7 |
| owner | 3bc17302ef9f465ba390fa036a35a34e |
| protected | False |
| size | 0 |
| status | active |
| tags | [] |
| updated_at | 2018-05-17T01:23:37Z |
| virtual_size | None |
| visibility | public |
+------------------+--------------------------------------+
4.找到glance存放image的地方
vi /etc/glance/glance-api.conf
[glance_store]
filesystem_store_datadir = /opt/stack/data/glance/images/
5.然后把真正的鏡像文件copy覆蓋f7fbe797-184a-4c5d-ad67-67cb254539a2 這個(gè)文件
cp /opt/image/win7.qcow2 f7fbe797-184a-4c5d-ad67-67cb254539a2
6.修改size
由于上傳dummy時(shí)颜说,glance計(jì)算了size和md5sum并保存數(shù)據(jù)庫(kù)了购岗,很顯然不同于真正的鏡像的計(jì)算結(jié)果。
可以通過(guò)直接修改數(shù)據(jù)的方式改過(guò)來(lái)
-rw-r--r-- 1 stack stack 7836008448 May 17 09:26 f7fbe797-184a-4c5d-ad67-67cb254539a2
把7836008448 修改到數(shù)據(jù)庫(kù)