Ubuntu 18.04上单机安装OpenStack Stein(非脚本方式):Glance

Ubuntu 18.04上单机安装OpenStack Stein(非脚本方式):Glance

安装与配置

使用root用户登陆MySQL数据库

# mysql

新建glance数据库

MariaDB [(none)]> CREATE DATABASE glance;

对glance数据库授予权限

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';

用之前对应生成的十六进制数代替“GLANCE_DBPASS”字段

退出数据库,然后运行admin用户的OpenRC脚本文件

$ . admin-openrc

创建glance用户

$ openstack user create --domain default --password-prompt glance

输出结果

User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 2a7cb6861f8a4aa283a45374f1268ee0 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

授予glance用户在service项目中使用admin角色

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

创建glance服务实体

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

输出结果

+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | ab0640334c624f63995c39d6f677285e |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

创建镜像服务的API端点

$ openstack endpoint create --region RegionOne image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 2072ef64d7c24e0bb9bbf26ae3b43b4e |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | ab0640334c624f63995c39d6f677285e |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
$ openstack endpoint create --region RegionOne image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | e7258f9db1e14089969ae5945fe8319a |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | ab0640334c624f63995c39d6f677285e |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
$ openstack endpoint create --region RegionOne image admin http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 347ea172c58841c89d2f374a9ba2a6ba |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | ab0640334c624f63995c39d6f677285e |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

安装glance软件包

# apt-get install glance

输入如下指令编辑glance配置文件

# vim /etc/glance/glance-api.conf

在打开的文件中修改如下键值

[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
[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 = GLANCE_PASS

在[glance_store] 部分,配置本地文件系统和镜像文件存储位置

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

用之前对应生成的十六进制数代替“GLANCE_PASS”和“GLANCE_DBPASS”字段
省略号(…)表示保留原有默认配置选项
[keystone_authtoken]部分要注释或删除其他选项

完成后同步glance数据库

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

重启镜像服务

# service glance-api restart

验证操作

通过一个小型Linux镜像CirrOS来测试镜像服务是否正常运行

下载镜像文件

$ wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

上传镜像至OpenStack,存储格式为QCOW2,容器格式为bare

$ openstack image create "cirros" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare

输出结果

+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                      |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                                                                                                                                                           |
| container_format | bare                                                                                                                                                                                       |
| created_at       | 2019-09-11T07:51:43Z                                                                                                                                                                       |
| disk_format      | qcow2                                                                                                                                                                                      |
| file             | /v2/images/3239e6b8-3eb9-4c47-8343-5a14bc2c1cad/file                                                                                                                                       |
| id               | 3239e6b8-3eb9-4c47-8343-5a14bc2c1cad                                                                                                                                                       |
| min_disk         | 0                                                                                                                                                                                          |
| min_ram          | 0                                                                                                                                                                                          |
| name             | cirros                                                                                                                                                                                     |
| owner            | None                                                                                                                                                                                       |
| 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-09-11T07:51:44Z                                                                                                                                                                       |
| virtual_size     | None                                                                                                                                                                                       |
| visibility       | shared                                                                                                                                                                                     |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

查看已有镜像列表

$ openstack image list

输出结果

+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 3239e6b8-3eb9-4c47-8343-5a14bc2c1cad | cirros | active |
+--------------------------------------+--------+--------+

参考链接: https://docs.openstack.org/glance/stein/install/install-ubuntu.html.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值