注意要 按顺序 搭建服务,在 CentOS 7 安装 Openstack Rocky 版本 - 环境搭建 的基础上安装服务。
Image service - 镜像服务(Glance)
在 控制节点 安装,这里默认是将镜像存储在本地,之后安装了存储服务再进行修改
数据库配置
连接数据库
数据库操作
1 2 3 4 5 6 7 8 9
| CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'mariadb-glance'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'mariadb-glance';
exit
|
身份认证和 API 配置
创建用户 glance
并添加到 admin
角色
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| . admin-openrc
openstack user create --domain default --password-prompt glance
openstack role add --project service --user glance admin
|
创建服务实体和服务 API 端点
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| openstack service create --name glance --description "OpenStack Image" image
openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292
|
安装和配置 glance
安装软件包
1 2
| yum install openstack-glance -y
|
修改配置文件 /etc/glance/glance-api.conf
,配置文件中有些选项是没有的,需要直接添加到相应的小节
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| [database] connection = mysql+pymysql://glance:mariadb-glance@controller/glance
[keystone_authtoken] www_authenticate_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 = glance
[paste_deploy] flavor = keystone
[glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/
|
修改另一个配置文件 /etc/glance/glance-registry.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| [database] connection = mysql+pymysql://glance:mariadb-glance@controller/glance
[keystone_authtoken] www_authenticate_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 = glance
[paste_deploy] flavor = keystone
|
启用镜像服务
1 2 3 4 5 6 7 8
| 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
|
验证
在 控制节点 上运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| . admin-openrc
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
openstack image create "cirros" \ --file cirros-0.4.0-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public
openstack image list
|
参阅