zoukankan      html  css  js  c++  java
  • Centos7 install Openstack

    Centos7 install Openstack - (第三节)添加镜像服务(Glance)

    我的blog地址:http://www.cnblogs.com/caoguo

    该文根据openstack官方文档配置

    官方文档地址: http://docs.openstack.org/juno/install-guide/install/yum/content/#

    0x01. 基本安装配置(控制节点)

    一) To configure prerequisites 
    1. To create the database, complete these steps:(在数据创建该服务需要使用的数据库帐户)

    [root@controller ~]# mysql -uroot -p
    MariaDB [(none)]> CREATE DATABASE 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';

    2. 加载admin环境变量

    [root@controller ~]# source admin-openrc.sh



    3. To create the service credentials, complete these steps:

      a. Create the glance user:  #在认证服务中创建一个glance的帐户

    [root@controller ~]# keystone user-create --name glance --pass GLANCE_PASS
    +----------+----------------------------------+
    | Property | Value |
    +----------+----------------------------------+
    | email | |
    | enabled | True |
    | id | b5eb644a0049459c9f1b1bb87eaa2f35 |
    | name | glance |
    | username | glance |
    +----------+----------------------------------+

       

      


      b. Add the admin role to the glance user:   #将用户添加至admin用户组 service租户中

    [root@controller ~]# keystone user-role-add --user glance --tenant service --role admin


      c. Create the glance service entiry:

    [root@controller ~]# keystone service-create --name glance --type image 
    --description "OpenStack Image Service"
    +-------------+----------------------------------+
    | Property | Value |
    +-------------+----------------------------------+
    | description | OpenStack Image Service |
    | enabled | True |
    | id | 95b4d1e8cee046ada8e131cdef6d01da |
    | name | glance |
    | type | image |
    +-------------+----------------------------------+



    4. Create the Image Service API endpoints:  #创建镜像服务api

    [root@controller ~]# keystone endpoint-create 
    --service-id $(keystone service-list | awk '/ image / {print $2}') 
    --publicurl http://controller:9292 
    --internalurl http://controller:9292 
    --adminurl http://controller:9292 
    --region regionOne
    

      



    二) To install and configure the Image Service components
    1. Install the packages:  # 安装镜像服务软件包

    [root@controller ~]# yum install -y openstack-glance python-glanceclient

    2. Edit the /etc/glance/glance-api.conf file

    [root@controller ~]# cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.old
    [root@controller ~]# vi /etc/glance/glance-api.conf   # 在配置文件节点下新增配置
    [database]
    connection = mysql://glance:GLANCE_DBPASS@controller/glance
    
    [keystone_authtoken]
    auth_uri = http://controller:5000/v2.0
    identity_uri = http://controller:35357
    admin_tenant_name = service
    admin_user = glance
    admin_password = GLANCE_PASS
    
    [paste_deploy]
    flavor = keystone
    
    [glance_store]
    default_store = file
    filesystem_store_datadir = /var/lib/glance/images/
    
    [DEFAULT]
    notification_driver = noop


    3. Edit the /etc/glance/glance-registry.conf file

    [root@controller ~]# cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.old
    [root@controller ~]# vi /etc/glance/glance-registry.conf
    [database]
    connection = mysql://glance:GLANCE_DBPASS@controller/glance
    
    [keystone_authtoken]
    auth_uri = http://controller:5000/v2.0
    identity_uri = http://controller:35357
    admin_tenant_name = service
    admin_user = glance
    admin_password = GLANCE_PASS
    
    [paste_deploy]
    flavor = keystone
    
    [DEFAULT]
    notification_driver = noop
    verbose = True



    4. Populate the Image Service database: # 镜像服务数据同步

    [root@controller ~]# su -s /bin/sh -c "glance-manage db_sync" glance


    三)To finalize installation(收尾工作)

    [root@controller ~]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
    [root@controller ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service

    0x02. 确认以上操作
      1. Create and change into a temporary local directory: # 创建一个临时目录

    [root@controller ~]# mkdir /tmp/images

      2. Download the image to the temporary local directory: # 下载一个测试镜像

    [root@controller ~]# yum install -y wget
    [root@controller ~]# wget -P /tmp/images http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img


      3. Source the admin credentials to gain access to admin-only CLI commands: # 导入admin环境变量

    [root@controller ~]# source admin-openrc.sh

      4. Upload the image to the Image Service: # 上传镜像文件

    [root@controller ~]# glance image-create --name "cirros-0.3.3-x86_64" --file /tmp/images/cirros-0.3.3-x86_64-disk.img 
    --disk-format qcow2 --container-format bare --is-public True --progress
    [=============================>] 100%
    +------------------+--------------------------------------+
    | Property | Value |
    +------------------+--------------------------------------+
    | checksum | 133eae9fb1c98f45894a4e60d8736619 |
    | container_format | bare |
    | created_at | 2015-11-01T10:16:39 |
    | deleted | False |
    | deleted_at | None |
    | disk_format | qcow2 |
    | id | 833b50a1-167e-4968-8d8e-27799ad4c52a |
    | is_public | True |
    | min_disk | 0 |
    | min_ram | 0 |
    | name | cirros-0.3.3-x86_64 |
    | owner | f42937a2fd484d638ce58e67fef59b67 |
    | protected | False |
    | size | 13200896 |
    | status | active |
    | updated_at | 2015-11-01T10:16:40 |
    | virtual_size | None |
    +------------------+--------------------------------------+

      5. Confirm upload for image and validate attributes: # 查看当前已经上传成功的镜像

    [root@controller ~]# glance image-list
    +--------------------------------------+---------------------+-------------+------------------+----------+--------+
    | ID | Name | Disk Format | Container Format | Size | Status |
    +--------------------------------------+---------------------+-------------+------------------+----------+--------+
    | 74da30a6-8e15-4b11-807c-2eba444e6a54 | cirros-0.3.3-x86_64 | qcow2 | bare | 13200896 | active |
    +--------------------------------------+---------------------+-------------+------------------+----------+--------+

      6. Remove the temporary local directory:

    [root@controller ~]# rm -r /tmp/images
    rm: descend into directory ‘/tmp/images’? y
    rm: remove regular file ‘/tmp/images/cirros-0.3.3-x86_64-disk.img’? y
    rm: remove directory ‘/tmp/images’? y

    结束!!!

    更多精彩请访问:http://www.cnblogs.com/caoguo

  • 相关阅读:
    a标签上window.location.href无法跳转
    Directive指令的scope配置项使用说明
    Echarts 里面获取纵坐标刻度的间距
    使用 Supervsior 守护进程
    linux 下的快捷键操作
    前端必须掌握的 nginx 技能(4)
    在 vue 中用 transition 实现轮播效果
    前端必须掌握的 nginx 技能(3)
    前端必须掌握的 nginx 技能(2)
    前端必须掌握的 nginx 技能(1)
  • 原文地址:https://www.cnblogs.com/caoguo/p/4937323.html
Copyright © 2011-2022 走看看