https://docs.openstack.org/glance/train/install/
controller配置
#1
创库授权
mysql -u root -p0000
MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance0000'; # glance0000是设置的glance数据库密码
MariaDB [(none)]> exit
source admin-openrc.sh
openstack user create --domain default --password-prompt glance #设置密码,统一glance
openstack role add --project service --user glance admin
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
openstack endpoint list #查看是否配置好
yum install openstack-glance
这里可能会出bug 找不到glance包,我们需要换华为源
Error:
Problem: package openstack-glance-1:19.0.4-1.el8.noarch requires python3-glance = 1:19.0.4-1.el8, but none of the providers can be installed
- cannot install the best candidate for the job
- nothing provides python3-httplib2 needed by python3-glance-1:19.0.4-1.el8.noarch
- nothing provides python3-pyxattr needed by python3-glance-1:19.0.4-1.el8.noarch
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
yum install wget -y
cd /etc/yum.repos.d/
cp CentOS-Linux-BaseOS.repo CentOS-Linux-BaseOS.repo.bak
wget -O /etc/yum.repos.d/CentOS-Linux-BaseOS.repo https://repo.huaweicloud.com/repository/conf/CentOS-8-reg.repo
yum clean all
yum makecache
yum install openstack-glance -y
vim /etc/glance/glance-api.conf
openstack配置文件不能有中文,注释的也不行
[database]
connection = mysql+pymysql://glance:glance0000@controller/glance #glance0000是上面设置过的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 #这个是创域的密码,glance
#认证方式
[paste_deploy]
flavor = keystone
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
#同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
#启动自启服务
systemctl enable openstack-glance-api.service;systemctl start openstack-glance-api.service
#可以查看glance日志
tail -f /var/log/glance/api.log
#2
确认操作
source admin-openrc.sh
#下载镜像
wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
#上传镜像
glance image-create --name "cirros4" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public
glance image-list