• openstack setup demo Image service


    Image service (glance)是openstack中管理vm image的service。本文包含以下内容:

    • overview
    • install

    overview

    glance包含以下部分

    glance-api
    是glance的API接口。用户通过该接口发现,调用以及存取vm image。

    glance-registry
    主要用于处理存储vm image的metadata,如size,type。该service是openstack的内部服务。

    database
    存储 image metadata 。通常用mysql

    Storage repository for image files
    Storage repository 主要用来存储vm image。glance支持多种存储如 normal file systems, Object Storage, RADOS block devices, HTTP, and Amazon S3。

    Metadata definition service
    vendors, admins, services, and users可以自定义metadata。

    install

    install部分包括

    >* prerequisite
    >* keystone 设置
    >* install and configure
    >* verify
    

    prerequisite

    首先要为glance创建数据库

    mysql -u root -p
    CREATE DATABASE glance;
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' 
      IDENTIFIED BY 'GLANCE_DBPASS';
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' 
      IDENTIFIED BY 'GLANCE_DBPASS';
    

    keystone 设置

    在keystone中创建glance用户

    . admin-openrc
    openstack user create --domain default --password-prompt glance
    

    为glance用户在service project中添加admin role

    openstack role add --project service --user glance admin
    

    创建glance service

    openstack service create --name glance 
      --description "OpenStack Image" image
    

    为glance service 创建end points

    openstack endpoint create --region RegionOne image public http://controller01:9292
    openstack endpoint create --region RegionOne image internal http://controller01:9292
    openstack endpoint create --region RegionOne image admin http://controller01:9292
    

    install and configure

    安装package

    yum install openstack-glance
    

    编辑文件 /etc/glance/glance-api.conf。配置glance-api 注意替换密码为你所使用的密码

    [database]
    ...
    connection = mysql+pymysql://glance:GLANCE_DBPASS@controller01/glance
    
    [keystone_authtoken]
    ...
    auth_uri = http://controller01:5000
    auth_url = http://controller01:35357
    memcached_servers = controller01: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]
    ...
    stores = file,http
    default_store = file
    filesystem_store_datadir = /var/lib/glance/images/
    

    编辑文件/etc/glance/glance-registry.conf 配置glanceregistry

    [database]
    ...
    connection = mysql+pymysql://glance:GLANCE_DBPASS@controller01/glance
    
    [keystone_authtoken]
    ...
    auth_uri = http://controller01:5000
    auth_url = http://controller01:35357
    memcached_servers = controller01: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 数据库

    su -s /bin/sh -c "glance-manage db_sync" glance
    

    对glance api,register服务启动并设置开机启动

    systemctl enable openstack-glance-api.service openstack-glance-registry.service
    systemctl start openstack-glance-api.service openstack-glance-registry.service
    

    verify

    要verify最好的办法是用glance管理vm image试一下。首先下载一个image。

    # load keystone 环境变量
    . admin-openrc
    # 下载一个小的image
    wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
    

    upload image

    openstack image create "cirros" 
      --file cirros-0.3.4-x86_64-disk.img 
      --disk-format qcow2 --container-format bare 
      --public
    

    查看image

    openstack image list
    

    如果能够看见刚刚的vm镜像则说明没问题。

  • 相关阅读:
    nodejs 的序列化与反序列化
    Visual Studio 监视与快速监视即时窗口没有智能提示
    mysql 备份数据语句
    mysql 导入sql 2006
    MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
    怎么查看mysql的安装目录
    【支付宝】退款接口 报 “缺少签名参数”
    【支付宝】"验签出错,sign值与sign_type参数指定的签名类型不一致:sign_type参数值为RSA,您实际用的签名类型可能是RSA2"
    【支付宝】支付 系统繁忙,请稍后再试(ALIN10146)
    php插入日志到数据库,对象转json
  • 原文地址:https://www.cnblogs.com/kramer/p/5545778.html
Copyright © 2020-2023  润新知