Glance是OpenStack镜像服务组件,该组件提供虚拟机镜像的发现,注册,取得服务。通过Glance,虚拟机镜像可以被存储到多种存储上,比如简单的文件存储或者对象存储。Glance 组件完成镜像模板、快照的存储工作。Glance 主要包括了glance-api 和glaneregistry两个服务。
3.1 Install the Image Service(安装镜像服务)
3.1.1 在控制节点上安装glance服务
# yum install openstack-glance python-glanceclient
3.1.2 登陆mysql,为glance创建数据库
$ mysql -u root -p mysql> CREATE DATABASE glance; mysql> GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘localhost‘ IDENTIFIED BY ‘glance‘; mysql> GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘%‘ IDENTIFIED BY ‘glance‘;
3.1.3 修改glance的配置文件,修改数据库的连接
# openstack-config --set /etc/glance/glance-api.conf database connection mysql://glance:[email protected]/glance # openstack-config --set /etc/glance/glance-registry.conf database connection mysql://glance:[email protected]/glance
3.1.4 为镜像服务创建数据库表
# su -s /bin/sh -c "glance-manage db_sync" glance
3.1.5 创建一个glance用户,并且将这个用户添加到admin角色中
# keystone user-create --name=glance --pass=glance [email protected] # keystone user-role-add --user=glance --tenant=service --role=admin
3.1.6 配置镜像服务,从而可以正常的使用身份认证服务
# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller:5000 # openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_host controller # openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_port 35357 # openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_protocol http # openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service # openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance # openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password glance # openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone # openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller:5000 # openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_host controller # openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_port 35357 # openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_protocol http # openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service # openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance # openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_password glance # openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
3.1.7 注册服务并且创建端点(endpoint)
# keystone service-create --name=glance --type=image --description="OpenStack Image Service" # keystone endpoint-create --service-id=$(keystone service-list | awk ‘/ image / {print $2}‘) --publicurl=http://controller:9292 --internalurl=http://controller:9292 --adminurl=http://controller:9292
3.1.8 启动glance服务,并且加入到开机自动启动。
# service openstack-glance-api start # service openstack-glance-registry start # chkconfig openstack-glance-api on # chkconfig openstack-glance-registry on
3.2Verify the Image Service installation(验证镜像服务的安装)
3.2.1 创建一个目录,并且下载
# mkdir /tmp/images # cd /tmp/images/ # wget http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img
3.2.2 上传并且制作镜像,创建成功之后会显示出镜像的信息
# source admin.sh # glance image-create --name "cirros-0.3.2-x86_64" --disk-format qcow2 --container-format bare --is-public True --progress < cirros-0.3.2-x86_64-disk.img
+------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 87h7c1cd2b6f60c92c9966skjkks7326 | | container_format | bare | | created_at | 2015-08-12T15:00:18 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | asjkd7d3-78kl-3783-7873-b878784e1fj3 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | cirros-0.3.2-x86_64 | | owner | efa984b0a914450e9a47788ad330699d | | protected | False | | size | 13167616 | | status | active | | updated_at | 2015-08-12T15:00:18 | +------------------+--------------------------------------+
3.2.3 查看镜像
$ glance image-list
+--------------------------------------+---------------------+-------------+------------------+----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +--------------------------------------+---------------------+-------------+------------------+----------+--------+ | asjkd7d3-78kl-3783-7873-b878784e1fj3 | cirros-0.3.2-x86_64 | qcow2 | bare | 13167616 | active | +--------------------------------------+---------------------+-------------+------------------+----------+--------+
3.2.4 到此为止,镜像服务已经安装完成,并且成功完成了镜像的注册。
时间: 2024-11-18 06:57:21