OpenStack

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > 云和虚拟化 > OpenStack > OpenStack部署Glance

OpenStack手动分布式部署Glance(Queens版)

作者:小强在学习的路上

这篇文章主要介绍了OpenStack手动分布式部署Glance(Queens版),Glance为云平台虚拟机提供镜像服务,例如:上传镜像、删除镜像等,需要的朋友可以参考下

Glance简介

【glance镜像服务】

它在open stack中的项目名称为Glance.在早期的open stack版本中,Glance只有管理镜像的功能,并不具备镜像存储功能。现在,Glance已经发展称为集上传,检索,管理和存储等多种功能的open stack核心服务。

【glance由两部分组成】

(1)glance-api: 接受云系统镜像的创建,删除,读取请求

(2)glance-Registry: 云系统的镜像注册服务

【镜像服务的主要功能】

1.查询和获取镜像的元数据和镜像本身

2.注册和上传虚拟机镜像,包括镜像的创建、上传、下载和管理

3.维护镜像信息,包括元数据和镜像本身

4.支持多种方式存储镜像,包括普通的文件系统、swift、Amazon、S3等

5.对虚拟机实例执行创建快照命令来创建新的镜像,或者备份虚拟机的状态

1、登录数据库配置(在controller执行)  

1.1登录数据库

[root@controller ~]# mysql -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.3.20-MariaDB MariaDB Server
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> 

  1.2数据库里创建glance

MariaDB [(none)]> CREATE DATABASE glance;

  1.3授权对glance数据库的正确访问

GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '000000';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%'  IDENTIFIED BY '000000';

  1.4退出数据库

MariaDB [(none)]> quit;

  1.5创建glance用户密码为000000

[root@controller ~]# openstack user create --domain default --password 000000 glance
Missing value auth-url required for auth plugin password

        如上我的这里会报错,时因为没有source环境变量导致。

        如下修改/etc/profile文件解决:

#[root@controller ~]# vi /etc/profile
 
export OS_USERNAME=admin
export OS_PASSWORD=000000
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
[root@controller ~]# source /etc/profile
[root@controller ~]# openstack user create --domain default --password 000000 glance

  1.6增加admin角色

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

  1.7创建glance服务

openstack service create --name glance --description "OpenStack Image" image

 

   1.8创建镜像服务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

2、安装glance配置组件  

2.1安装glance包

yum install openstack-glance -y

  2.2备份配置文件并且修改(修改了4个地方)

cp /etc/glance/glance-api.conf{,.bak}
grep -Ev "^$|#" /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf
vi /etc/glance/glance-api.conf
 
[database]
connection = mysql+pymysql://glance:000000@controller/glance
 
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
 
[keystone_authtoken]
www_authenticate_uri  = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = 000000
 
[paste_deploy]
flavor = keystone
 

  2.3同步数据库

su -s /bin/sh -c "glance-manage db_sync" glance
systemctl start openstack-glance-api.servicesystemctl enable openstack-glance-api.service

  2.4(这一步可以不做)现在glance没有日志,我们需要配置下

#[root@controller ~]# vi /etc/glance/glance-api.conf
 
[DEFAULT]
log_file = /var/log/glance/glance-api.log
[root@controller ~]# systemctl restart openstack-glance-api.service
[root@controller ~]# tail -f /var/log/glance/glance-api.log 
).  Its value may be silently ignored in the future.
2023-02-09 10:18:22.350 43599 INFO glance.common.wsgi [-] Starting 4 workers
2023-02-09 10:18:22.352 43599 INFO glance.common.wsgi [-] Started child 43611
2023-02-09 10:18:22.354 43611 INFO eventlet.wsgi.server [-] (43611) wsgi starting up on http://0.0.0.0:9292
2023-02-09 10:18:22.355 43599 INFO glance.common.wsgi [-] Started child 43612
2023-02-09 10:18:22.357 43612 INFO eventlet.wsgi.server [-] (43612) wsgi starting up on http://0.0.0.0:9292
2023-02-09 10:18:22.358 43599 INFO glance.common.wsgi [-] Started child 43613
2023-02-09 10:18:22.360 43613 INFO eventlet.wsgi.server [-] (43613) wsgi starting up on http://0.0.0.0:9292
2023-02-09 10:18:22.361 43599 INFO glance.common.wsgi [-] Started child 43614
2023-02-09 10:18:22.363 43614 INFO eventlet.wsgi.server [-] (43614) wsgi starting up on http://0.0.0.0:9292

3、测试

下载cirros-0.4.0-x86_64-disk.img这个镜像上传到/opt下面(镜像文件在我的资源csdn下载地方找到)

切换到/opt目录下

[root@controller opt]# ls
cirros-0.4.0-x86_64-disk.img
[root@controller opt]# glance image-create --name "cirros" \
   --file cirros-0.4.0-x86_64-disk.img \
   --disk-format qcow2 --container-format bare \
   --visibility=public
+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                                                 |
| container_format | bare                                                                             |
| created_at       | 2023-02-09T15:25:52Z                                                             |
| disk_format      | qcow2                                                                            |
| id               | 79e21395-0d41-4c98-86f2-bfa813a48a2f                                             |
| min_disk         | 0                                                                                |
| min_ram          | 0                                                                                |
| name             | cirros                                                                           |
| os_hash_algo     | sha512                                                                           |
| os_hash_value    | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e |
|                  | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78                                 |
| os_hidden        | False                                                                            |
| owner            | 4c7bdbb75b9e481db886549f7d2711be                                                 |
| protected        | False                                                                            |
| size             | 12716032                                                                         |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2023-02-09T15:25:53Z                                                             |
| virtual_size     | Not available                                                                    |
| visibility       | public                                                                           |
+------------------+----------------------------------------------------------------------------------+
[root@controller opt]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 79e21395-0d41-4c98-86f2-bfa813a48a2f | cirros |
+--------------------------------------+--------+
 

以上说明部署glance成功

到此这篇关于OpenStack手动分布式部署Glance(Queens版)的文章就介绍到这了,更多相关OpenStack部署Glance内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

您可能感兴趣的文章:
阅读全文