这是安装glance的官方网站:
https://docs.openstack.org/glance/queens/install/install-rdo.html#install-and-configure-components
首先建立数据库
进入mysql
mysql -u root -p
建立数据库glance
CREATE DATABASE glance;
对用户进行授权
GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@‘localhost’
IDENTIFIED BY ‘GLANCE_DBPASS’;
其中,第二个glance是用户名,GLANCE_DBPASS是给该用户设置的密码。
GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’%’
IDENTIFIED BY ‘GLANCE_DBPASS’;
GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@’%’
IDENTIFIED BY ‘GLANCE_DBPASS’;
GRANT ALL PRIVILEGES ON glance.* TO ‘glance’@‘主机名’
IDENTIFIED BY ‘GLANCE_DBPASS’;
(如果忘记主机名可以退出mysql环境用hostname命令进行查看)
然后退出mysql环境,创建glance的用户
openstack user create --domain default --password-prompt glance
将管理员角色添加到glance用户和服务项目:
openstack role add --project service --user glance admin
创建glance服务实体:
openstack service create --name glance --description “OpenStack Image” image
创建映像服务API终结点:
openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
其中,controller换成虚拟机的IP地址
下载安装包
systemctl status openstack-nova-consoleauth
进入文件进行配置
vim /etc/glance/glance-api.conf
输入/[database查找[database]
在[database]下更改
其中GLANCE_DBPASS是自己的密码,controller换成虚拟机的IP地址
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
同样,进入[keystone_authtoken],对其进入编辑:
[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 = GLANCE_PASS
其中,controller换成虚拟机的IP地址,GLANCE_PASS换成之前设置的glance的密码(在这里建议把所有学习过程中将所有密码设置为一样或者与用户名相同)
[paste_deploy]下,
flavor = keystone
[glance_store]下
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
先按esc,再按:然后按wq保存退出文件
在使用命令
vim /etc/glance/glance-registry.conf
进入该文件下
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
其中GLANCE_DBPASS是自己的密码,controller换成虚拟机的IP地址
[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 = GLANCE_PASS
其中,controller换成虚拟机的IP地址,GLANCE_PASS换成之前设置的glance的密码
[paste_deploy]下
flavor = keystone
保存退出文件后,填充映像服务数据库:
glance-manage db_sync
启动映像服务并将其配置为在系统引导时启动:
systemctl enable openstack-glance-api openstack-glance-registry
systemctl start openstack-glance-api openstack-glance-registry
好嘞,检查一下
![在这里插入图片描述](https://img-blog.csdnimg.cn/5e1f0aa8741047768c5085f1b91b0016.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAT3JpZXR0YV8xMDEy,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center