openstack的另外一個組件--glance,它主要是存放鏡像的,而它支持的格式也挺多,例如:ISO、qcow、raw、vmdk等,那麼咱們就搭建glance服務。
mysql
建立glance數據庫、glance用戶
sql
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';
建立glance用戶
數據庫
將admin角色添加到service項目中的glance用戶
api
[root@wang02 ~]# openstack role add --project service --user glance admindom
建立一個glance服務實體ide
[root@wang02 ~]# openstack service create --name glance \memcached
> --description "OpenStack Image" p_w_picpathurl
建立一個公共的glance用戶的url
spa
[root@wang02 ~]# openstack endpoint create --region RegionOne \.net
> p_w_picpath public http://wang02:9292
建立一個內部的glance用戶的url
[root@wang02 ~]# openstack endpoint create --region RegionOne \
> p_w_picpath internal http://wang02:9292
建立一個admin的glance用戶的url
[root@wang02 ~]# openstack endpoint create --region RegionOne \
> p_w_picpath admin http://wang02:9292
下載glance服務包
[root@wang02 ~]# yum install openstack-glance
修改配置文件
[root@wang02 glance]# cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
[root@wang02 glance]# cat /etc/glance/glance-api.conf.bak | grep -v ^# | uniq > /etc/glance/glance-api.conf
[root@wang02 glance]# sed -i '/^\[database\]$/a\connection = mysql+pymysql://glance:GLANCE_DBPASS@wang01/glance\n' /etc/glance/glance-api.conf
[root@wang02 glance]# sed -i '/^\[keystone_authtoken\]$/a\auth_uri = http://wang02:5000\nauth_url = http://wang02:35357\nmemcached_servers = wang01:11211\nauth_type = password\nproject_domain_name = default\nuser_domain_name = default\nproject_name =service\nusername = glance\npassword = GLANCE_PASS\n' /etc/glance/glance-api.conf
[root@wang02 glance]# sed -i '/^\[paste_deploy\]$/a\flavor = keystone\n' /etc/glance/glance-api.conf
[root@wang02 glance]# sed -i '/^\[glance_store\]$/a\stores = file,http\ndefault_store = file\nfilesystem_store_datadir = /var/lib/glance/p_w_picpaths/\n' /etc/glance/glance-api.conf
[root@wang02 glance]# cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
[root@wang02 glance]# cat /etc/glance/glance-registry.conf.bak | grep -v ^# | uniq > /etc/glance/glance-registry.conf
[root@wang02 glance]# sed -i '/^\[database\]$/a\connection = mysql+pymysql://glance:GLANCE_PASS@wang01/glance\n' /etc/glance/glance-registry.conf
[root@wang02 glance]# sed -i '/^\[keystone_authtoken\]$/a\auth_uri = http://wang02:5000\nauth_url = http://wang02:35357\nmemcached_servers = wang01:11211\nauth_type = password\nproject_domain_name = default\nuser_domain_name = default\nproject_name = service\nusername = glance\npassword = GLANCE_PASS\n' /etc/glance/glance-registry.conf
[root@wang02 glance]# sed -i '/^\[paste_deploy\]$/a\flavor = keystone\n' /etc/glance/glance-registry.conf
同步數據庫
[root@wang02 glance]# su -s /bin/sh -c "glance-manage db_sync" glance
啓動服務
[root@wang02 glance]# systemctl start openstack-glance-api.service \
> openstack-glance-registry.service
[root@wang02 glance]# systemctl enable openstack-glance-api.service \
> openstack-glance-registry.service
驗證操做
[root@wang02 ~]# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
[root@wang02 ~]# openstack p_w_picpath create "cirros" \
> --file cirros-0.3.5-x86_64-disk.img \
> --disk-format qcow2 --container-format bare \
> --public
查看鏡像的狀態
[root@wang02 ~]# openstack p_w_picpath list
到這裏咱們看到剛纔上傳的鏡像的狀態是激活的,說明咱們上傳成功