OpenStack(Queens)详细安装部署(三)-镜像服务(glance)安装

本文为扶艾原创文章,版权所有,禁止转载!

本篇文章是本系列的第三篇文章,将继续进行OpenStack镜像服务的安装

四、安装镜像服务

4.1 (控制节点)配置镜像数据库

  • 连接数据库
# mysql -u root -pfuai123
  • 创建glance数据库并设置访问权限
MariaDB [(none)]> CREATE DATABASE glance;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
  IDENTIFIED BY 'fuai123';

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
  IDENTIFIED BY 'fuai123';

4.2 (控制节点)创建glance认证相关信息

  • 设置admin环境变量
# . admin-openrc
  • 创建glance用户

密码我设置的fuai123

# openstack user create --domain default --password-prompt glance

User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 0bf68fa1a87c4760859f9f34697a8753 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
  • 将glance用户加入service项目,并设置admin角色
# openstack role add --project service --user glance admin
  • 创建镜像服务
# openstack service create --name glance \
  --description "OpenStack Image" image

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | 520b45f9c795468ab50a5c7c363babef |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+
  • 创建镜像api端口
# openstack endpoint create --region RegionOne \
  image public http://controller:9292

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | ff8c65b2d96c4329a85954ed4ac13853 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 520b45f9c795468ab50a5c7c363babef |
| 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           | 5d930d23645541b3ad76c9bb29426519 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 520b45f9c795468ab50a5c7c363babef |
| 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           | e0fc9759fb7b4d4790d225aaedcdcf31 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 520b45f9c795468ab50a5c7c363babef |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

4.3 (控制节点)安装软件包并配置配置文件

  • 安装软件包
# yum install openstack-glance -y
  • 编辑/etc/glance/glance-api.conf文件并完成下面配置
[database]
connection = mysql+pymysql://glance:fuai123@controller/glance
...

[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = fuai123
...

[paste_deploy]
flavor = keystone
...

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
...
  • 编辑/etc/glance/glance-registry.conf文件,完成以下配置
[database]
connection = mysql+pymysql://glance:fuai123@controller/glance
...

[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = fuai123
...

[paste_deploy]
flavor = keystone
...

  • 同步数据库
# su -s /bin/sh -c "glance-manage db_sync" glance

4.4 (控制节点)设置服务的开机自启动,并启动服务

  • 设置服务自启,并启动服务
# systemctl enable openstack-glance-api.service \
  openstack-glance-registry.service
# systemctl start openstack-glance-api.service \
  openstack-glance-registry.service

4.5 (控制节点)验证操作
- 设置环境变量

# . admin-openrc
  • 下载镜像
# yum install wget -y
# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
  • 上传镜像
# openstack image create "cirros" \
  --file cirros-0.3.5-x86_64-disk.img \
  --disk-format qcow2 --container-format bare \
  --public

+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | f8ab98ff5e73ebab884d80c9dc9c7290                     |
| container_format | bare                                                 |
| created_at       | 2018-04-25T12:13:57Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/0466e837-7d0c-4ebd-a2a1-194e80635d98/file |
| id               | 0466e837-7d0c-4ebd-a2a1-194e80635d98                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | cirros                                               |
| owner            | c4e73f33137b49dcb1ff949f3d95de36                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 13267968                                             |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2018-04-25T12:14:58Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+
  • 确认下镜像是否成功上传
# openstack image list

+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 0466e837-7d0c-4ebd-a2a1-194e80635d98 | cirros | active |
+--------------------------------------+--------+--------+

至此,OpenStack镜像服务已经安装验证完成,下面将进行计算服务等组件的安装,具体请参见文章《OpenStack(Queens)详细安装部署(四)-计算服务(nova)安装》

更多精彩内容,OpenStack干货请扫描下方二维码,关注我们微信公众号“扶艾”!
OpenStack(Queens)详细安装部署(三)-镜像服务(glance)安装_第1张图片

你可能感兴趣的:(openstack)