云计算之openstack-newton版搭建(四)

镜像服务

镜像服务(glance)是用户能够发现,注册和检索虚拟机的镜像,它提供了一个REST API,使您能够查询虚拟机映像元数据并检索实际映像。可以将通过Image服务提供的虚拟机映像存储在各种位置,从简单文件系统到对象存储系统(如OpenStack对象存储)。镜像默认放在/var/lib/glance/images/。

下面说一下glance服务的安装及配置

1.创建数据库

[[email protected] ~]# mysql -uroot -p123456
mysql> CREATE DATABASE glance;
mysql> GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘localhost‘   IDENTIFIED BY ‘GLANCE_DBPASS‘;
mysql> GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘%‘   IDENTIFIED BY ‘GLANCE_DBPASS‘;

2.获取admin权限

[[email protected] ~]# . admin-openrc

3.创建glance用户

[[email protected] ~]# openstack user create --domain default --password-prompt glance
User Password:123456
Repeat User Password:123456
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 09d8b7bbfe9748ffadff25bffc1b46cd |
| name                | glance                           |
| password_expires_at | None                             |
+---------------------+----------------------------------+

将admin角色添加到glance用户和服务项目中

[[email protected] ~]# openstack role add --project service --user glance admin

创建glance服务实例

# openstack service create --name glance   --description "OpenStack Image" image
[[email protected] ~]# openstack service create --name glance >   --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | d6319246d7e3486d86b54634f07c1cb8 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

4.创建image服务API端点

# openstack endpoint create --region RegionOne   image public http://controller:9292
[[email protected] ~]# openstack endpoint create --region RegionOne >   image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 621b1c8dabc9472591690d4dadbd4dff |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | d6319246d7e3486d86b54634f07c1cb8 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne   image internal http://controller:9292
[[email protected] ~]# openstack endpoint create --region RegionOne >   image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | f2d4366f844d415e9745c6d7d817d859 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | d6319246d7e3486d86b54634f07c1cb8 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne   image admin http://controller:9292
[[email protected] ~]# openstack endpoint create --region RegionOne >   image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 48114b387628482f9ae11d0cdb29dce2 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | d6319246d7e3486d86b54634f07c1cb8 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

5.安装服务

[[email protected] ~]# yum install openstack-glance -y

6.配置服务

修改/etc/glance/glance-api.conf

[[email protected] ~]# cd /etc/glance/
[[email protected] glance]# cp glance-api.conf glance-api.conf.bak
[[email protected] glance]# egrep -v "^#|^$" glance-api.conf.bak > glance-api.conf
[[email protected] glance]# vim glance-api.conf
[database]
...
connection = mysql+pymysql://glance:[email protected]/glance
[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 = 123456

[paste_deploy]
...
flavor = keystone
[glance_store]
...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

修改/etc/glance/glance-registry.conf

[[email protected] ~]# cd /etc/glance/
[[email protected] glance]# cp glance-registry.conf glance-registry.conf.bak
[[email protected] glance]# egrep -v "^#|^$" glance-registry.conf.bak glance-registry.conf
[database]
...
connection = mysql+pymysql://glance:[email protected]/glance
[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 = 123456

[paste_deploy]
...
flavor = keystone

7.填充数据库

[[email protected] glance]# su -s /bin/sh -c "glance-manage db_sync" glance

8.启动服务

[[email protected] glance]# systemctl enable openstack-glance-api.service   openstack-glance-registry.service
[[email protected] glance]#  systemctl start openstack-glance-api.service   openstack-glance-registry.service

9.验证

下载镜像

[[email protected] glance]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img

导入镜像

# openstack image create "cirros"   --file cirros-0.3.4-x86_64-disk.img   --disk-format qcow2 --container-format bare   --public
[[email protected] glance]# openstack image create "cirros" >   --file cirros-0.3.4-x86_64-disk.img >   --disk-format qcow2 --container-format bare >   --public
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6                     |
| container_format | bare                                                 |
| created_at       | 2017-01-11T03:10:51Z                                 |
| disk_format      | qcow2                                                |
| file             | /v2/images/2faf5e8a-890d-4c68-a391-a2911342a3af/file |
| id               | 2faf5e8a-890d-4c68-a391-a2911342a3af                 |
| min_disk         | 0                                                    |
| min_ram          | 0                                                    |
| name             | cirros                                               |
| owner            | 3cf031774a844e4c8422cadb9d67785e                     |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 13287936                                             |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2017-01-11T03:10:52Z                                 |
| virtual_size     | None                                                 |
| visibility       | public                                               |
+------------------+------------------------------------------------------+
[[email protected] glance]# openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 2faf5e8a-890d-4c68-a391-a2911342a3af | cirros | active |
+--------------------------------------+--------+--------+
安装成功
[[email protected] ~]# ls /var/lib/glance/images/
2faf5e8a-890d-4c68-a391-a2911342a3af
时间: 2024-10-11 07:51:25

云计算之openstack-newton版搭建(四)的相关文章

openstack i版搭建教程

第一部分云计算平台Openstack介绍 一.   什么是云计算 云计算(cloud computing)是基于互联网的相关服务的增加.使用和交付模式,通常涉及通过互联网来提供动态易扩展且经常是虚拟化的资源.云是网络.互联网的一种比喻说法.过去在图中往往用云来表示电信网,后来也用来表示互联网和底层基础设施的抽象.因此,云计算甚至可以让你体验每秒10万亿次的运算能力,拥有这么强大的计算能力可以模拟核爆炸.预测气候变化和市场发展趋势.用户通过电脑.笔记本.手机等方式接入数据中心,按自己的需求进行运算

基于Ubuntu12.04-server版的openstack F版搭建步骤

本文为双节点搭建,分为计算(IP1)和控制节点(IP2) 说明: 计算节点组件: 1.mysql 2.keystone 3.Nova 4.glance 5.rabbitmq 控制节点组件: 1.cinder 2.dashboard 一.修改主机名及静态IP 1.vim  /etc/hostname             xxctrl(xxctrl改为目标名) 2.vim  /etc/hosts     IP     xxctrl(目标名) 3.hostname xxctrl (使改名生效,也可

ubuntu16.04多节点布置openstack newton版

控制节点安装 1.网络配置 需要两张网卡,两张网卡第一张网卡配置静态地址,第二张为provider interface,配置如下: # The provider network interface auto INTERFACE_NAME iface INTERFACE_NAME inet manual up ip link set dev $IFACE up down ip link set dev $IFACE down 将其中的INTERFACE_NAME换成自己的interface(最后两

openstack R版 搭建过程遇到的种种问题

一.创建虚拟机失败 vm上运行virt-install 创建kvm类型的主机,centos的版本建议不要超过7.2,本人用的7.7版本,不能创建kvm类型的虚拟机,只能创建qemu类型的虚拟机.把宿主机版本降到7.2后,恢复正常. 二.Nova控制节点安装报错 采用centos7.2,yum安装报错,需要在手动添加一个QEMU-EV.repo文件 [[email protected] yum.repos.d]# cat 1.repo [openstack] name=openstack base

openstack newton linuxbridge 改成 ovs

最近搭建了一个all in one 的 openstack newton 版,安装官方文档做用的是linuxbridge.已经老版玩的时候都是用的ovs,趁比较闲的时候也将N版改造一下 官方文档 http://docs.openstack.org/liberty/networking-guide/scenario-provider-ovs.html 下面只列出比较重要的文件,官方有文档,这次参考L版的文档来操作的 安装包yum install openstack-neutron openstac

openstack I版的搭建四--

[[email protected]]# cd /usr/local/src/neutron-2014.1 [[email protected] neutron-2014.1]# python setup.py install [[email protected] etc]# pwd /usr/local/src/neutron-2014.1/etc [[email protected] etc]# mkdir /etc/neutron [[email protected] etc]# mkdi

openstack I版的搭建二

[[email protected] ~]# cd /usr/local/src/ [[email protected] src]# cd keystone-2014.1 [[email protected] keystone-2014.1]# python setup.py install [[email protected] keystone-2014.1]# cd etc/ [[email protected] etc]# ll 总用量 72 -rw-rw-r-- 1 1004 1004

openstack I版的搭建六--

[[email protected] init.d]# chkconfig openstack-neutron-linuxbridge-agent on [[email protected] init.d]# chkconfig openstack-nova-compute on [[email protected] ~]# nova host-list +---------------------------+-------------+----------+ | host_name    

openstack I版的搭建五--

登陆 用户demo登陆 如果你在启动某个服务的时候,没启动起来,没日子 那么我们就手动启动一下. [[email protected] ~]# neutron-server --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini --config-file /etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini 这样的

openstack I版的搭建三--Nova

安装Nova [[email protected] src]# cd ~ [[email protected] ~]# cd /usr/local/src/nova-2014.1 [[email protected] nova-2014.1]# python setup.py install [[email protected] nova]# pwd /usr/local/src/nova-2014.1/etc/nova [ro[email protected] nova]# ll 总用量 48