一、部署Glance
1、Glance 安装
[root@linux-node1 ~]#yum install openstack-glance python-glance python-glanceclient -y
2、配置:修改glance-api和glance-registry的配置文件,同步数据库
[root@linux-node1 ~]# vi /etc/glance/glance-api.conf [database] connection = mysql://glance:glance@172.22.0.218/glance [root@linux-node1 ~]# vi /etc/glance/glance-registry.conf [database] connection = mysql://glance:glance@172.22.0.218/glance
3、同步数据库并检查数据库:
[root@linux-node1 ~]# su -s /bin/sh -c "glance-manage db_sync" glance 检查导入glance库的表情况: MariaDB [(none)]> use glance Database changed MariaDB [glance]> MariaDB [glance]> show tables; +----------------------------------+ | Tables_in_glance | +----------------------------------+ | artifact_blob_locations | | artifact_blobs | | artifact_dependencies | | artifact_properties | | artifact_tags | | artifacts | | image_locations | | image_members | | image_properties | | image_tags | | images | | metadef_namespace_resource_types | | metadef_namespaces | | metadef_objects | | metadef_properties | | metadef_resource_types | | metadef_tags | | migrate_version | | task_info | | tasks | +----------------------------------+ 20 rows in set (0.00 sec)
4、配置glance连接keystone,对于keystone,每个服务都要有一个用户连接keystone
[root@linux-node1 ~]# source admin-openrc.sh [root@linux-node1 ~]# openstack user create --domain default --password=glance glance +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | d21d0715890447fb87f72e85dce6d4be | | enabled | True | | id | add8d7512b3a4af78236d75e5154978e | | name | glance | | password_expires_at | None | +---------------------+----------------------------------+ [root@linux-node1 ~]# openstack role add --project service --user glance admin
5、修改glance-api配置文件,结合keystone和mysql
[root@linux-node1 ~]# vi /etc/glance/glance-api.conf verbose = true [keystone_authtoken] auth_uri = http://172.22.0.218:5000 auth_url = http://172.22.0.218:35357 auth_plugin = password project_domain_id = d21d0715890447fb87f72e85dce6d4be user_domain_id = d21d0715890447fb87f72e85dce6d4be project_name = service username = glance password = glance [paste_deploy] flavor = keystone [oslo_messaging_notifications] # The Drivers(s) to handle sending notifications. Possible values are messaging, # messagingv2, routing, log, test, noop (multi valued) # Deprecated group/name - [DEFAULT]/notification_driver driver = noop [glance_store] default_store = file filesystem_store_datadir = /var/lib/glance/images
6、修改glance-registry配置文件,结合keystone和mysql
[root@linux-node1 ~]# vi /etc/glance/glance-registry.conf verbose=True [oslo_messaging_notifications] # The Drivers(s) to handle sending notifications. Possible values are messaging, # messagingv2, routing, log, test, noop (multi valued) # Deprecated group/name - [DEFAULT]/notification_driver driver = noop [keystone_authtoken] auth_uri = http://172.22.0.218:5000 auth_url = http://172.22.0.218:35357 auth_plugin = password project_domain_id = d21d0715890447fb87f72e85dce6d4be user_domain_id = d21d0715890447fb87f72e85dce6d4be project_name = service username = glance password = glance [paste_deploy] flavor = keystone
7、配置检查:
[root@linux-node1 ~]# grep -n '^[a-z]' /etc/glance/glance-api.conf 1455:verbose = true 1748:connection = mysql://glance:glance@172.22.0.218/glance 1896:default_store = file 2196:filesystem_store_datadir = /var/lib/glance/images 3192:auth_uri = http://172.22.0.218:5000 3193:auth_url = http://172.22.0.218:35357 3194:auth_plugin = password 3195:project_domain_id = d21d0715890447fb87f72e85dce6d4be 3196:user_domain_id = d21d0715890447fb87f72e85dce6d4be 3197:project_name = service 3198:username = glance 3199:password = glance 3564:driver = noop 3989:flavor = keystone [root@linux-node1 ~]# grep -n '^[a-z]' /etc/glance/glance-registry.conf 1038:connection = mysql://glance:glance@172.22.0.218/glance 1141:auth_uri = http://172.22.0.218:5000 1142:auth_url = http://172.22.0.218:35357 1143:auth_plugin = password 1144:project_domain_id = d21d0715890447fb87f72e85dce6d4be 1145:user_domain_id = d21d0715890447fb87f72e85dce6d4be 1146:project_name = service 1147:username = glance 1148:password = glance 1494:driver = noop 1908:flavor = keystone
二、启动glance
1、设置开机启动并启动glance服务检查服务:
[root@linux-node1 ~]# systemctl enable openstack-glance-api Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service. [root@linux-node1 ~]# systemctl enable openstack-glance-registry Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service. 查看galnce占用端口情况,其中9191是registry占用端口,9292是api占用端口 [root@linux-node1 ~]# netstat -lntup|egrep "9191|9292" tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 3029/python2 tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 3046/python2 [root@linux-node1 ~]# ps aux | grep 3029 glance 3029 4.6 6.4 370872 65748 ? Ss 11:06 0:15 /usr/bin/python2 /usr/bin/glance-api root 3164 0.0 0.0 112660 976 pts/0 R+ 11:11 0:00 grep --color=auto 3029 [root@linux-node1 ~]# ps aux | grep 3046 glance 3046 1.7 6.4 352560 65152 ? Ss 11:06 0:06 /usr/bin/python2 /usr/bin/glance-registry root 3169 0.0 0.0 112660 976 pts/0 S+ 11:11 0:00 grep --color=auto 3046
2、glance服务在keystone上注册,才可以允许其他服务调用glance
[root@linux-node1 ~]# openstack service create --name glance --description "OpenStack Image service" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image service | | enabled | True | | id | b08581e2a35a4ed982ddfac797050ae1 | | name | glance | | type | image | +-------------+----------------------------------+ [root@linux-node1 ~]# openstack endpoint create --region RegionOne image public http://172.22.0.218:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | af6c4a21691344d7adfd6ec3e2d3674e | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | b08581e2a35a4ed982ddfac797050ae1 | | service_name | glance | | service_type | image | | url | http://172.22.0.218:9292 | +--------------+----------------------------------+ [root@linux-node1 ~]# openstack endpoint create --region RegionOne image internal http://172.22.0.218:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 2646c93f3cda442fb062887f6c510343 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | b08581e2a35a4ed982ddfac797050ae1 | | service_name | glance | | service_type | image | | url | http://172.22.0.218:9292 | +--------------+----------------------------------+ [root@linux-node1 ~]# openstack endpoint create --region RegionOne image admin http://172.22.0.218:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 5cc3112ed5944f04935805467ad36ec8 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | b08581e2a35a4ed982ddfac797050ae1 | | service_name | glance | | service_type | image | | url | http://172.22.0.218:9292 | +--------------+----------------------------------+
3、在admin和demo中加入glance的环境变量,告诉其他服务glance使用的环境变量,一定要在admin-openrc.sh的路径下执行
[root@linux-node1 ~]# echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh export OS_IMAGE_API_VERSION=2 [root@linux-node1 ~]# tail -1 admin-openrc.sh export OS_IMAGE_API_VERSION=2 [root@linux-node1 ~]# tail -1 demo-openrc.sh export OS_IMAGE_API_VERSION=2
三、检查是否安装部署正确
1、如果出现以下情况,表示glance配置成功,由于没有镜像,所以看不到
[root@linux-node1 ~]# glance image-list
+----+------+
| ID | Name |
+----+------+
+----+------+
2、下载一个镜像:
[root@linux-node1 ~]#wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
3、上传镜像到glance,要在上一步所下载的镜像当前目录执行:
[root@linux-node1 ~]# glance image-create --name "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public --progress [=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2018-03-06T03:30:50Z | | disk_format | qcow2 | | id | 8f5837b4-bbec-4ef5-96f6-aba989c27206 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | 503b0eab0420454e909a46e476bf1ede | | protected | False | | size | 13287936 | | status | active | | tags | [] | | updated_at | 2018-03-06T03:30:50Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+
4、查看上传镜像:
[root@linux-node1 ~]# glance image-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | 8f5837b4-bbec-4ef5-96f6-aba989c27206 | cirros | +--------------------------------------+--------+ [root@linux-node1 ~]# cd /var/lib/glance/images/ [root@linux-node1 images]# ls 8f5837b4-bbec-4ef5-96f6-aba989c27206
完成部署!部署成功!