インストールと設定

インストールと設定

このセクションでは、コントローラーノードに Image service (コード名 glance) をインストールして設定する方法を説明します。簡単のため、この設定ではイメージをローカルファイルシステムに保存します。

前提条件

Image service をインストールして設定する前に、データベース、サービスクレデンシャル、API エンドポイントを作成する必要があります。

  1. データベースを作成するには、これらの手順をすべて実行します。

    • データベースクライアントを使用して、データベースサーバーに root ユーザーとして接続します。

      $ mysql -u root -p
      
    • glance データベースを作成します。

      mysql> CREATE DATABASE glance;
      
    • glance データベースに適切なアクセス権を付与します。

      mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
        IDENTIFIED BY 'GLANCE_DBPASS';
      mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
        IDENTIFIED BY 'GLANCE_DBPASS';
      

      GLANCE_DBPASS を適切なパスワードに置き換えます。

    • データベースクライアントを終了します。

  2. admin クレデンシャルを読み込み、管理者専用 CLI コマンドへのアクセス権を取得します。

    $ . admin-openrc
    
  3. 以下の手順を実行して、サービスクレデンシャルを作成します。

    • glance ユーザーを作成します。

      $ openstack user create --domain default --password-prompt glance
      
      User Password:
      Repeat User Password:
      +---------------------+----------------------------------+
      | Field               | Value                            |
      +---------------------+----------------------------------+
      | domain_id           | default                          |
      | enabled             | True                             |
      | id                  | 3f4e777c4062483ab8d9edd7dff829df |
      | name                | glance                           |
      | password_expires_at | None                             |
      +---------------------+----------------------------------+
      
    • admin ロールを glance ユーザーと service プロジェクトに追加します。

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

      注釈

      このコマンドは何も出力しません。

    • glance サービスエンティティーを作成します。

      $ openstack service create --name glance \
        --description "OpenStack Image" image
      
      +-------------+----------------------------------+
      | Field       | Value                            |
      +-------------+----------------------------------+
      | description | OpenStack Image                  |
      | enabled     | True                             |
      | id          | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
      | name        | glance                           |
      | type        | image                            |
      +-------------+----------------------------------+
      
  4. Image service の API エンドポイントを作成します。

    $ openstack endpoint create --region RegionOne \
      image public http://controller:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 340be3625e9b4239a6415d034e98aace |
    | interface    | public                           |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller:9292           |
    +--------------+----------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      image internal http://controller:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | a6e4b153c2ae4c919eccfdbb7dceb5d2 |
    | interface    | internal                         |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller:9292           |
    +--------------+----------------------------------+
    
    $ openstack endpoint create --region RegionOne \
      image admin http://controller:9292
    
    +--------------+----------------------------------+
    | Field        | Value                            |
    +--------------+----------------------------------+
    | enabled      | True                             |
    | id           | 0c37ed58103f4300a84ff125a539032d |
    | interface    | admin                            |
    | region       | RegionOne                        |
    | region_id    | RegionOne                        |
    | service_id   | 8c2c7f1b9b5049ea9e63757b5533e6d2 |
    | service_name | glance                           |
    | service_type | image                            |
    | url          | http://controller:9292           |
    +--------------+----------------------------------+
    

コンポーネントのインストールと設定

注釈

設定ファイルのデフォルトは、ディストリビューションにより異なります。これらの既存のセクションとオプションを編集するのではなく、追加する必要があるかもしれません。また、設定のスニペットにある 省略 (...) は、保持すべきデフォルトの設定オプションを意味します。

  1. パッケージをインストールします。

    # apt install glance
    
  1. /etc/glance/glance-api.conf ファイルを編集し、以下の作業をすべて行います。

    • [database] セクションで、データベースのアクセス方法を設定します。

      [database]
      ...
      connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
      

      GLANCE_DBPASS を Image service データベース用に選んだパスワードで置き換えます。

    • [keystone_authtoken] セクションと [paste_deploy] セクションで、Identity サービスへのアクセス方法を設定します。

      [keystone_authtoken]
      ...
      auth_uri = http://controller:5000
      auth_url = http://controller:35357
      memcached_servers = controller: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_PASS を Identity において glance ユーザー用に選択したパスワードで置き換えます。

      注釈

      [keystone_authtoken] セクションにある他のオプションは、コメントアウトまたは削除します。

    • [glance_store] セクションにおいて、ローカルファイルシステムストアおよびイメージファイルの場所を設定します。

      [glance_store]
      ...
      stores = file,http
      default_store = file
      filesystem_store_datadir = /var/lib/glance/images/
      
  2. /etc/glance/glance-registry.conf ファイルを編集し、以下の作業をすべて行います。

    • [database] セクションで、データベースのアクセス方法を設定します。

      [database]
      ...
      connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
      

      GLANCE_DBPASS を Image service データベース用に選んだパスワードで置き換えます。

    • [keystone_authtoken] セクションと [paste_deploy] セクションで、Identity サービスへのアクセス方法を設定します。

      [keystone_authtoken]
      ...
      auth_uri = http://controller:5000
      auth_url = http://controller:35357
      memcached_servers = controller: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_PASS を Identity において glance ユーザー用に選択したパスワードで置き換えます。

      注釈

      [keystone_authtoken] セクションにある他のオプションは、コメントアウトまたは削除します。

  1. Image サービスデータベースを展開します。

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

    注釈

    この出力の廃止予定に関するメッセージはすべて無視してください。

インストールの最終作業

  1. Image サービスのサービスを再起動します。

    # service glance-registry restart
    # service glance-api restart
    
Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.