OpenStack安装(二) Glance模块

一、安装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:5000
    auth_url = http://controller:35357
    auth_plugin = password
    project_domain_id = default
    user_domain_id = default
    project_name = service
    username = glance
    password = GLANCE_PASS
    复制代码
    flavor = keystone
    复制代码
  3. 修改[keystone_store]部分,配置镜像存储采用文件的形式,并且指定存储的路径:

    default_store = file
    filesystem_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:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = 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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值