前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS7.0+OpenStack+kvm云平台部署—配置Glance

CentOS7.0+OpenStack+kvm云平台部署—配置Glance

作者头像
菲宇
发布2019-06-11 17:51:31
6140
发布2019-06-11 17:51:31
举报
文章被收录于专栏:菲宇菲宇菲宇

初始化Glance

(1).安装Glance服务:

[root@openstack ~]# yum -y installopenstack-glance

(2).创建Glance数据库:

[root@openstack ~]# openstack-db--init --service glance

(3).修改配置文件中的数据库链接:

[root@openstack ~]# openstack-config--set /etc/glance/glance-api.conf DEFAULT sql_connectionmysql://glance:glance@localhost/glance

[root@openstack ~]# openstack-config--set /etc/glance/glance-registry.conf DEFAULT sql_connectionmysql://glance:glance@localhost/glance

创建User,定义Services和 API Endpoints

(1).为Glance服务创建一个glance用户:

[root@openstack ~]# keystoneuser-create--name=glance --pass=service--email=glance@zcs.com

[root@openstack ~]# keystoneuser-role-add --user=glance --tenant=service --role=admin

(2).为glance创建一个服务:

[root@openstack ~]# keystoneservice-create --name=glance --type=image --description="GlanceImageService"

(3).使用服务ID创建一个endpoint:

[root@openstack ~]# vi/root/config/glance.sh

#!/bin/bash

my_ip=10.1.1.2

service=$(keystone service-list | awk'/glance/ {print $2}')

keystone endpoint-create --service-id=$service--publicurl=http://$my_ip:9292 --internalurl=http://$my_ip:9292--adminurl=http://$my_ip:9292

[root@mg ~]# sh /root/config/glance.sh

WARNING: Bypassing authentication using atoken & endpoint (authentication credentials are being ignored).

+-------------+----------------------------------+

| Property | Value |

+-------------+----------------------------------+

| adminurl | http://10.1.1.2:9292 |

| id |fe281515d406407bbcd4887cb5815de4 |

| internalurl | http://10.1.1.2:9292 |

| publicurl | http://10.1.1.2:9292 |

| region | regionOne |

| service_id | 7c0102f0e715479e9292c0581d214de2 |

+-------------+----------------------------------+

配置Glance服务

(1).将keystone认证信息添加到glance配置文件中:

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf keystone_authtoken auth_host 127.0.0.1

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf keystone_authtoken auth_port 35357

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf keystone_authtoken auth_protocol http

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf keystone_authtoken admin_user glance

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf keystone_authtoken admin_password service

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf keystone_authtoken auth_host 127.0.0.1

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf keystone_authtoken auth_port 35357

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf keystone_authtoken auth_protocol http

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf keystone_authtoken admin_user glance

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf keystone_authtoken admin_password service

(2).修改ini文件路径,将keystone认证信息添加到ini文件中:

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf paste_deploy config_file/etc/glance/glance-api-paste.ini

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf paste_deploy flavor keystone

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf paste_deploy config_file /etc/glance/glance-registry-paste.ini

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry.conf paste_deploy flavor keystone

[root@openstack ~]# cp/usr/share/glance/glance-api-dist-paste.ini /etc/glance/glance-api-paste.ini

[root@openstack ~]# cp/usr/share/glance/glance-registry-dist-paste.ini/etc/glance/glance-registry-paste.ini

[root@openstack ~]# chown -R root:glance/etc/glance/glance-api-paste.ini

[root@openstack ~]# chown -R root:glance/etc/glance/glance-registry-paste.ini

[root@openstack ~]# openstack-config --set/etc/glance/glance-api-paste.ini filter:authtoken auth_host 127.0.0.1

[root@openstack ~]# openstack-config --set/etc/glance/glance-api-paste.ini filter:authtoken admin_tenant_name service

[root@openstack ~]# openstack-config --set/etc/glance/glance-api-paste.ini filter:authtoken admin_user glance

[root@openstack ~]# openstack-config --set/etc/glance/glance-api-paste.ini filter:authtoken admin_password service

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry-paste.ini filter:authtoken auth_host 127.0.0.1

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry-paste.ini filter:authtoken admin_tenant_nameservice

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry-paste.ini filter:authtoken admin_user glance

[root@openstack ~]# openstack-config --set/etc/glance/glance-registry-paste.ini filter:authtoken admin_password service

(3).修改镜像文件的存放路径(默认存放在/var/lib/glance目录下,若不需修改,此步骤可省略)

[root@openstack ~]# openstack-config--set /etc/glance/glance-api.conf DEFAULT filesystem_store_datadir/openstack/lib/glance/images/

[root@openstack ~]# openstack-config--set /etc/glance/glance-api.conf DEFAULT scrubber_datadir/openstack/lib/glance/scrubber

[root@openstack ~]# openstack-config --set/etc/glance/glance-api.conf DEFAULT image_cache_dir/openstack/lib/glance/image-cache/

[root@openstack ~]# mkdir -p/openstack/lib

[root@openstack ~]# cp -r/var/lib/glance/ /openstack/lib/

[root@openstack ~]# chown -Rglance:glance /openstack/lib/glance/

(4).启动glance服务,设置开机自启动

[root@openstack ~]# serviceopenstack-glance-api start

[root@openstack ~]# serviceopenstack-glance-registry start

[root@openstack ~]# chkconfigopenstack-glance-api on

[root@openstack ~]# chkconfigopenstack-glance-registry on

Glance测试

(1).上传镜像

[root@openstack ~]# glanceimage-create --name=centos6.4 --disk-format=qcow2 --container-format=ovf--is-public=true < /root/centos6.4-mini_x64.qcow2

注意:(以下框住的描述可忽略)验证镜像服务的安装(Verify theImage Service installation)

为了测试镜像服务的安装,至少下载一个虚拟机镜像,这个镜像一定要能够与OpenStack一起工作。例如,CirrOS是一个很小的测试镜像,它经常用于测试OpenStack部署。这个过程,使用了64-bit的CirrOSQCOW2镜像。

有关更多如何下载和创建镜像的信息,请参考“OpenStackVirtual Machine Image Guide”,有关如何管理镜像的信息,请参考“OpenStackUser Guide”.

1. 用wget或curl下载该镜像到指定的目录

$ mkdirimages $ cd images/ $ wget http://cdn.download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img

2. 上传该镜像到该镜像服务中

# glanceimage-create --name=imageLabel --disk-format=fileFormat \ --container-format=containerFormat --is-public=accessValue < imageFile

参数说明:

imageLabel 任意的标志,该名称由用户指向镜像。

fileFormat 说明镜像文件格式,有效的文件格式包括:qcow2,raw,vhd,vmdk,vdi,iso,aki,ari,andami等等。

(这里选择format的时候,最好选择vmdk,因为后面创建虚拟机实例的时候可能会识别不了)

containerFormat 指定的容器格式,有效的格式包括:bare,ovf,aki,ariand ami。

指定bare格式表明镜像文件不在文件格式里,也就是说包含有关虚拟机的元数据。虽然目前这个字段是必须的,但实际上任何其它的OpenStack服务不使用它,而且在系统运行时也没有效果。因为该值在任何地方都没有用到,为了安全,一直指定bare作为容器的格式。

accessValue 指定镜像是否能访问。

true --所有的用户都能够查看和使用该镜像。

false --只有管理员才能够查看和使用该镜像

imageFile 指定你下载的镜像文件名称

注:上传出错:

Requestreturned failure status. HTTPInternalServerError (HTTP 500)

后来查看debug,是我在配置/etc/glance/glanceregistry.conf文件时把:

[paste_deploy] ... flavor = keystone 中的keystone错写成了glance

更改后,再上传,就对了,结果如下:

root@controller:~/image#glance image-create --name="CirrOS 0.3.1" --disk-format=qcow2--container-format=bare --is-public=true < cirros-0.3.1-x86_64-disk.img +------------------+--------------------------------------+ | Property |Value | +------------------+--------------------------------------+ | checksum |d972013792949d0d3ba628fbe8685bce | | container_format |bare | | created_at |2014-03-14T10:03:34 | | deleted |False | | deleted_at |None | | disk_format |qcow2 | |id | 84e4056d-662f-4c88-809a-6551b9e3185a | | is_public |True | | min_disk |0 | | min_ram |0 | | name | CirrOS0.3.1 | | owner |fe0f1b42a1df44bcac0b6908b96bcaae | | protected |False | | size |13147648 | | status |active | | updated_at |2014-03-14T10:03:35 | +------------------+--------------------------------------+ 查看glance数据库中的表images,就可以看到添加的镜像文件。

再查看/var/lib/glance/images目录下,就有一个与images表中ID号相同的文件。

(2).查看镜像

[root@openstack ~]# glance image-list

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018年08月08日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
容器服务
腾讯云容器服务(Tencent Kubernetes Engine, TKE)基于原生 kubernetes 提供以容器为核心的、高度可扩展的高性能容器管理服务,覆盖 Serverless、边缘计算、分布式云等多种业务部署场景,业内首创单个集群兼容多种计算节点的容器资源管理模式。同时产品作为云原生 Finops 领先布道者,主导开源项目Crane,全面助力客户实现资源优化、成本控制。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档