Centos7 install Openstack - (第三節)添加鏡像服務(Glance)

Centos7 install Openstack - (第三節)添加鏡像服務(Glance)python

 

個人blog地址:http://www.cnblogs.com/caoguomysql

該文根據openstack官方文檔配置sql

官方文檔地址: http://docs.openstack.org/juno/install-guide/install/yum/content/#數據庫

 

 

0x01. 基本安裝配置(控制節點)api

一) To configure prerequisites 
1. To create the database, complete these steps:(在數據建立該服務須要使用的數據庫賬戶)curl

[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環境變量ide

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



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

  a. Create the glance user:  #在認證服務中建立一個glance的賬戶oop

[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:ui

[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

相關文章
相關標籤/搜索