創建endpoint
Keystone源碼中的創建腳本中並不會創建swift的endpoint,因此還需要手動創建一個:
keystone service-list
keystone endpoint-create --region RegionOne --service_id 00217d2721e94cee9f4c27c8c2f89f52 --publicurl 'http://10.61.2.12:8888/v2/AUTH_$(tenant_id)s'--adminurl 'http://10.61.2.12:8888/' --internalurl'http://10.61.2.12:8888/v2/AUTH_$(tenant_id)s'
命令中的service_id的值是通過keystone service-list查詢到的swift的id,如果原來在安裝keystone的時候沒有創建swift的service的話還需要手動創建,命令可參考sample_data.sh文件或者運行keystone help service-create
添加環境變量
需要在原來的.openstackrc中添加一個ST_USER變量,這裏ST_USER中的service表示用戶所在的tenant,nova表示用戶名,現在的內容如下
export OS_USERNAME=nova
export ST_USER=service:nova
export OS_PASSWORD=service123
export OS_TENANT_NAME=service
export OS_AUTH_URL=http://127.0.0.1:5000/v2.0
簡單測試
1. 列出當前狀態
2. 創建一個名爲mycontainer的container並上傳小文件install.tar.gz
3. 分片並行上傳大於5G的大文件x6402.GHO到mycontainer,swift默認單個文件最大5G,對於大於5G的文件必須分片上傳,如下命令是將將7G的大文件分成1G大小的片斷上傳,上傳時間大約十分鐘
4. 列出mycontainer中的文件
5. 下載小文件
6. 下載大文件,時間約爲4分鐘
7. 刪除文件
Glance更改及測試
Glance原來採用的是文件系統存儲,現在swift已經搭好當然得讓glance用上。首先刪除OpenStack中所有的測試實例,刪除glance中所有的測試鏡像。
修改配置文件
修改/etc/glance/glance-api.conf以下選項
defualt_store = swift
swift_store_auth_address = http://127.0.0.1:5000/v2.0/
swift_store_user = service:glance
swift_store_key = service123
swift_store_create_container_on_put = True
重啓glance
glance-control all restart
上傳鏡像
glance addname="tty-linux-kernel" disk_format=aki container_format=aki <ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz
glance add name="tty-linux-ramdisk" disk_format=aricontainer_format=ari < ttylinux-uec-amd64-12.1_2.6.35-22_1-loader
glance add name="tty-linux" disk_format=ami container_format=amikernel_id=b4c7e967-2830-45ed-a353-47712242b9c4ramdisk_id=ee36a367-0a5e-421e-9b04-89c5a3920e71 < ttylinux-uec-amd64-12.1_2.6.35-22_1.img
啓動一個實例
修改創建實例時找不到鏡像的問題,方法如下:
https://github.com/openstack/glance/commit/fa82103f1cdb9bb26473df3a4ee9ddc077c0541e
vim /usr/lib/python2.6/site-packages/glance-2012.1-py2.6.egg/glance/store/swift.py按下圖修改