class="area">
上一篇电脑知识吧的小编写了:“OpenStack云系统搭建之安装篇--控制节点安装配置一(云搭建1)”,今天电脑知识吧的小编继续为大家分享的是:“OpenStack云系统搭建之安装篇--控制节点安装配置二---(云搭建2)”,具体如下:添加 Image 服务 安装和配置本节介绍如何安装和配置 Image 服务,代号为 glance,在控制器节点上。为简单起见,此存储镜像配置为本地文件系统。 配置的先决条件 在您安装和配置镜像服务之前,您必须创建一个数据库和身份服务终端凭据。1、创建数据库,完成这些步骤A.登陆数据库:$ mysql -u root -p B.创建 glance 数据库:CREATE DATABASE glance; C.授予权限:GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY ' GLANCE_DBPASS';GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY ' GLANCE_DBPASS';用一个合适的密码替换 GLANCE_DBPASS。flush privileges; //刷新MySQL的系统权限D.退出数据库 2、执行 admin 凭证脚本文件,凭证脚本文件在《OpenStack云系统搭建之安装篇--控制节点安装配置一》配置完成。$ source admin-openrc.sh
3、创建身份服务凭据 A.创建 glance 用户:$ keystone user-create --name glance --pass GLANCE_PASS+----------+----------------------------------+| Property | Value |+----------+----------------------------------+| email | || enabled | True || id | f89cca5865dc42b18e2421fa5f5cce66 || name | glance || username | glance |+----------+----------------------------------用一个合适的密码替换 GLANCE_PASS。 B.将 glance 用户链接到 service 租户和 admin 角色:$ keystone user-role-add --user glance --tenant service --role admin C.创建 glance 服务:$ keystone service-create --name glance --type image \--description "OpenStack Image Service"+-------------+----------------------------------+| Property | Value |+-------------+----------------------------------+| description | OpenStack Image Service || enabled | True || id | 23f409c4e79f4c9e9d23d809c50fbacf || name | glance || type | image |+-------------+----------------------------------+ 4、创建身份服务端点$ keystone endpoint-create --service-id $(keystone service-list | awk '/ image / {print $2}') --publicurl http://controller:9292 --internalurl http://controller:9292 --adminurl http://controller:9292 --region regionOne+-------------+----------------------------------+| Property | Value |+-------------+----------------------------------+| adminurl | http://controller:9292 || id | a2ee818c69cb475199a1ca108332eb35 || internalurl | http://controller:9292 || publicurl | http://controller:9292 || region | regionOne || service_id | 23f409c4e79f4c9e9d23d809c50fbacf |+-------------+----------------------------------+ 安装和配置 Image 服务组件1、安装包# yum install openstack-glance python-glanceclient 2、编辑/etc/glance/glance-api.conf 文件A.在[database]部分,配置数据库访问:[database]connection = mysql://glance: GLANCE_DBPASS@controller/glanceGLANCE_DBPASS 替换为您选择的镜像服务数据库密码。B.在[ keystone_authtoken ]和[ paste_deploy ]部分,配置身份服务访问:[keystone_authtoken]auth_uri = http://controller:5000/v2.0identity_uri = http://controller:35357admin_tenant_name = serviceadmin_user = glanceadmin_password = GLANCE_PASS [paste_deploy]flavor = keystone GLANCE_PASS 替换为您选择的 glance 用户密码。 请注意注释掉任何 auth_host 、auth_port、auth_protocol 选项,因为 identity_uri 选项 将替换他们。 C.(可选)在[DEFAULT]部分,启用详细记录来帮助解决问题 [DEFAULT]verbose = True 3、编辑/etc/glance/glance-registry.conf 文件A.在[database]部分,配置数据库访问:[database]connection = mysql://glance: GLANCE_DBPASS@controller/glanceGLANCE_DBPASS 替换为您选择的镜像服务数据库密码。
B.在[keystone_authtoken]和[paste_deploy]部分,配置身份服务访问:[keystone_authtoken]auth_uri = http://controller:5000/v2.0identity_uri = http://controller:35357admin_tenant_name = serviceadmin_user = glanceadmin_password = GLANCE_PASS
[paste_deploy]flavor = keystone GLANCE_PASS 替换为您选择的 glance 用户身份服务密码。 请注意注释掉任何 auth_host、 auth_port、auth_protocol 选项,因为 identity_uri 选项 将替换他们。 C.在[DEFAULT]部分,启用详细的日志记录,来协助排除潜在的故障:[DEFAULT]verbose = True 4、填充 Image 服务数据库# su -s /bin/sh -c "glance-manage db_sync" glance 完成安装•启动镜像服务和配置随系统启动:# systemctl enable openstack-glance-api.service# systemctl enable openstack-glance-registry.service# systemctl start openstack-glance-api.service# systemctl start openstack-glance-registry.service
验证操作本节描述如何使用 CirrOS 验证镜像服务,一个小的 Linux 镜像可以帮助测试你的.OpenStack 部署。1、创建和切换到一个本地临时目录$ mkdir /tmp/images$ cd /tmp/images 2、下载镜像到本地的临时目录中$ wget http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img 3、执行 admin 凭证文件$ source admin-openrc.sh 4、上传镜像到镜像服务$ glance image-create --name "cirros-0.3.3-x86_64" --file cirros-0.3.3- x86_64-disk.img --disk-format qcow2 --container-format bare --is-public True --progress[=============================>] 100%+------------------+--------------------------------------+| Property | Value |+------------------+--------------------------------------+| checksum | 133eae9fb1c98f45894a4e60d8736619 || container_format | bare || created_at | 2014-10-10T13:14:42 || deleted | False || deleted_at | None || disk_format | qcow2 || id | acafc7c0-40aa-4026-9673-b879898e1fc2 || is_public | True || min_disk | 0 || min_ram | 0 || name | cirros-0.3.3-x86_64 || owner | ea8c352d253443118041c9c8b8416040 || protected | False || size | 13200896 || status | active || updated_at | 2014-10-10T13:14:43 || virtual_size | None |+------------------+--------------------------------------+ 5、确定镜像上传和验证属性$ glance image-list+--------------------------------------+---------------------+-------------+------------------+----------+--------+| ID | Name | Disk Format| Container Format | Size | Status |+--------------------------------------+---------------------+-------------+------------------+----------+--------+| acafc7c0-40aa-4026-9673-b879898e1fc2 | cirros-0.3.3-x86_64 | qcow2| bare | 13200896 | active |+--------------------------------------+---------------------+-------------+------------------+----------+--------+ 6、删除本地临时目录$ rm -r /tmp/images