Glance安装以及验证

一、lance搭建步骤
    1.安装Glance包
    2.初始化数据库
    3 配置Glance
         数据库
         keystone认证信息
    4 启动Glance

二、验证keystone可用

[root@controller ~]# . keystonerc
[root@controller ~]# keystone token-get

     如果输出正常,则keystone正常。

三、安装Glance包

[root@controller ~]# yum install openstack-glance python-glanceclient -y

四 配置Glance连接数据库

[root@controller ~]# openstack-config --set /etc/glance/glance-api.conf DEFAULT sql_connection mysql://glance:openstack@controller0/glance
[root@controller ~]# openstack-config --set /etc/glance/glance-registry.conf DEFAULT sql_connection mysql://glance:openstack@controller0/glance

五、初始化Glance 数据库

[root@controller ~]# openstack-db --init --service glance --password openstack
Please enter the password for the 'root' MySQL user:
Verified connectivity to MySQL.
Creating 'glance' database.
Updating 'glance' database password in /etc/glance/glance-registry.conf /etc/glance/glance-api.conf
Initializing the glance database, please wait...
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
Complete!

六、创建glance用户

[root@controller ~]# keystone user-create --name=glance --pass=glance [email protected]
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |        [email protected]        |
| enabled  |               True               |
|    id    | e9f8d113c0c341a2b7d81099f004c122 |
|   name   |              glance              |
| username |              glance              |
+----------+----------------------------------+
[root@controller0 ~]# keystone user-list
+----------------------------------+--------+---------+--------------------+
|                id                |  name  | enabled |       email        |
+----------------------------------+--------+---------+--------------------+
| 6efb8d6615b84cacb7cbdf0591a66bb7 | admin  |   True  | [email protected]  |
| e9f8d113c0c341a2b7d81099f004c122 | glance |   True  | [email protected] |
+----------------------------------+--------+---------+--------------------+

七、分配角色

[root@controller ~]# keystone user-role-add --user=glance --tenant=service --role=admin

八、创建glance服务

[root@controller ~]# keystone service-create --name=glance --type=image --description="Glance Image Service"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |       Glance Image Service       |
|   enabled   |               True               |
|      id     | 04555caea1674cc0bc17e69fa0f9ff38 |
|     name    |              glance              |
|     type    |              image               |
+-------------+----------------------------------+
[root@controller0 ~]# keystone service-list
+----------------------------------+----------+----------+---------------------------+
|                id                |   name   |   type   |        description        |
+----------------------------------+----------+----------+---------------------------+
| 04555caea1674cc0bc17e69fa0f9ff38 |  glance  |  image   |    Glance Image Service   |
| b8860e4213ef4b828e5c81b1b9e4d0bb | keystone | identity | Keystone Identity Service |
+----------------------------------+----------+----------+---------------------------+

九、创建keystone的endpoint

[root@controller ~]# keystone endpoint-create \
> --service-id=$(keystone service-list | awk '/ image / {print $2}')  \
> --publicurl=http://controller0:9292 \
> --internalurl=http://controller0:9292 \
> --adminurl=http://controller0:9292
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  |     http://controller0:9292      |
|      id     | 6be86cd7eaf94f3a90b5664a89663746 |
| internalurl |     http://controller0:9292      |
|  publicurl  |     http://controller0:9292      |
|    region   |            regionOne             |
|  service_id | 04555caea1674cc0bc17e69fa0f9ff38 |
+-------------+----------------------------------+
[root@controller0 ~]# keystone endpoint-list
+----------------------------------+-----------+------------------------------+------------------------------+-------------------------------+----------------------------------+
|                id                |   region  |          publicurl           |         internalurl          |            adminurl           |            service_id            |
+----------------------------------+-----------+------------------------------+------------------------------+-------------------------------+----------------------------------+
| 08feef21842442cf9185e748d14d9214 | regionOne | http://controller0:5000/v2.0 | http://controller0:5000/v2.0 | http://controller0:35357/v2.0 | b8860e4213ef4b828e5c81b1b9e4d0bb |
| 6be86cd7eaf94f3a90b5664a89663746 | regionOne |   http://controller0:9292    |   http://controller0:9292    |    http://controller0:9292    | 04555caea1674cc0bc17e69fa0f9ff38 |
+----------------------------------+-----------+------------------------------+------------------------------+-------------------------------+----------------------------------+

十、修改glance api和register相关配置

openstack-config --set /etc/glance/glance-api.conf DEFAULT debug True
openstack-config --set /etc/glance/glance-api.conf DEFAULT verbose True
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller0:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_host controller0
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_port 35357
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_protocol http
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password glance
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-registry.conf DEFAULT debug True
openstack-config --set /etc/glance/glance-registry.conf DEFAULT verbose True
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller0:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_host controller0
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_port 35357
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_protocol http
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_password glance
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone

十一、启动相关服务

[root@controller ~]# service openstack-glance-api start
Starting openstack-glance-api:                             [  OK  ]
[root@controller ~]# service openstack-glance-registry start
Starting openstack-glance-registry:                        [  OK  ]
[root@controller ~]# chkconfig openstack-glance-api on
[root@controller ~]# chkconfig openstack-glance-registry on
[root@controller ~]# ps -ef|grep glance
glance    2979     1  0 11:15 ?        00:00:00 /usr/bin/python /usr/bin/glance-api
glance    2987  2979  0 11:15 ?        00:00:00 /usr/bin/python /usr/bin/glance-api
glance    3009     1  1 11:16 ?        00:00:00 /usr/bin/python /usr/bin/glance-registry
glance    3015  3009  0 11:16 ?        00:00:00 /usr/bin/python /usr/bin/glance-registry
root      3022  2207  0 11:17 pts/0    00:00:00 grep glance
[root@controller ~]# cat /var/log/glance/api.log
[root@controller ~]# cat /var/log/glance/registry.log

十二、验证
1 准备Cirros

[root@controller ~]# ll cirros-0.3.2-x86_64-disk.img
-rw-r--r-- 1 root root 13167616 Feb 25 11:31 cirros-0.3.2-x86_64-disk.img

2 安装镜像

[root@controller ~]# glance image-create --progress --name="CirrOS 0.3.1" --disk-format=qcow2  --container-format=ovf --is-public=true < cirros-0.3.2-x86_64-disk.img
[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 64d7c1cd2b6f60c92c14662941cb7913     |
| container_format | ovf                                  |
| created_at       | 2018-02-25T03:35:29                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | 2e4303e2-ac60-45ba-af59-ae530487fb57 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | CirrOS 0.3.1                         |
| owner            | 4e845b494bf74cbf89213bf552db8599     |
| protected        | False                                |
| size             | 13167616                             |
| status           | active                               |
| updated_at       | 2018-02-25T03:35:30                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+
[root@controller ~]# glance  image-list
+--------------------------------------+--------------+-------------+------------------+----------+--------+
| ID                                   | Name         | Disk Format | Container Format | Size     | Status |
+--------------------------------------+--------------+-------------+------------------+----------+--------+
| 2e4303e2-ac60-45ba-af59-ae530487fb57 | CirrOS 0.3.1 | qcow2       | ovf              | 13167616 | active |
+--------------------------------------+--------------+-------------+------------------+----------+--------+
[root@controller ~]# glance image-show 2e4303e2-ac60-45ba-af59-ae530487fb57
/usr/lib64/python2.6/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | 64d7c1cd2b6f60c92c14662941cb7913     |
| container_format | ovf                                  |
| created_at       | 2018-02-25T03:35:29                  |
| deleted          | False                                |
| disk_format      | qcow2                                |
| id               | 2e4303e2-ac60-45ba-af59-ae530487fb57 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | CirrOS 0.3.1                         |
| owner            | 4e845b494bf74cbf89213bf552db8599     |
| protected        | False                                |
| size             | 13167616                             |
| status           | active                               |
| updated_at       | 2018-02-25T03:35:30                  |
+------------------+--------------------------------------+
[root@controller ~]# glance member-add 2e4303e2-ac60-45ba-af59-ae530487fb57 6efb8d6615b84cacb7cbdf0591a66bb7
[root@controller ~]# glance member-list --image-id 2e4303e2-ac60-45ba-af59-ae530487fb57
+--------------------------------------+----------------------------------+-----------+
| Image ID                             | Member ID                        | Can Share |
+--------------------------------------+----------------------------------+-----------+
| 2e4303e2-ac60-45ba-af59-ae530487fb57 | 6efb8d6615b84cacb7cbdf0591a66bb7 |           |
+--------------------------------------+----------------------------------+-----------+

猜你喜欢

转载自blog.csdn.net/yuchenxueyue/article/details/82775147