本篇文章是本系列的第三篇文章,将继续进行OpenStack镜像服务的安装
4.1 (控制节点)配置镜像数据库
# mysql -u root -pfuai123
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-openrc
密码我设置的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 |
+---------------------+----------------------------------+
# 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 |
+-------------+----------------------------------+
# 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
[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/
...
[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)安装》