OpenStack中部署glance的步驟


 

OpenStack中部署glance的步驟(基於Ubuntu14.04系統)

   author:headsen  chen   2017-10-13   08:34:35  

個人原創,轉載請注明作者,出處,否則依法追究法律責任

 

1,在數據庫里創建glance的數據庫和glance用戶,並進行授權。

MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'localhost' identified by 'openstack';
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> grant all privileges on glance.* to 'glance'@'%' identified by 'openstack';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

 

2,獲得 admin 憑證來獲取只有管理員能執行的命令的訪問權限:

root@controller:~# . admin-openrc

 

3,要創建服務證書,完成這些步驟:

 創建 glance 用戶(密碼也設置為openstack):

root@controller:~# openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:

 

添加 admin 角色到 glance 用戶和 service 項目上(這個命令執行完成后無輸出)

root@controller:~# openstack role add --project service --user glance admin

創建``glance``服務實體:

root@controller:~# openstack service create --name glance \
> --description "OpenStack Image" image

 

4,創建鏡像服務的 API 端點:

 root@controller:~# openstack endpoint create --region RegionOne \

> image public http://controller:9292

 

root@controller:~# openstack endpoint create --region RegionOne \
> image internal http://controller:9292

root@controller:~# openstack endpoint create --region RegionOne \
> image admin http://controller:9292

 

5,安裝glance的軟件包:

root@controller:~# apt-get install glance

 

6,修改配置文件:

  • 在 [database] 部分,配置數據庫訪問:

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

    將``GLANCE_DBPASS`` 替換為你為鏡像服務選擇的密碼(openstack)。

  • 在 [keystone_authtoken] 和 [paste_deploy] 部分,配置認證服務訪問:

    [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 -----------替換為你為認證服務中你為 glance 用戶選擇的密碼。 [paste_deploy] ... flavor = keystone 

     

  • 在 [glance_store] 部分,配置本地文件系統存儲和鏡像文件位置:

    [glance_store]
    ... stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/


    7,
    編輯文件 ``/etc/glance/glance-registry.conf``並完成如下動作:
    • 在 [database] 部分,配置數據庫訪問:

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

      將``GLANCE_DBPASS`` 替換為你為鏡像服務選擇的密碼。

    • 在 [keystone_authtoken] 和 [paste_deploy] 部分,配置認證服務訪問:

      [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


      8,
      寫入鏡像服務數據庫:
      # su -s /bin/sh -c "glance-manage db_sync" glance

       

      9,完成安裝

    • # service glance-registry restart
    • # service glance-api restart
    •  
                      

      10,驗證操作

        
      1. 使用 admin 憑證來獲取只有管理員能執行的命令的訪問權限:

        $ . admin-openrc
        
      2. 下載源鏡像:

        $ wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
        

         如果您的發行版里沒有包含wget,請安裝它

      3. 使用 QCOW2 磁盤格式, bare 容器格式上傳鏡像到鏡像服務並設置公共可見,這樣所有的項目都可以訪問它:

        $ openstack image create "cirros" \ --file cirros-0.3.4-x86_64-disk.img \ --disk-format qcow2 --container-format bare \ --public +------------------+------------------------------------------------------+ | Property | Value | +------------------+------------------------------------------------------+ | checksum | 133eae9fb1c98f45894a4e60d8736619 | | container_format | bare | | created_at | 2015-03-26T16:52:10Z | | disk_format | qcow2 | | file | /v2/images/cc5c6982-4910-471e-b864-1098015901b5/file | | id | cc5c6982-4910-471e-b864-1098015901b5 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | ae7a98326b9c455588edd2656d723b9d | | protected | False | | schema | /v2/schemas/image | | size | 13200896 | | status | active | | tags | | | updated_at | 2015-03-26T16:52:10Z | | virtual_size | None | | visibility | public | +------------------+------------------------------------------------------+ 

         

      4. 確認鏡像的上傳並驗證屬性:

        $ openstack image list
        +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros | active | +--------------------------------------+--------+--------+








免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM