1、创建数据库 [iyunv@controller ~]# mysql -u root -p -e "CREATE DATABASEglance;" Enter password: [iyunv@controller ~]# mysql -u root -p -e "GRANT ALL PRIVILEGES ONglance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';" Enter password: [iyunv@controller ~]# mysql -u root -p -e "GRANT ALL PRIVILEGES ONglance.* TO 'glance'@'%' IDENTIFIED BY 'glance';" Enter password: 2、安装glance [iyunv@controller ~]# yum install -y openstack-glance python-glancepython-glanceclient 3、配置glance
3.1、同步数据库 [iyunv@controller ~]# vim /etc/glance/glance-api.conf 538 connection=mysql://glance:glance@192.168.1.11/glance [iyunv@controller ~]# vim /etc/glance/glance-registry.conf 363 connection=mysql://glance:glance@192.168.1.11/glance [iyunv@controller ~]# su -s /bin/sh -c "glance-manage db_sync"glance 3.2、创建glance用户 [iyunv@controller ~]# source admin-openrc.sh [iyunv@controller ~]# openstack user create --domain default--password=glance glance +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | default | | enabled | True | | id |c13d8e0ef83f466e95bdd4040284c52b | | name | glance | +-----------+----------------------------------+ [iyunv@controller ~]# openstack role add --project service --user glanceadmin 3.3、配置glance-api 3.3.1、配置连接keystone [iyunv@controller ~]# vim /etc/glance/glance-api.conf 973 [keystone_authtoken] 974 auth_uri = http://192.168.1.11:5000 975 auth_url = http://192.168.1.11:35357 976 auth_plugin = password 977 project_domain_id = default 978 user_domain_id = default 979 project_name = service 980 username = glance 981 password = glance 1484 flavor=keystone 3.3.2、配置不使用消息队列 [iyunv@controller ~]# vim /etc/glance/glance-api.conf 491 notification_driver = noop 3.3.3、配置镜像存放位置 [iyunv@controller ~]# vim /etc/glance/glance-api.conf 642 default_store=file 701 filesystem_store_datadir=/var/lib/glance/images/ 3.4、配置glance-registry 3.4.1、配置连接keystone [iyunv@controller ~]# vim /etc/glance/glance-registry.conf 762 [keystone_authtoken] 763 uth_uri = http://192.168.1.11:5000 764 auth_url = http://192.168.1.11:35357 765 auth_plugin = password 766 project_domain_id = default 767 user_domain_id = default 768 project_name = service 769 username = glance 770 password = glance 1256 flavor=keystone 3.5、注册到keystone [iyunv@controller ~]# openstack service create --name glance --description"OpenStack Image service" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image service | | enabled | True | | id |9d7176f5cfab47aa99789159dd8ea8a2 | | name | glance | | type | image | +-------------+----------------------------------+ [iyunv@controller ~]# openstack endpoint create --region RegionOne image public http://192.168.1.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id |e8c6bfd66506449094a2aab994e7a4be | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id |9d7176f5cfab47aa99789159dd8ea8a2 | | service_name | glance | | service_type | image | | url | http://192.168.1.11:9292 | +--------------+----------------------------------+ [iyunv@controller ~]# openstack endpoint create --region RegionOne image internal http://192.168.1.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id |3b18ac8bd0764d009451223f26dccede | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id |9d7176f5cfab47aa99789159dd8ea8a2 | | service_name | glance | | service_type | image | | url |http://192.168.1.11:9292 | +--------------+----------------------------------+ [iyunv@controller ~]# openstack endpoint create --region RegionOne image admin http://192.168.1.11:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | db9f2e251e26413d836bacd725677426| | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id |9d7176f5cfab47aa99789159dd8ea8a2 | | service_name | glance | | service_type | image | | url |http://192.168.1.11:9292 | +--------------+----------------------------------+ 4、启动glance [iyunv@controller ~]# systemctl enable openstack-glance-api [iyunv@controller ~]# systemctl enable openstack-glance-registry [iyunv@controller ~]# systemctl start openstack-glance-api [iyunv@controller ~]# systemctl start openstack-glance-registry 5、添加glance环境变量 [iyunv@controller ~]# echo "export OS_IMAGE_API_VERSION=2" \ | tee -a admin-openrc.sh kevin-openrc.sh 6、验证是否安装成功 [iyunv@controller ~]# glance image-list +----+------+ | ID | Name | +----+------+ +----+------+ 7、上传镜像 下载cirros镜像,该镜像为大约13M大小的镜像 [iyunv@controller ~]# wget https://download.cirros-cloud.ne ... 3.4-x86_64-disk.img [iyunv@controller ~]# rm -f cirros-0.3.4-x86_64-disk.img [iyunv@controller ~]# [iyunv@controller ~]# 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 |2015-12-28T07:20:25Z | | disk_format | qcow2 | | id |de72b13d-3f0f-4292-9afa-30c94175c3b5 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner |69d1967e59d247e6b7c4c3937d5baa89 | | protected | False | | size | 13287936 | | status | active | | tags | [] | | updated_at |2015-12-28T07:20:26Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+ root@controller ~]# glance image-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | de72b13d-3f0f-4292-9afa-30c94175c3b5 | cirros | +--------------------------------------+--------+
|