[root@mg ~]# sh /root/config/glance.sh
WARNING: Bypassing authentication using a token & endpoint (authentication credentials are being ignored).
+-------------+----------------------------------+
| Property | Value | +-------------+----------------------------------+
| adminurl | http://192.168.1.2:9292 | | id | fe281515d406407bbcd4887cb5815de4 | | internalurl | http://192.168.1.2:9292 | | publicurl | http://192.168.1.2:9292 | | region | regionOne | | service_id | 7c0102f0e715479e9292c0581d214de2 | +-------------+----------------------------------+
6.3.配置Glance服务
(1).将keystone认证信息添加到glance配置文件中:
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_host 127.0.0.1
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_port 35357
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_protocol http
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password service
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_host 127.0.0.1
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_port 35357
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_protocol http
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_password service
(2).修改ini文件路径,将keystone认证信息添加到ini文件中:
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf paste_deploy config_file /etc/glance/glance-api-paste.ini
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf paste_deploy config_file /etc/glance/glance-registry-paste.ini
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
[root@openstack ~]# cp /usr/share/glance/glance-api-dist-paste.ini /etc/glance/glance-api-paste.ini
[root@openstack ~]# cp /usr/share/glance/glance-registry-dist-paste.ini /etc/glance/glance-registry-paste.ini
[root@openstack ~]# chown -R root:glance /etc/glance/glance-api-paste.ini [root@openstack ~]# chown -R root:glance /etc/glance/glance-registry-paste.ini
[root@openstack ~]# openstack-config --set /etc/glance/glance-api-paste.ini filter:authtoken auth_host 127.0.0.1
[root@openstack ~]# openstack-config --set /etc/glance/glance-api-paste.ini filter:authtoken admin_tenant_name service
[root@openstack ~]# openstack-config --set /etc/glance/glance-api-paste.ini filter:authtoken admin_user glance
[root@openstack ~]# openstack-config --set /etc/glance/glance-api-paste.ini filter:authtoken admin_password service
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry-paste.ini filter:authtoken auth_host 127.0.0.1
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry-paste.ini filter:authtoken admin_tenant_name service
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry-paste.ini filter:authtoken admin_user glance
[root@openstack ~]# openstack-config --set /etc/glance/glance-registry-paste.ini filter:authtoken admin_password service
(3).修改镜像文件的存放路径(默认存放在/var/lib/glance目录下,若不需修改,此步骤可省略)
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf DEFAULT filesystem_store_datadir /openstack/lib/glance/images/
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf DEFAULT scrubber_datadir /openstack/lib/glance/scrubber
[root@openstack ~]# openstack-config --set /etc/glance/glance-api.conf DEFAULT image_cache_dir /openstack/lib/glance/image-cache/ [root@openstack ~]# mkdir -p /openstack/lib
[root@openstack ~]# cp -r /var/lib/glance/ /openstack/lib/
[root@openstack ~]# chown -R glance:glance /openstack/lib/glance/
(4).启动glance服务,设置开机自启动
[root@openstack ~]# service openstack-glance-api start [root@openstack ~]# service openstack-glance-registry start [root@openstack ~]# chkconfig openstack-glance-api on [root@openstack ~]# chkconfig openstack-glance-registry on
6.4.Glance测试
(1).上传镜像
[root@openstack ~]# glance image-create --name=centos6.4 --disk-format=qcow2 --container-format=ovf --is-public=true < /root/centos6.4-mini_x64.qcow2
注意:(以下框住的描述可忽略)验证镜像服务的安装(Verify the Image Service installation) 为了测试镜像服务的安装,至少下载一个虚拟机镜像,这个镜像一定要能够与OpenStack一起工作。例如,CirrOS是一个很小的测试镜像,它经常用于测试OpenStack部署。这个过程,使用了64-bit的CirrOS QCOW2镜像。 有关更多如何下载和创建镜像的信息,请参考“OpenStack Virtual Machine Image Guide”,有关如何管理镜像的信息,请参考“OpenStack User Guide”. 1. 用wget或curl下载该镜像到指定的目录 $ mkdir images $ cd images/ $ wget http://cdn.download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64- disk.img 2. 上传该镜像到该镜像服务中 # glance image-create --name=imageLabel --disk-format=fileFormat \\ --container-format=containerFormat --is-public=accessValue < imageFile 参数说明: imageLabel 任意的标志,该名称由用户指向镜像。 fileFormat 说明镜像文件格式,有效的文件格式包括:qcow2,raw,vhd,vmdk,vdi,iso,aki,ari,and ami等等。 containerFormat 指定的容器格式,有效的格式包括:bare,ovf,aki,ari and ami。 指定bare格式表明镜像文件不在文件格式里,也就是说包含有关虚拟机的元数据。虽然目前这个字段是必须的,但实际上任何其它的OpenStack服务不使用它,而且在系统运行时也没有效果。因为该值在任何地方都没有用到,为了安全,一直指定bare作为容器的格式。 accessValue 指定镜像是否能访问。 true --所有的用户都能够查看和使用该镜像。 false --只有管理员才能够查看和使用该镜像 imageFile 指定你下载的镜像文件名称 注:上传出错: Request returned failure status. HTTPInternalServerError (HTTP 500) 后来查看debug,是我在配置/etc/glance/glanceregistry.conf文件时把: [paste_deploy] ... flavor = keystone 中的keystone错写成了glance 更改后,再上传,就对了,结果如下: root@controller:~/image# glance image-create --name=\--is-public=true < cirros-0.3.1-x86_64-disk.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | d972013792949d0d3ba628fbe8685bce | | container_format | bare | | created_at | 2014-03-14T10:03:34 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | 84e4056d-662f-4c88-809a-6551b9e3185a | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | CirrOS 0.3.1 | | owner | fe0f1b42a1df44bcac0b6908b96bcaae | | protected | False | | size | 13147648 | | status | active | | updated_at | 2014-03-14T10:03:35 | +------------------+--------------------------------------+ 查看glance数据库中的表images,就可以看到添加的镜像文件。 再查看/var/lib/glance/images目录下,就有一个与images表中ID号相同的文件。
(2).查看镜像
[root@openstack ~]# glance image-list
7.安装配置Nova
7.1.初始化Nova
(1).安装nova:
[root@openstack ~]# yum -y install openstack-nova