
Glanceは、ディスクまたはサーバーイメージ、およびエンドユーザーまたはOpenStackComputeからのイメージメタデータに対するAPIリクエストを受け入れます。また、OpenStackObjectStorageを含むさまざまなリポジトリタイプでのディスクまたはサーバーイメージのストレージもサポートしています。
この投稿では、コントローラーノードでOpenStackイメージサービス(Glance)を構成する方法について説明します。コントローラノードにローカルに画像を保存するように一目で設定します。先に進む前に、KeyStoneサービスが構成されていることを確認してください。
KeyStoneをまだ構成していない場合は、以下の2つの投稿を確認できます。
Ubuntu14.04.2でのOpenStackKilo-KeyStone#1の構成
Ubuntu14.04.2でのOpenStackKilo-KeyStone#2の構成
管理者およびデモユーザー用のクライアント環境スクリプトを作成します。これらのスクリプトは、クライアント操作に適切なクレデンシャルをロードするのに役立ちます。
admin-openrc.shを作成します ファイル。
# nano admin-openrc.sh
次のコンテンツをファイルに貼り付けます。
export OS_PROJECT_DOMAIN_ID=default export OS_USER_DOMAIN_ID=default export OS_PROJECT_NAME=admin export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=PASS_ADMIN export OS_AUTH_URL=http://controller:35357/v3 export OS_IDENTITY_API_VERSION=3
PASS_ADMINを置き換えます KeyStone#2で管理者ユーザー用に作成したパスワードを使用
demo-openrc.shを作成します ファイル。
# nano demo-openrc.sh
以下のコンテンツをファイルに貼り付けます。
export OS_PROJECT_DOMAIN_ID=default export OS_USER_DOMAIN_ID=default export OS_PROJECT_NAME=demo export OS_TENANT_NAME=demo export OS_USERNAME=demo export OS_PASSWORD=PASS_DEMO export OS_AUTH_URL=http://controller:5000/v3 export OS_IDENTITY_API_VERSION=3
PASS_DEMOを置き換えます KeyStone#2でデモユーザー用に作成したパスワードを使用します。
Glanceデータベースの作成:
ルートとしてMySQLデータベースサーバーにログインします。
# mysql -u root -p
一目でわかるデータベースを作成します。
CREATE DATABASE glance;
glanceデータベースへの適切なアクセスを設定します。
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'password';
パスワードを置き換えます 適切なパスワードを使用してください。
MySQLプロンプトを終了します。
サービスクレデンシャルとAPIエンドポイントを作成します:
管理者の資格情報を読み込みます。
# source admin-openrc.sh
glanceユーザーを作成します。
# openstack user create --domain default --password-prompt glance User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | default | | enabled | True | | id | ca01105cf73945ce9e93dae68158a86e | | name | glance | +-----------+----------------------------------+
glanceユーザーおよびサービスプロジェクトに管理者の役割を追加します。
# openstack role add --project service --user glance admin
Glanceサービスエンティティを作成します。
# openstack service create --name glance --description "OpenStack Image service" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image service | | enabled | True | | id | 728c9fe5ae474c6dbd943aa8f1727a49 | | name | glance | | type | image | +-------------+----------------------------------+
一目でわかるAPIエンドポイントを作成します。
# openstack endpoint create --region RegionOne image public http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 5125e46d88f047f7944c86224576b3a3 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 728c9fe5ae474c6dbd943aa8f1727a49 | | 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 | 7ade8b978fc2498eabf6d5ca62f1cdb7 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 728c9fe5ae474c6dbd943aa8f1727a49 | | 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 | d9933de493c44e8c9d3b2a515b400cb3 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 728c9fe5ae474c6dbd943aa8f1727a49 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+
Glanceのインストールと構成:
パッケージをインストールします。
# apt-get install glance python-glanceclient
/etc/glance/glance-api.confを編集します 、以下の設定を変更し、適切なセクションにエントリを配置してください。
[DEFAULT] ... notification_driver = noop verbose = True [database] ... ## Comment out below sqlite_db #sqlite_db = /var/lib/glance/glance.sqlite connection = mysql+pymysql://glance:password@controller/glance ## Replace with the password you chose for glance database [keystone_authtoken] ... 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 = password ## Replace this with the password you chose for glance user in the identity service. [paste_deploy] ... flavor = keystone [glance_store] ... default_store = file filesystem_store_datadir = /var/lib/glance/images/
/etc/glance/glance-registry.confを編集します ファイルを作成し、以下の設定を変更して、適切なセクションにエントリを配置してください。
[DEFAULT] ... notification_driver = noop verbose = True [database] ... ## Comment out below sqlite_db #sqlite_db = /var/lib/glance/glance.sqlite connection = mysql+pymysql://glance:password@controller/glance ## Replace with the password you chose for glance database [keystone_authtoken] ... 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 = password ## Replace this with the password you chose for glance user in the identity service [paste_deploy] ... flavor = keystone
glanceデータベースにデータを入力します。
# su -s /bin/sh -c "glance-manage db_sync" glance
サービスを再開します。
# service glance-registry restart # service glance-api restart
SQLiteデータベースファイルを削除します。
# rm -f /var/lib/glance/glance.sqlite
操作の確認:
ここでは、Fedora 22のクラウドイメージをOpenStack環境にアップロードして、イメージサービスを検証します。
クライアント環境スクリプトでは、APIバージョン2.0を使用するようにImageServiceクライアントを構成します。
# echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
管理者の資格情報を読み込みます。
# source admin-openrc.sh
/tmpディレクトリにUbuntuクラウドイメージをダウンロードします。
# cd /tmp # wget http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
画像をアップロードします。
# glance image-create --name "Ubuntu_Trusty_Cloud_x86_64" --file /tmp/trusty-server-cloudimg-amd64-disk1.img --disk-format qcow2 --container-format bare --visibility public --progress
以下の出力が得られます。
[=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | fefdbde09433b879198e58ef69471fab | | container_format | bare | | created_at | 2015-11-02T16:27:39Z | | disk_format | qcow2 | | id | 489ece19-2ab3-4105-9a3a-befa974dff38 | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu_Trusty_Cloud_x86_64 | | owner | fe858f6a43f84c26b994f0be74c928e6 | | protected | False | | size | 258540032 | | status | active | | tags | [] | | updated_at | 2015-11-02T16:27:47Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+
アップロードされた画像を一覧表示します。
# glance image-list +--------------------------------------+----------------------------+ | ID | Name | +--------------------------------------+----------------------------+ | 489ece19-2ab3-4105-9a3a-befa974dff38 | Ubuntu_Trusty_Cloud_x86_64 | +--------------------------------------+----------------------------+
これですべてです!!!これでGlanceが正常に構成されました。