安装OpenStack Queens三节点群集

时间:2020-02-23 14:31:24  来源:igfitidea点击:

安装说明

在第二部分中,我们将安装glance image服务。
图像服务(概览)项目提供了一项服务,用户可以其中上载和发现要与其他服务一起使用的数据资产。
当前,这包括图像和元数据定义。
概览镜像服务包括发现,注册和检索虚拟机(VM)镜像。
Glance具有RESTful API,该API允许查询VM镜像元数据以及检索实际镜像。
(Openstack.org,2016)

我们可能会猜到的第一步是,将已扫视用户添加到已安装的Keystone中,并为其添加角色(角色是用户具有的授权级别。
)

让我们开始添加扫视用户。

[Hyman@theitroad ~(keystone)]# openstack user create --domain default --project service --password password glance
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | 76d124ff821e4db5ad792a113b54724e |
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 9feefa47a5414490ad16ac19201bac8f |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

您可以确认新的glance用户,如下所示。

[Hyman @ theitroad~(keystone)]# openstack user list
[Hyman @ theitroad~(keystone)]# openstack role add –project service –user glance admin
[Hyman @ theitroad~(keystone)]# openstack service create –name glance –description “Glance Serves Images” image
[Hyman @ theitroad~(keystone)]# export controller=192.168.122.130

我们将继续添加端点。
Keystone中的端点只是一个URL,可用于访问OpenStack中的服务。
端点就像给定用户使用OpenStack服务的联系点。
管理员URL用于管理员用户,内部URL是其他服务用来互相通信的URL。
公用URL是访问服务端点的其他所有人使用的URL。

[Hyman@theitroad ~(keystone)]# openstack endpoint create --region RegionOne image public http://$controller:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 86e2ed91b42341d3b8edf1c829842192 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 4145a8e51f9d4c0d81cf4f0f5d505ab8 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://192.168.122.130:9292      |
+--------------+----------------------------------+
[Hyman @ theitroad~(keystone)]# openstack endpoint create –region RegionOne image internal http://$controller:9292

在添加Gluise用户、分配角色和创建端点之后,Gluish需要一个数据库来运行,因此,让我们在安装和配置之前为其创建数据库。

[Hyman@theitroad ~(keystone)]# mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
No entry for terminal type "xterm-termite";
using dumb terminal settings.
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 Hyman@theitroad'localhost' identified by 'password';   
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on glance.* to Hyman@theitroad'%' identified by 'password';   
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit;
Bye

安装glance

[Hyman@theitroad ~(keystone)]#  yum --enablerepo=centos-openstack-queens,epel install openstack-glance -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: repos-jnb.psychz.net
 * epel: mirror.de.leaseweb.net
 * extras: repos-jnb.psychz.net
 * updates: repos-jnb.psychz.net
Resolving Dependencies
--> Running transaction check
---> Package openstack-glance.noarch 1:16.0.2-0.20160706180854.f676961.el7 will be installed
--> Processing Dependency: python-glance = 1:16.0.2-0.20160706180854.f676961.el7 for package: 1:openstack-glance-16.0.2-0.20160706180854.f676961.el7.noarch

配置glance

首先,创建默认文件的备份并创建具有已简洁参数的新文件以匹配环境。

sudo mv /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
vim /etc/glance/glance-api.conf

添加:

###New##
[DEFAULT]
bind_host = 0.0.0.0

[glance_store]

stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/

[database]

# MariaDB connection informotation. Do not forget the password for glance database connection = mysql+pymysql://glance:[email protected]/glance # keystone authentication details

[keystone_authtoken]

www_authenticate_uri = http://192.168.122.130:5000 auth_url = http://192.168.122.130:5000 memcached_servers = 192.168.122.130:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = password ##the password for service

[paste_deploy]

flavor = keystone

同时设置注册表:

mv /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
vim /etc/glance/glance-registry.conf

添加内容:

###New##
[DEFAULT]
bind_host = 0.0.0.0

[database]

# MariaDB connection information. Do not forget glance database password here. connection = mysql+pymysql://glance:[email protected]/glance # Keystone authentication details

[keystone_authtoken]

www_authenticate_uri = http://192.168.122.130:5000 auth_url = http://192.168.122.130:5000 memcached_servers = 192.168.122.130:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = password ##service password here

[paste_deploy]

flavor = keystone

更改配置文件的文件权限和文件所有权,如下所示

chmod 640 /etc/glance/glance-api.conf /etc/glance/glance-registry.conf
chown root:glance /etc/glance/glance-api.conf /etc/glance/glance-registry.conf

执行数据库同步。如果您在这里有错误,请确认您的密码是正确的,文件的间距也设置好。最后应该会看到“数据库同步成功”。

[Hyman@theitroad ~(keystone)]# su -s /bin/bash glance -c "glance-manage db_sync"
/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

启动并启用openstack glance api和openstack glance registry,如下所示,您就可以使用glance服务了。不要忘记启用防火墙中的端口。

sudo systemctl start openstack-glance-api openstack-glance-registry
sudo systemctl enable openstack-glance-api openstack-glance-registry 
sudo firewall-cmd --add-port={9191/tcp,9292/tcp} --permanent
sudo firewall-cmd --reload