本文主要是介绍OpenStack L版官网配置转载(三),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
添加镜像服务
控制节点:
完成下面的步骤以创建数据库:
用数据库连接客户端以 root 用户连接到数据库服务器:
$ mysql -u root -p
创建 glance 数据库:
CREATE DATABASE glance;
对glance数据库授予恰当的权限:
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。
退出数据库客户端。
获得 admin 凭证来获取只有管理员能执行命令的访问权限:
$ source admin-openrc.sh
要创建服务证书,完成这些步骤:
创建 glance 用户:
$ openstack user create --domain default --password-prompt glance User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | default | | enabled | True | | id | e38230eeff474607805b596c91fa15d9 | | name | glance | +-----------+----------------------------------+
添加 admin 角色到 glance 用户和 service 项目上。
$ openstack role add --project service --user glance admin
创建glance服务实体:
$ openstack service create --name glance \ --description "OpenStack Image service" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image service | | enabled | True | | id | 8c2c7f1b9b5049ea9e63757b5533e6d2 | | name | glance | | type | image | +-------------+----------------------------------+
创建镜像服务的 API 端点:
$ openstack endpoint create --region RegionOne \ image public http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 340be3625e9b4239a6415d034e98aace | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+$ openstack endpoint create --region RegionOne \ image internal http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | a6e4b153c2ae4c919eccfdbb7dceb5d2 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+$ openstack endpoint create --region RegionOne \ image admin http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 0c37ed58103f4300a84ff125a539032d | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 8c2c7f1b9b5049ea9e63757b5533e6d2 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+
安全并配置组件
安装软件包:
# yum install openstack-glance python-glance python-glanceclient
编辑文件 /etc/glance/glance-api.conf 并完成如下动作:
在 [database] 部分,配置数据库访问:
[database] ... connection = mysql://glance:GLANCE_DBPASS@controller/glance将GLANCE_DBPASS替换为你为镜像服务选择的密码。
在 [keystone_authtoken] 和 [paste_deploy] 部分,配置认证服务访问:
[keystone_authtoken] ... auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = glance password = GLANCE_PASS[paste_deploy] ... flavor = keystone
将 GLANCE_PASS 替换为你为认证服务中你为 glance 用户选择的密码。
在 [glance_store]部分,配置本地文件系统存储和镜像文件位置:
[glance_store] ... default_store = file filesystem_store_datadir = /var/lib/glance/images/
在[DEFAULT]部分,配置 noop 禁用通知,因为他们只适合与可选的Telemetry 服务:
[DEFAULT] ... notification_driver = noopTelemetry 章节提供了一个启用消息机制的镜像服务配置。
(可选的)为帮助排错,在 “[DEFAULT]”部分启用详细日志。
[DEFAULT] ... verbose = True
编辑文件 /etc/glance/glance-registry.conf 并完成如下动作:
在 [database] 部分,配置数据库访问:
[database] ... connection = mysql://glance:GLANCE_DBPASS@controller/glance
将GLANCE_DBPASS替换为你为镜像服务选择的密码。
在 [keystone_authtoken] 和 [paste_deploy] 部分,配置认证服务访问:
[keystone_authtoken] ... auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = glance password = GLANCE_PASS[paste_deploy] ... flavor = keystone将 GLANCE_PASS 替换为你为认证服务中你为 glance 用户选择的密码。
[DEFAULT]部分,配置 noop 禁用通知,因为他们只适合与可选的Telemetry 服务:
[DEFAULT] ... notification_driver = noop
Telemetry 章节提供了一个启用消息机制的镜像服务配置。
(可选的)为帮助排错,在 “[DEFAULT]”部分启用详细日志。
[DEFAULT] ... verbose = True
写入镜像服务数据库:
# su -s /bin/sh -c "glance-manage db_sync" glance
完成安装
控制文件:
启动镜像服务、配置他们随机启动:
# systemctl enable openstack-glance-api.service \ openstack-glance-registry.service # systemctl start openstack-glance-api.service \ openstack-glance-registry.service
验证操作
控制节点:
在每个客户端脚本中,配置镜像服务客户端使用2.0的API:
$ echo "export OS_IMAGE_API_VERSION=2" \ | tee -a admin-openrc.sh demo-openrc.sh
获得 admin 凭证来获取只有管理员能执行命令的访问权限:
$ source admin-openrc.sh
下载源镜像:
$ wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
使用 QCOW2 磁盘格式, bare 容器格式上传镜像到镜像服务并设置公共可见,这样所有的项目都可以访问它:
$ glance image-create --name "cirros" \ --file cirros-0.3.4-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --visibility public --progress [=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 133eae9fb1c98f45894a4e60d8736619 | | container_format | bare | | created_at | 2015-03-26T16:52:10Z | | disk_format | qcow2 | | id | 38047887-61a7-41ea-9b49-27987d5e8bb9 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | ae7a98326b9c455588edd2656d723b9d | | protected | False | | size | 13200896 | | status | active | | tags | [] | | updated_at | 2015-03-26T16:52:10Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+
确认镜像的上传并验证属性:
$ glance image-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros | +--------------------------------------+--------+
这篇关于OpenStack L版官网配置转载(三)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!