





创建 glance 数据库
Controller node 安装
#登录数据库
mysql -uroot -p
#创建glance数据库
MariaDB [(none)]>CREATE DATABASE glance;
#赋予glance账号权限
MariaDB [(none)]>GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost'
IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%'
IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> exit
Bye
服务注册授权
创建 glance 账号-认证
#在default域中创建glance账号
[root@controller ~]# openstack user create --domain default --password GLANCE_PASS glance
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | dfafcd5780384c7a89e37086ef1ff9c4 |
| name | glance |
| options | {} |
| password_expires_at | None | +---------------------+----------------------------------+
给 glance 账号分配 admin 角色-授权
[root@controller ~]# openstack role add --project service --user glance admin
❝
注解:这个命令执行后没有输出。
❞
注册名字为 glance 的 image 类型服务
[root@controller ~]# openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | a60a10e69e3149c9b719e76f3129d77d |
| name | glance |
| type | image |
+-------------+----------------------------------+
创建 Image 服务的 API 端点
访问 API 端点:
-
public 外部网络访问 -
internal 内部网络访问 -
admin 管理访问
#查看当前Region
[root@controller ~]# openstack region list
+-----------+---------------+-------------+
| Region | Parent Region | Description |
+-----------+---------------+-------------+
| RegionOne | None | |
+-----------+---------------+-------------+
#创建glance镜像服务API public端点(暴露于外部的api)
[root@controller ~]# openstack endpoint create --region RegionOne
> image public http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | edbc503ffeef42a19eba4416445d09c2 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne | | service_id | a60a10e69e3149c9b719e76f3129d77d |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
#创建glance镜像服务API internal端点(暴露于内部的api)
[root@controller ~]# openstack endpoint create --region RegionOne
> image internal http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 346fd9edb2db44988b16fab733e0fc41 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a60a10e69e3149c9b719e76f3129d77d |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
#创建glance镜像服务API admin端点(管理api)
[root@controller ~]# openstack endpoint create --region RegionOne
>image admin http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | d0c45662a0cd489fbd2aa22c2b9b2916 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a60a10e69e3149c9b719e76f3129d77d |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
安装配置 glance 组件
Controller node 安装
安装 glance 软件包
[root@controller ~]# yum install openstack-glance -y
编辑 /etc/glance/glance-api.conf
「配置文件」
手工修改配置文件
[root@controller ~]# cd /etc/glance/
#修改前先备份
[root@controller glance]# cp -a glance-api.conf glance-api.conf.bak
#删除空行及注释行
[root@controller glance]# sed -i '/^$/d;/^#/d' glance-api.conf
[root@controller glance]#vim glance-api.conf
-
在[database]段,配置数据库访问
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
-
在[keystone_authtoken]
「段」[paste_deploy]
「段,配置认证服务访问:」
[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
[paste_deploy]
flavor = keystone
-
在[glance_store]段,配置本地文件系统存储和镜像文件位置
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
命令行方式修改配置文件
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
编辑/etc/glance/glance-registry.conf
配置文件
手工修改配置文件
在[database]段,配置数据库访问
[root@controller glance]# cp -a glance-registry.conf glance-registry.conf.bak
[root@controller glance]# sed -i '/^$/d;/^#/d' glance-registry.conf
[root@controller glance]#vim glance-registry.conf
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
在[keystone_authtoken]
「段」[paste_deploy]
「段,配置认证服务访问:」
[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
[paste_deploy]
flavor = keystone
命令行方式修改配置文件
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://controller:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name Default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-registry.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-registry.conf glance_store default_store file
openstack-config --set /etc/glance/glance-registry.conf glance_store filesystem_store_datadir /var/lib/glance/images/
同步 glance 数据库
#临时使用glance账号把数据同步到glance数据库
[root@controller glance]# su -s /bin/sh -c "glance-manage db_sync" glance
#查询glance数据库,存在数据即为成功
[root@controller glance]# mysql glance -e 'show tables;'
+----------------------------------+
| Tables_in_glance |
+----------------------------------+
| alembic_version |
| image_locations |
| image_members |
| image_properties |
| image_tags |
| images |
| metadef_namespace_resource_types |
| metadef_namespaces |
| metadef_objects |
| metadef_properties |
| metadef_resource_types |
| metadef_tags |
| migrate_version |
| task_info |
| tasks |
+----------------------------------+
启动 glance 相关服务
启动相关服务
[root@controller glance]# systemctl enable openstack-glance-api.service
> openstack-glance-registry.service
[root@controller glance]# systemctl start openstack-glance-api.service
openstack-glance-registry.service
验证服务启动状态
[root@controller glance]# ss -lntp |grep glance
LISTEN 0 128 *:9191 *:* users:(("glance-re
gistry",pid=6817,fd=4),("glance-registry",pid=6816,fd=4),("glance-registry",pid=6795,fd=4))
LISTEN 0 128 *:9292 *:* users:(("glance-ap
i",pid=6819,fd=4),("glance-api",pid=6818,fd=4),("glance-api",pid=6794,fd=4))
❝
「glance」-api 端口:tcp9292「glance」-registry 端口:tcp9191
❞


扫描二维码获取
更多精彩

带米的笨老头

原文始发于微信公众号(带米的笨老头):
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之家整理,本文链接:https://www.bmabk.com/index.php/post/20833.html