OpenStack安装(二) Glance模块
发布日期:2021-08-25 15:35:07 浏览次数:10 分类:技术文章

本文共 2999 字,大约阅读时间需要 9 分钟。

一、安装Glance前的准备

1. 为Glance创建数据库

  1. 使用数据库客户端,以root用户身份连接到数据库中:mysql -u root -p
  2. 创建Glance数据库:CREATE DATABASE glance;
  3. 为Glance用户授予数据库权限:
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';

2. 创建Glance的身份认证证书

  1. 加载admin用户的客户端脚本:source admin-openrc.sh
  2. 创建glance用户:openstack user create --password-prompt glance
  3. 将admin角色添加给glance用户和service项目:openstack role add --project service --user glance admin
  4. 创建glance的服务实体:
    openstack service create --name glance --description "OpenStack Image service" image
  5. 创建镜像服务的API endpoint:
    openstack endpoint creat --publicurl http://controller:9292 --internalurl http://controller:9292 --adminurl http://controller:9292 --region RegionOne image

二、安装和配置Glance

1. 安装Glance

在Controller节点上进行安装

  1. 安装Glance:apt-get install -y glance python-glanceclient

2. 配置Glance-api

编辑文件/etc/glance/glance-api.conf

小助手:删除#和空格的命令:cat file | grep -v '^#' | grep -v '^$' > newfile connection = mysql://glance:GLANCE_DBPASS@controller/glance

  1. 修改[database]部分,配置数据库的连接:connection = mysql://glance:GLANCE_DBPASS@controller/glance

  2. 修改[keystone_authtoken]和[paste_deploy]两部分, 配置身份认证服务访问:

    auth_uri = http://controller:5000auth_url = http://controller:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = glancepassword = GLANCE_PASS复制代码
    flavor = keystone复制代码
  3. 修改[keystone_store]部分,配置镜像存储采用文件的形式,并且指定存储的路径:

    default_store = filefilesystem_store_datadir = /var/lib/glance/images/复制代码
  4. 在[DEFAULT]部分,配置noop禁用通知驱动,因为这是为telemetry测量服务保留的:

    notification_driver = noop复制代码
  5. 在[DEFAULT]部分启用日志详细信息记录:

    verbose = True复制代码

3. 配置Glance-registry

编辑文件/etc/glance/glance-registry.conf

  1. 修改[database]部分,配置数据库的连接:connection = mysql://glance:GLANCE_DBPASS@controller/glance
  2. 修改[keystone_authtoken]和[paste_deploy]两部分, 配置身份认证服务访问:
auth_uri = http://controller:5000auth_url = http://controller:35357auth_plugin = passwordproject_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = glancepassword = GLANCE_PASS复制代码
  1. 在[DEFAULT]部分,配置noop禁用通知驱动,因为这是为telemetry测量服务保留的:
notification_driver = noop复制代码
  1. 在[DEFAULT]部分启用日志详细信息记录:
verbose = True复制代码

4. 配置Glance数据库

  1. 为镜像服务数据库添加数据:su -s /bin/sh -c "glance-manage db_sync" glance
  2. 重启镜像服务Glance:service glance-registry restart service glance-api restart
  3. 删除ubuntu默认创建的SQLite数据库:rm -f /var/lib/glance/glance.sqlite

三、校验Glance安装

使用CirrOS镜像做测试,因为CirrOS非常小,所以常被用来做测试

  1. 编辑admin和demo的脚本文件,添加新的操作系统环境变量:
    echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
  2. 加载admin客户端脚本:source admin-openrc.sh
  3. 创建临时目录:mkdir /tmp/images
  4. 下载测试镜像到该目录:
    wget -P /tmp/images http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
  5. 使用QCOW2的磁盘格式和bare的容器格式将镜像上传到glance镜像服务中,并且设置为对所有的项目可见:
    glance image-create --name "cirros-0.3.4-x86_64" --file /tmp/images/cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public --progress
  6. 验证镜像是否上传成功以及查看属性:glance image-list
  7. 可选:删除测试镜像目录:rm -r /tmp/images

转载地址:https://blog.csdn.net/weixin_33858336/article/details/87961382 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:资源 | 我们从8800个机器学习开源项目中精选出Top30,推荐给你
下一篇:设计模式系列4--生成器模式

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年04月22日 14时57分04秒