openstack部署过程3

Glance服务安装(控制节点)

1、创库授权

连接数据库
mysql -u root -p

创建glance数据库
CREATE DATABASE glance;

授予glance数据库权限,然后退出

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
  IDENTIFIED BY 'GLANCE_DBPASS'; #改密码
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
  IDENTIFIED BY 'GLANCE_DBPASS'; #改密码

2、创建glance用户并关联角色

创建用户(密码GLANCE_PASS,用户名 glance)

openstack user create --domain default --password GLANCE_PASS glance

在这里插入图片描述
关联角色(glance用户关联admin角色)

openstack role add --project service --user glance admin

3、创建服务实体和后端api

创建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

在这里插入图片描述

4. 安装软件

yum install openstack-glance –y

5. 自动配置

5.1. 配置glance-api.conf

cp /etc/glance/glance-api.conf{,.bak}
grep '^[a-Z\[]' /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  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/
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

5.2. 配置glance-registry.conf

cp /etc/glance/glance-registry.conf{,.bak}
grep '^[a-Z\[]' /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  keystoneopenstack-config --set /etc/glance/glance-api.conf  paste_deploy flavor  keystone

6.同步数据库

su -s /bin/sh -c "glance-manage db_sync" glance

7.验证

mysql -u root -p
use glance;
show tables;

在这里插入图片描述

8. 启动

加入开机启动
systemctl enable openstack-glance-api.service \
  openstack-glance-registry.service
启动程序
systemctl start openstack-glance-api.service \
  openstack-glance-registry.service
验证tcp端口
netstat -lntp|grep -E '9191|9292'

在这里插入图片描述

9. 上传镜像验证

9.1. 下载镜像

wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
如果提示wget是无效命令,请使用”yum install wget –y“安装wget软件

9.2. 上传镜像

openstack image create "cirros" \
  --file cirros-0.3.4-x86_64-disk.img \
  --disk-format qcow2 --container-format bare \
  --public

在这里插入图片描述

9.3. 查看镜像

openstack image list

10. Openstack镜像服务基本操作

10.1. 查看镜像列表

glance image-list
在这里插入图片描述

10.2. 使用参数可以是镜像id或者镜像名称查看镜像的详细信息

glance image-show 镜像id或者镜像名称
在这里插入图片描述

10.3. 删除镜像

glance image-delete镜像id或者镜像名称

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值