【Openstack】实录手动部署Openstack Rocky 双节点(3)- Glance

第一篇:实录手动部署Openstack Rocky 双节点(1)- 基础服务
上一篇:实录手动部署Openstack Rocky 双节点(2)- Keystone
下一篇:手动部署Openstack Rocky 双节点(4)- Nova

参考文档

手动部署OpenStack Rocky双节点

Glance (controller-only)

添加Glance账户及其鉴权信息

[tony@controller ~]$ cat adminrc
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=$password
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
# 导入admin鉴权信息
[tony@controller ~]$ source adminrc

# 创建image服务
[tony@controller ~]$ openstack service create --name glance --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | e6233eeb690640f083fcf5ed7b827574 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

[tony@controller ~]$ openstack user create --domain default --password-prompt glance
User Password: <Enter New Password>
Repeat User Password: <Repeat New Password>
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | da95d21236994b10b88257225b159d46 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

[tony@controller ~]$ openstack role add --project service --user glance admin

[tony@controller ~]$ openstack endpoint create --region RegionOne image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 38fdbaa8ca084b63a5c06f94f97a0a6d |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e6233eeb690640f083fcf5ed7b827574 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
[tony@controller ~]$ openstack endpoint create --region RegionOne image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 70147e5d3ceb4997854f330e2be45d69 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e6233eeb690640f083fcf5ed7b827574 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
[tony@controller ~]$ openstack endpoint create --region RegionOne image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | de68ba8a3b6543e2ae5edeb5aae3ba48 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | e6233eeb690640f083fcf5ed7b827574 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

[tony@controller ~]$ openstack catalog list
+----------+----------+----------------------------------------+
| Name     | Type     | Endpoints                              |
+----------+----------+----------------------------------------+
| keystone | identity | RegionOne                              |
|          |          |   admin: http://controller:5000/v3/    |
|          |          | RegionOne                              |
|          |          |   internal: http://controller:5000/v3/ |
|          |          | RegionOne                              |
|          |          |   public: http://controller:5000/v3/   |
|          |          |                                        |
| glance   | image    | RegionOne                              |
|          |          |   public: http://controller:9292       |
|          |          | RegionOne                              |
|          |          |   internal: http://controller:9292     |
|          |          | RegionOne                              |
|          |          |   admin: http://controller:9292        |
|          |          |                                        |
+----------+----------+----------------------------------------+

安装软件包

[tony@controller ~]$ sudo yum install -y openstack-glance

修改配置文件

glance-api.conf文件

  • 原始配置文件
# 所有的配置选线都被注释掉
[tony@controller ~]$ sudo cat /etc/glance/glance-api.conf  | grep -v -E '^#|^$'
[DEFAULT]
[cors]
[database]
[glance_store]
[image_format]
[keystone_authtoken]
[matchmaker_redis]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
  • 修改后的配置文件
[tony@controller ~]$ sudo cat /etc/glance/glance-api.conf  | grep -v -E '^#|^$'

[DEFAULT]
[cors]
[database]
connection = mysql+pymysql://glance:$password@controller/glance
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images

[image_format]
[keystone_authtoken]
project_domain_name = Default
user_domain_name = Default
project_name = service
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
username = glance
password = $password

[matchmaker_redis]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]

glance-registry.conf文件

  • 原始配置文件
[tony@controller ~]$ sudo cat /etc/glance/glance-registry.conf  | grep -v -E '^#|^$'
[DEFAULT]
[database]
[keystone_authtoken]
[matchmaker_redis]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_policy]
[paste_deploy]
[profiler]
  • 修改后配置文件
[tony@controller ~]$ sudo cat /etc/glance/glance-registry.conf  | grep -v -E '^#|^$'

[DEFAULT]
[database]
connection = mysql+pymysql://glance:$password@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
username = glance
password = $password
project_domain_name = Default
user_domain_name = Default
project_name = service

[matchmaker_redis]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]

创建Glance数据库

[tony@controller ~]$ mysql -u root -p

Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 45
Server version: 10.1.20-MariaDB MariaDB Server
 
Copyright © 2000, 2016, Oracle, MariaDB Corporation Ab and others.
 
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
 
MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.00 sec)
 
MariaDB [(none)]> grant all privileges on glance.* to ‘glance’@‘localhost’ identified by ‘$password’;
Query OK, 0 rows affected (0.01 sec)
 
MariaDB [(none)]> grant all privileges on glance.* to ‘glance’@’%’ identified by ‘$password’;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [(none)]> quit
Bye

初始化Glance数据库

[tony@controller ~]$ sudo su -s /bin/sh -c "glance-manage db_sync" glance

/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1352: OsloDBDeprecationWarning: EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade
expire_on_commit=expire_on_commit, _conf=conf)
INFO [alembic.runtime.migration] Context impl MySQLImpl.

INFO [alembic.runtime.migration] Will assume non-transactional DDL.
Database is synced successfully.

启动服务

[tony@controller ~]$ sudo systemctl enable openstack-glance-api.service openstack-glance-registry.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.
# 启动并检查服务状态
[tony@controller ~]$ sudo systemctl start openstack-glance-api.service openstack-glance-registry.service
[tony@controller ~]$ sudo systemctl status openstack-glance-api.service openstack-glance-registry.service

openstack-glance-api.service - OpenStack Image Service (code-named Glance) API server
Loaded: loaded (/usr/lib/systemd/system/openstack-glance-api.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-04-07 23:02:48 EDT; 9s ago
Main PID: 73667 (glance-api)
CGroup: /system.slice/openstack-glance-api.service
├─73667 /usr/bin/python2 /usr/bin/glance-api
├─73694 /usr/bin/python2 /usr/bin/glance-api
├─73695 /usr/bin/python2 /usr/bin/glance-api
├─73696 /usr/bin/python2 /usr/bin/glance-api
└─73697 /usr/bin/python2 /usr/bin/glance-api
 
Apr 07 23:02:49 controller glance-api[73667]: /usr/lib/python2.7/site-packag…

Apr 07 23:02:49 controller glance-api[73667]: val = callable(*args, **kw)
 
openstack-glance-registry.service - OpenStack Image Service (code-named Glance) Registry server
Loaded: loaded (/usr/lib/systemd/system/openstack-glance-registry.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-04-07 23:02:48 EDT; 9s ago
Main PID: 73668 (glance-registry)
CGroup: /system.slice/openstack-glance-registry.service
├─73668 /usr/bin/python2 /usr/bin/glance-registry
├─73690 /usr/bin/python2 /usr/bin/glance-registry
├─73691 /usr/bin/python2 /usr/bin/glance-registry
├─73692 /usr/bin/python2 /usr/bin/glance-registry
└─73693 /usr/bin/python2 /usr/bin/glance-registry
 
Apr 07 23:02:49 controller glance-registry[73668]: /usr/lib/python2.7/site-pa…

Apr 07 23:02:49 controller glance-registry[73668]: val = callable(*args, **kw)
Hint: Some lines were ellipsized, use -l to show in full.

验证服务功能

[tony@controller ~]$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

–2019-04-07 23:07:15-- http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
Resolving download.cirros-cloud.net (download.cirros-cloud.net)… 64.90.42.85, 2607:f298:6:a036::bd6:a72a
Connecting to download.cirros-cloud.net (download.cirros-cloud.net)|64.90.42.85|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 12716032 (12M) [text/plain]
Saving to: ‘cirros-0.4.0-x86_64-disk.img’
 
100%[======================================>] 12,716,032 4.57MB/s in 2.7s
 
2019-04-07 23:07:19 (4.57 MB/s) - ‘cirros-0.4.0-x86_64-disk.img’ saved [12716032/12716032]

[tony@controller ~]$ openstack image create "cirros" 
--file cirros-0.4.0-x86_64-disk.img 
--disk-format qcow2 
--container-format bare 
--public

±-----------------±-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
±-----------------±-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | 443b7623e27ecf03dc9e01ee93f67afe |
| container_format | bare |
| created_at | 2019-04-08T03:08:28Z |
| disk_format | qcow2 |
| file | /v2/images/e0b94ac9-ec3d-41ad-b43e-5bbb47d03830/file |
| id | e0b94ac9-ec3d-41ad-b43e-5bbb47d03830 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | bcb33d5868a7442e914bd0568228d5ed |
| properties | os_hash_algo=‘sha512’, os_hash_value=‘6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78’, os_hidden=‘False’ |
| protected | False |
| schema | /v2/schemas/image |
| size | 12716032 |
| status | active |
| tags | |
| updated_at | 2019-04-08T03:08:29Z |
| virtual_size | None |
| visibility | public |
±-----------------±-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

[tony@controller ~]$ openstack image list

±-------------------------------------±-------±-------+
| ID | Name | Status |
±-------------------------------------±-------±-------+
| e0b94ac9-ec3d-41ad-b43e-5bbb47d03830 | cirros | active |
±-------------------------------------±-------±-------+

[tony@controller ~]$ sudo ls -l /var/lib/glance/images/

total 12420
-rw-r-----. 1 glance glance 12716032 Apr 7 23:08 e0b94ac9-ec3d-41ad-b43e-5bbb47d03830

小结

自此,Glance的安装成功并能正常运行。
Glance模块的日志在/var/log/glance目录下,如果在运行过程中出现错误,可以通过日志分析解决问题。

[tony@controller ~]$ sudo ls /var/log/glance/
api.log  registry.log

第一篇:实录手动部署Openstack Rocky 双节点(1)- 基础服务
上一篇:实录手动部署Openstack Rocky 双节点(2)- Keystone
下一篇:手动部署Openstack Rocky 双节点(4)- Nova

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值