个人-003-OpenStack-镜像服务
2019-07-25 本文已影响0人
MineG
OpenStack-镜像服务
【基于此文章的环境】点我快速打开文章
1、安装和配置
控制节点(controller)
1.1 创库授权 glance
mysql
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
用一个合适的密码替换
GLANCE_DBPASS
。


1.2 创建服务证书
1. 创建 glance
用户
openstack user create --domain default --password GLANCE_PASS glance
用一个合适的密码替换 GLANCE_PASS
。


2. 添加 admin 角色到 glance 用户和 service 项目上
openstack role add --project service --user glance admin


3. 创建服务,注册 api 地址
openstack service create --name glance \
--description "OpenStack Image" image
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


1.3 安装配置 glance
1. 安装其软件包
yum install openstack-glance -y &>/dev/null
echo $?


2. 修改配置文件
1. 备份初始配置文件,然后重定向写入配置文件
cp /etc/glance/glance-api.conf{,.bak}
egrep -v '^$|#' /etc/glance/glance-api.conf.bak >/etc/glance/glance-api.conf


2. 编辑文件 /etc/glance/glance-api.conf
并完成如下动作:
vim /etc/glance/glance-api.conf
- 在
[database]
部分,配置数据库访问
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
将
GLANCE_DBPASS
替换为你为镜像服务选择的密码
- 在
[keystone_authtoken]
和[paste_deploy]
部分,配置认证服务访问
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
# ...
flavor = keystone
将
GLANCE_PASS
替换为你为认证服务中你为glance
用户选择的密码。
- 在
[glance_store]
部分,配置本地文件系统存储和镜像文件位置
[glance_store]
# ...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/


3. 备份初始配置文件,然后重定向写入配置文件
cp /etc/glance/glance-registry.conf{,.bak}
egrep -v '^$|#' /etc/glance/glance-registry.conf.bak >/etc/glance/glance-registry.conf


4. 编辑文件 /etc/glance/glance-registry.conf
并完成如下动作:
vim /etc/glance/glance-registry.conf
- 在
[database]
部分,配置数据库访问
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
将
GLANCE_DBPASS
替换为你为镜像服务选择的密码。
- 在
[keystone_authtoken]
和[paste_deploy]
部分,配置认证服务访问
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
# ...
flavor = keystone
将
GLANCE_PASS
替换为你为认证服务中你为glance
用户选择的密码。


3. 写入其数据库
su -s /bin/sh -c "glance-manage db_sync" glance


验证操作
mysql glance -e 'show tables;'|wc -l


4. 启动和自启动
systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
systemctl start openstack-glance-api.service \
openstack-glance-registry.service


1.3 验证操作
1.3.1 验证端口
netstat -lntup|grep -E '9191|9292'


1.3.2 验证镜像
1. 官方镜像
【官方文档】点我快速打开文章
2. 本地镜像
本地上传镜像
ls
rz
ls


命令行上传镜像
file cirros-0.4.0-x86_64-disk.img
openstack image create "cirros" \
--file cirros-0.4.0-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public


确认镜像的上传并验证属性
openstack image list


【后续文章】点我快速打开文章
【本文图片下载地址】【002-OpenStack】点我快速打开分享(若异常,请私信,万分感谢) 【提取码:kse1 】