Centos7 安装kilo-4 controller(glance)

简介

Glance是OpenStack镜像服务,用来注册、登陆和检索虚拟机镜像。
Glance服务提供了一个REST API,能够查询虚拟机镜像元数据和检索的实际镜像。
通过镜像服务提供的虚拟机镜像可以存储在不同的位置,从简单的文件系统对象存储到类似OpeenStack对象存储系统。

本次安装使用普通文件作为后端,将上传的镜像放在/var/lib/image这个目录中,用于存储虚拟机的镜像和快照(确保这个目录有足够的空间)

镜像服务的组件:
Glance-API 承接镜像的探索,检索和存储镜像的API调用。
Glance-registry 存储,处理和检索有关镜像的元数据,元数据大小、类型等。
Database 存储镜像元数据,你可以选择你喜欢的数据库,现在比较多的是mysql和sqlite
Storage repository for image files 镜像存储,支持各种存储类型,包括普通文件系统,RADOS块设备,HTTP,和亚马逊的S3,(注意,有些存储只支持只读)

配置glance数据库

mysql -uroot -pPASS -e  "CREATE DATABASE glance;"
mysql -uroot -pPASS -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';"
mysql -uroot -pPASS -e "GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';"

创建user、service,endpoint

  • source 变量
source admin-openrc.sh
  • 创建 glance user
 openstack user create --password-prompt glance
User Password:
Repeat User Password:
+----------+----------------------------------+
| Field    | Value                            |
+----------+----------------------------------+
| email    | None                             |
| enabled  | True                             |
| id       | d9363e392a764cc0968405b3ba19fe8b |
| name     | glance                           |
| username | glance                           |
+----------+----------------------------------+
  • 给予glance user admin 角色
 openstack role add --project service --user glance admin

+-------+----------------------------------+
| Field | Value                            |
+-------+----------------------------------+
| id    | 53e5d390efe84b948ba5718f116b4861 |
| name  | admin                            |
+-------+----------------------------------+
  • 创建glance service
openstack service create --name glance --description "OpenStack Image service" image

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled     | True                             |
| id          | e4417d6d57654f96bf8cff0a3327a97c |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+
  • 创建 glance api endpoint
openstack endpoint create \
--publicurl http://controller:9292 \
--internalurl http://controller:9292 \
--adminurl http://controller:9292 \
--region RegionOne \
image

+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| adminurl     | http://controller:9292           |
| id           | f0b4177e0daa4dac939f91e3b9f09e26 |
| internalurl  | http://controller:9292           |
| publicurl    | http://controller:9292           |
| region       | RegionOne                        |
| service_id   | e4417d6d57654f96bf8cff0a3327a97c |
| service_name | glance                           |
| service_type | image                            |
+--------------+----------------------------------+

安装glance软件包

 yum -y install openstack-glance python-glance python-glanceclient

配置glance

  • glance-api.conf
openstack-config --set /etc/glance/glance-api.conf database  connection mysql://glance:glance@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  auth_plugin  password
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  project_domain_id  default
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  user_domain_id 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

openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone

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 DEFAULT notification_driver noop
openstack-config --set /etc/glance/glance-api.conf DEFAULT verbose True
  • glance-registry.conf
openstack-config --set /etc/glance/glance-registry.conf database  connection mysql://glance:glance@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  auth_plugin  password
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken  project_domain_id  default
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken  user_domain_id 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


openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone


openstack-config --set /etc/glance/glance-registry.conf  glance_store default_store file
openstack-config --set /etc/glance/glance-registry.conf  glance_store filesystem_store_datadir /var/lib/glance/images/

openstack-config --set /etc/glance/glance-api.conf DEFAULT notification_driver noop
openstack-config --set /etc/glance/glance-api.conf DEFAULT verbose True

初始化 glance数据库

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

启动glance并设置开启启动

systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl restart openstack-glance-api.service openstack-glance-registry.service

验证服务

  • 设置环境变量(glance api选用2.0)
echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
source admin-openrc.sh
  • 创建本地目录并下载测试镜像
  mkdir /tmp/images
  wget -P /tmp/images http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
  • 上传镜像并查看
glance image-create --name "cirros-0.3.4-x86_64" --file /tmp/images/cirros-0.3.4-x86_64-disk.img \
> --disk-format qcow2 --container-format bare --visibility public --progress

[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2015-09-10T04:26:06Z                 |
| disk_format      | qcow2                                |
| id               | 476d7b76-57d8-48be-a7e0-2130e718f157 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros-0.3.4-x86_64                  |
| owner            | 6655a8db1705461384c78137e5e87c17     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2015-09-10T04:26:07Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+


glance image-list
+--------------------------------------+---------------------+
| ID                                   | Name                |
+--------------------------------------+---------------------+
| 476d7b76-57d8-48be-a7e0-2130e718f157 | cirros-0.3.4-x86_64 |
+--------------------------------------+---------------------+


ls /var/lib/glance/images/
476d7b76-57d8-48be-a7e0-2130e718f157

glance服务小结

项目说明
服务名称glance
启动命令systemctl restart openstack-glance-api.service openstack-glance-registry.service
image存放目录/var/lib/glance/images/
api配置文件/etc/glance/glance-api.conf
registry配置文件/etc/glance/glance-registry.conf
api 日志/var/log/glance/api.log
registry日志/var/log/glance/registry.log
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值