其他分享
首页 > 其他分享> > OpenStack部署(三)

OpenStack部署(三)

作者:互联网

部署版本:pike
部署环境:CentOS7.6
配置文件中所有controller可修改为控制节点ip地址
配置过程中使用 echo $? 验证命令执行情况
Image Service
图像服务glance
映像服务(glance)使用户能够发现、注册和检索虚拟机映像。它提供了一个REST API,能够查询虚拟机映像元数据并检索实际映像。可以将通过映像服务提供的虚拟机映像存储在各种位置,从简单的文件系统到对象存储系统(如OpenStack对象存储)。
一、先决条件
在安装和配置映像服务之前,必须创建数据库、服务凭据和API端点。

1.创建数据库root访问数据库

[root@controller /]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. 

创建glance数据库

MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.00 sec)

授予对glance数据库的正确访问权限:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'controller' \
    ->   IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
    ->   IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.00 sec)

2.执行 admin 凭据 获得仅限管理员的CLI命令:

[root@controller /]# source /etc/openrc/admin-openrc.sh

3.创建服务凭据
创建glance用户

[root@controller /]# openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 3882fd00aaed4e9e8d60c34d57408223 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

将管理员角色添加到glance用户和服务项目:

[root@controller /]# openstack role add --project service --user glance admin
[root@controller /]# echo $?
0

创建glance服务主体

[root@controller/]# openstack service create --name glance \
>   --description "OpenStack Image" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | c098fe26e9e7405188f3e6a83d2a1b07 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+

4.创建镜像服务API终结点

root@controller/]# openstack endpoint create --region RegionOne \
>   image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 95af37c0e5eb485ea127f30fb0466db3 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c098fe26e9e7405188f3e6a83d2a1b07 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+
root@controller/]# openstack endpoint create --region RegionOne \
>   image public http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 95af37c0e5eb485ea127f30fb0466db3 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c098fe26e9e7405188f3e6a83d2a1b07 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

[root@controller/]# openstack endpoint create --region RegionOne \
>   image internal http://controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 179d8af3926b417c8a5ed3c19fdfc695 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c098fe26e9e7405188f3e6a83d2a1b07 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://controller:9292           |
+--------------+----------------------------------+

二、安装和配置组件
1.安装glance软件

[root@controller/]# yum install openstack-glance

2.编辑/etc/glance/glance-api.conf文件及修改内容

[root@controller/]# vim /etc/glance/glance-api.conf
[database]
connection = mysql+pymysql://glance:qwer1234@controller/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 = qwer1234


[paste_deploy]
flavor = keystone


[glance_store]
tores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
  1. 编辑/etc/glance/glance-registry.conf及修改文件内容
[root@controller /]# vim  /etc/glance/glance-registry.conf
[database]
connection = mysql+pymysql://glance:qwer1234@controller/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 = qwer1234

[paste_deploy]
flavor = keystone

4.填充图像服务数据库:

[root@controller /]# su -s /bin/sh -c "glance-manage db_sync" glance
/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1336: 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.
INFO  [alembic.runtime.migration] Running upgrade  -> liberty, liberty initial
INFO  [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table
INFO  [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server
INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_expand01, add visibility to images
INFO  [alembic.runtime.migration] Running upgrade ocata_expand01 -> pike_expand01, empty expand for symmetry with pike_contract01
INFO  [alembic.runtime.migration] Running upgrade pike_expand01 -> queens_expand01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: queens_expand01, current revision(s): queens_expand01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Database migration is up to date. No migration needed.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_contract01, remove is_public from images
INFO  [alembic.runtime.migration] Running upgrade ocata_contract01 -> pike_contract01, drop glare artifacts tables
INFO  [alembic.runtime.migration] Running upgrade pike_contract01 -> queens_contract01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: queens_contract01, current revision(s): queens_contract01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Database is synced successfully.

三、完成安装
启动glance服务并开机自启

[root@controller /]# 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.
[root@controller /]# systemctl start openstack-glance-api.service \
>   openstack-glance-registry.service
[root@controller /]# echo $?
0

标签:INFO,部署,controller,migration,OpenStack,glance,runtime,alembic
来源: https://blog.csdn.net/weixin_44099173/article/details/123182828