我要评分
获取效率
正确性
完整性
易理解

Installing, Configuring, and Verifying Glance

Glance provides a catalog service for storing and querying virtual disk images of VM instances. Nova computing service components can use this service when VM instances are running.

Install, configure, and verify Glance on controller nodes.

Creating the Glance Database

  1. Access the MySQL database.
    1
    mysql -u root -p
    
  2. Create a database for Glance.
    1
    CREATE DATABASE glance;
    
  3. Grant proper access to the database, set the PASSWORD for accessing the database, and run the exit command to exit the database.
    1
    2
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '<PASSWORD>';
    GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '<PASSWORD>';
    

Creating Roles and Users

  1. Log in to the OpenStack CLI as the admin user.
    1
    source /etc/keystone/admin-openrc
    
  2. Create the glance user.
    1
    openstack user create --domain default --password-prompt glance
    
  3. Add the role to the project and user.
    1
    openstack role add --project service --user glance admin
    

  4. Creates a service entity.
    1
    openstack service create --name glance --description "OpenStack Image" image
    
  5. Create API endpoints of the Image service.
    1
    openstack endpoint create --region RegionOne image public http://controller:9292
    

    1
    2
    openstack endpoint create --region RegionOne image internal http://controller:9292
    openstack endpoint create --region RegionOne image admin http://controller:9292
    

Installing and Configuring Glance

  1. Install Glance using Yum.
    1
    yum -y install openstack-glance
    
  2. Edit the /etc/glance/glance-api.conf file.
    1. Configure database access in the [database] section.
      1
      2
      [database]
      connection = mysql+pymysql://glance:<PASSWORD>@controller/glance
      

      Set PASSWORD to the password for accessing the Glance database.

    2. Configure Identity service access in [keystone_authtoken] and [paste_deploy] sections.
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      [keystone_authtoken]
      www_authenticate_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 = <PASSWORD>
      [paste_deploy]
      flavor = keystone
      

      PASSWORD indicates the password of the Glance user.

    3. In the [glance_store] section, configure the location where image files are stored in the local file system.
      1
      2
      3
      4
      [glance_store]
      stores = file,http
      default_store = file
      filesystem_store_datadir = /var/lib/glance/images/
      
  3. Edit the /etc/glance/glance-registry.conf file and make the following changes:
    1. In the [database] section, configure database access.
      1
      2
      [database]
      connection = mysql+pymysql://glance:<PASSWORD>@controller/glance
      
    2. Configure Identity service access in [keystone_authtoken] and [paste_deploy] sections.
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      [keystone_authtoken]
      www_authenticate_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 = <PASSWORD>
      [paste_deploy]
      flavor = keystone
      
  4. Populate the Image service database.
    1
    su -s /bin/sh -c "glance-manage db_sync" glance
    

  5. Enable the Image service and configure it to start as the system boots.
    1
    2
    systemctl enable openstack-glance-api.service openstack-glance-registry.service
    systemctl start openstack-glance-api.service openstack-glance-registry.service
    

Verifying Glance

  1. Source the admin credentials to gain access to admin-only CLI commands.
    1
    source /etc/keystone/admin-openrc
    
  2. Download the image.

    Go to the /var/lib/glance/images directory.

    1
    wget https://download.cirros-cloud.net/0.5.2/cirros-0.5.2-arm-disk.img
    
  3. Upload the image to Glance.
    1
    openstack image create "cirros-0.5.2" --file cirros-0.5.2-arm-disk.img --disk-format qcow2 --container-format bare --public
    
  4. Confirm the uploaded image and its attributes.
    1
    openstack image list
    

    The image upload procedure is for reference only. In actual scenarios, you can create a VM image as required and upload the image to the controller node.