OpenStack(Queens)详细安装部署(三)-镜像服务(glance)安装
OpenStack(Queens)详细安装部署(三)-镜像服务(glance)安装 原创: 扶艾 码农这些事儿 5月10日 本文为扶艾原创文章,版权所有,禁止转载!
本篇文章是本系列的第三篇文章,将继续进行OpenStack镜像服务的安装 四、安装镜像服务
4.1 (控制节点)配置镜像数据库
连接数据库
1# mysql -u root -pfuai123
创建glance数据库并设置访问权限
1MariaDB [(none)]> CREATE DATABASE glance; 2 3MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ 4 IDENTIFIED BY 'fuai123'; 5 6MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ 7 IDENTIFIED BY 'fuai123';
4.2 (控制节点)创建glance认证相关信息
设置admin环境变量
1# . admin-openrc
创建glance用户
密码我设置的fuai123
1# openstack user create --domain default --password-prompt glance 2 3User Password: 4Repeat User Password: 5+---------------------+----------------------------------+ 6| Field | Value | 7+---------------------+----------------------------------+ 8| domain_id | default | 9| enabled | True |
10| id | 0bf68fa1a87c4760859f9f34697a8753 | 11| name | glance | 12| options | {} | 13| password_expires_at | None | 14+---------------------+----------------------------------+
将glance用户加入service项目,并设置admin角色
1# openstack role add --project service --user glance admin
创建镜像服务
1# openstack service create --name glance \ 2 --description "OpenStack Image" image 3 4+-------------+----------------------------------+ 5| Field | Value | 6+-------------+----------------------------------+ 7| description | OpenStack Image | 8| enabled | True | 9| id | 520b45f9c795468ab50a5c7c363babef |
10| name | glance | 11| type | image | 12+-------------+----------------------------------+
创建镜像api端口
1# openstack endpoint create --region RegionOne \ 2 image public http://controller:9292 3 4+--------------+----------------------------------+ 5| Field | Value | 6+--------------+----------------------------------+ 7| enabled | True | 8| id | ff8c65b2d96c4329a85954ed4ac13853 | 9| interface | public |
10| region | RegionOne | 11| region_id | RegionOne | 12| service_id | 520b45f9c795468ab50a5c7c363babef | 13| service_name | glance | 14| service_type | image | 15| url | http://controller:9292 | 16+--------------+----------------------------------+ 17 18# openstack endpoint create --region RegionOne \ 19 image internal http://controller:9292 20 21+--------------+----------------------------------+ 22| Field | Value | 23+--------------+----------------------------------+ 24| enabled | True | 25| id | 5d930d23645541b3ad76c9bb29426519 | 26| interface | internal | 27| region | RegionOne | 28| region_id | RegionOne | 29| service_id | 520b45f9c795468ab50a5c7c363babef | 30| service_name | glance | 31| service_type | image | 32| url | http://controller:9292 | 33+--------------+----------------------------------+ 34 35# openstack endpoint create --region RegionOne \ 36 image admin http://controller:9292 37 38+--------------+----------------------------------+ 39| Field | Value | 40+--------------+----------------------------------+ 41| enabled | True | 42| id | e0fc9759fb7b4d4790d225aaedcdcf31 | 43| interface | admin | 44| region | RegionOne | 45| region_id | RegionOne | 46| service_id | 520b45f9c795468ab50a5c7c363babef | 47| service_name | glance | 48| service_type | image | 49| url | http://controller:9292 | 50+--------------+----------------------------------+ 51
4.3 (控制节点)安装软件包并配置配置文件
安装软件包
1# yum install openstack-glance -y
编辑/etc/glance/glance-api.conf文件并完成下面配置
1[database] 2connection = mysql+pymysql://glance:fuai123@controller/glance 3... 4 5[keystone_authtoken] 6auth_uri = http://controller:5000 7auth_url = http://controller:5000 8memcached_servers = controller:11211 9auth_type = password
10project_domain_name = Default 11user_domain_name = Default 12project_name = service 13username = glance 14password = fuai123 15... 16 17[paste_deploy] 18flavor = keystone 19... 20 21[glance_store] 22stores = file,http 23default_store = file 24filesystem_store_datadir = /var/lib/glance/images/ 25...
编辑/etc/glance/glance-registry.conf文件,完成以下配置
1[database] 2connection = mysql+pymysql://glance:fuai123@controller/glance 3... 4 5[keystone_authtoken] 6auth_uri = http://controller:5000 7auth_url = http://controller:5000 8memcached_servers = controller:11211 9auth_type = password 10project_domain_name = Default 11user_domain_name = Default 12project_name = service 13username = glance 14password = fuai123 15... 16 17[paste_deploy] 18flavor = keystone 19...
同步数据库
1# su -s /bin/sh -c "glance-manage db_sync" glance
4.4 (控制节点)设置服务的开机自启动,并启动服务
设置服务自启,并启动服务
1# systemctl enable openstack-glance-api.service \ 2 openstack-glance-registry.service 3# systemctl start openstack-glance-api.service \ 4 openstack-glance-registry.service
4.5 (控制节点)验证操作 - 设置环境变量
1# . admin-openrc
下载镜像
1# yum install wget -y 2# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
上传镜像
1# openstack image create "cirros" \ 2 --file cirros-0.3.5-x86_64-disk.img \ 3 --disk-format qcow2 --container-format bare \ 4 --public 5 6+------------------+------------------------------------------------------+ 7| Field | Value | 8+------------------+------------------------------------------------------+ 9| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
10| container_format | bare | 11| created_at | 2018-04-25T12:13:57Z | 12| disk_format | qcow2 | 13| file | /v2/images/0466e837-7d0c-4ebd-a2a1-194e80635d98/file | 14| id | 0466e837-7d0c-4ebd-a2a1-194e80635d98 | 15| min_disk | 0 | 16| min_ram | 0 | 17| name | cirros | 18| owner | c4e73f33137b49dcb1ff949f3d95de36 | 19| protected | False | 20| schema | /v2/schemas/image | 21| size | 13267968 | 22| status | active | 23| tags | | 24| updated_at | 2018-04-25T12:14:58Z | 25| virtual_size | None | 26| visibility | public | 27+------------------+------------------------------------------------------+
确认下镜像是否成功上传
1# openstack image list 2 3+--------------------------------------+--------+--------+ 4| ID | Name | Status | 5+--------------------------------------+--------+--------+ 6| 0466e837-7d0c-4ebd-a2a1-194e80635d98 | cirros | active | 7+--------------------------------------+--------+--------+
至此,OpenStack镜像服务已经安装验证完成,下面将进行计算服务等组件的安装,具体请参见文章《OpenStack(Queens)详细安装部署(四)-计算服务(nova)安装》
更多精彩内容,OpenStack干货请扫描下方二维码,关注我们微信公众号“扶艾”!
微信扫一扫 关注该公众号