云计算技术应用实训-镜像服务
(2)把测试镜像cirros-0.3.4-x86_64-disk.img上传到 /home/soft 中。#(2)编辑文件 /etc/glance/glance-api.conf 并完成如下动作。#添加 admin 角色到 glance 用户和 service 项目上。#(4)查看是否成功。#2.安全并配置组件。
#1.先决条件
#(1)完成下面的步骤以创建数据库:
mysql
#(2)创建 glance 数据库:
CREATE DATABASE glance;
#(3)对``glance``数据库授予恰当的权限:
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';
#(4)查看是否成功
show databases;
#(5)退出
exit
#(2)获得 admin 凭证来获取只有管理员能执行的命令的访问权限:
. /etc/keystone/admin-openrc
#(3)要创建服务证书,完成这些步骤:
#创建 glance 用户:
openstack user create --domain default --password GLANCE_PASS glance
#添加 admin 角色到 glance 用户和 service 项目上。
openstack role add --project service --user glance admin
#创建``glance``服务实体:
openstack service create --name glance \
--description "OpenStack Image" image
#创建镜像服务的 API 端点:
openstack endpoint create --region RegionOne \
image public http://controller:9292
openstack endpoint create --region RegionOne \
image internal http://controller:9292
openstack endpoint create --region RegionOne \
image admin http://controller:9292
#2.安全并配置组件
#(1)安装软件包:
yum install openstack-glance -y
#(2)编辑文件 /etc/glance/glance-api.conf 并完成如下动作
cp /etc/glance/glance-api.conf{,.bak}
grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf
openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:35357
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
#(3)编辑文件 ``/etc/glance/glance-registry.conf``并完成如下动作:
cp /etc/glance/glance-registry.conf{,.bak}
grep -Ev '^$|#' /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.conf
openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://controller:35357
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
#(4)写入镜像服务数据库:
su -s /bin/sh -c "glance-manage db_sync" glance
#3.完成安装
systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
systemctl start openstack-glance-api.service \
openstack-glance-registry.service
systemctl status openstack-glance-api.service \
openstack-glance-registry.service
netstat -lntup
#tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 13236/python2
#启动成功!
#4.验证
#(1)获得 admin 凭证来获取只有管理员能执行的命令的访问权限:
. /etc/keystone/admin-openrc
#(2)把测试镜像cirros-0.3.4-x86_64-disk.img上传到 /home/soft 中
#(3)切换到/home/soft 使用 QCOW2 磁盘格式, bare 容器格式上传镜像到镜像服务并设置公共可见,这样所有的项目都可以访问它:
cd /home/soft
openstack image create "cirros" \
--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
(检查有没有这个)
#| virtual_size | None
#| visibility | public
openstack image list
################
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| fddbc33b-8a5c-4fbe-8b6c-ef520484ab65 | cirros | active |
+--------------------------------------+--------+--------+
#######################
#验证成功!!
#截图,创建快照
更多推荐
所有评论(0)