使用Packstack在CentOS 7上安装OpenStack

时间:2020-02-23 14:40:12  来源:igfitidea点击:

在CentOS 7或者RHEL 7 Linux上安装openstack的循序渐进指南。
使用packstack CentOS的Openstack安装指南。
7在RHEL或者CentOS 7 Linux中使用packstack的逐步安装指南。
在CentOS 7 Linux上安装OpenStack。
Openstack安装指南在CentOS 7上为单节点。
在CentOS 7或者RHEL 7 Linux服务器上使用packstack进行Openstack安装的逐步指南。
在CentOS 7上安装Openstack。
在centos 7上逐步安装openstack。
如何使用Packstack在CentOS 7上安装openstack。

尽管即使使用packstack,我们也可以使用"两个或者多个计算节点"启动多节点openstack部署,但是"使用packstack安装openstack时,不能有多个控制器节点"。
在本文中,将介绍分步教程,以使用Packstack在CentOS 7和RHEL 7上安装OpenStack。

什么是OpenStack?

OpenStack项目,也称为云操作系统,由许多开发单独子系统的不同项目组成。
任何OpenStack安装都只能包含其中一部分。
某些子系统甚至可以单独使用,也可以作为任何其他OpenSource项目的一部分使用。
随着新堆栈的出现以及现有堆栈功能的分离,它们的数量在OpenStack项目的版本之间不断增加。
例如,nova-volume服务被提取为单独的Cinder项目。

确保在刀片服务器上启用并支持虚拟机管理程序

# grep -E ' svm | vmx' /proc/cpuinfo

我们应该在处理器支持的标志中看到svm或者vmx。
同样,如果我们执行命令:

# lsmod | grep kvm
kvm_intel 143187 3
kvm 455843 1 kvm_intel

或者

# lsmod | grep kvm
kvm_amd 60314 3
kvm 461126 1 kvm_amd

我们应该看到内存中加载了两个内核模块。
kvm是独立于供应商的模块,kvm_intel或者kvm_amd分别执行VT-x或者AMD-V功能。

OpenStack发行版的下载链接

Red Hat OpenStack Platform(60天试用版)https://www.redhat.com/en/insights/openstack

Red Hat的RDO https://www.rdoproject.org/

Mirantis OpenStack https://www.mirantis.com/products/mirantis-openstacksoftware/

Ubuntu OpenStackhttp://www.ubuntu.com/cloud/openstack

SUSE OpenStack Cloud(60天试用版)https://www.suse.com/products/suse-openstack-cloud/

重要的提示:

如果使用的是虚拟环境,则可以在安装和配置openstack之前拍摄快照,以便在发生任何故障时可以还原。
在物理环境上,我们可以备份分区,以后可以在发生任何故障时还原分区。

使用Packstack在CentOS 7上安装Openstack

Packstack提供了一种在一个或者多台计算机上部署OpenStack Platform环境的简便方法,因为它可以通过应答文件进行自定义,该文件包含一组允许自定义基础Openstack Platform服务的参数。

什么是答案文件?

Packstack默认情况下提供一个答案文件模板,该模板可在一个环境中全部部署。
当非交互地运行packstack命令时,必须通过文本文件(称为答案文件)而不是通过标准输入来提供配置选项。

启动物理主机服务器

首先,我们需要一个基础服务器,在该基础服务器上我们将创建我用RHEL 7.4购买了服务器的整个Openstack云

  • 下次登录到服务器并使用Red Hat Subscription注册

  • 使用"应用程序安装程序"安装Virtual Machine Manager(如果尚未安装)

  • 下一步开始按照以下各章中的说明创建虚拟机

配置BIND DNS服务器

在使用Packstack在CentOS 7上安装OpenStack之前,建议使用DNS服务器。

以下是我的示例配置文件

# cd /var/named/chroot/var/named

控制器和计算节点的前向区域配置文件

# cat example.zone
$TTL 1D
@       IN SOA  example. root (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@               IN NS   example.
                IN A    127.0.0.1
                IN A    10.43.138.12
openstack       IN A    10.43.138.12
controller      IN A    192.168.122.49
compute         IN A    192.168.122.215
compute-rhel    IN A    192.168.122.13
controller-rhel IN A    192.168.122.12

我托管OpenStack的物理主机服务器的第一个反向区域文件

# cat example.rzone
$TTL 1D
@       IN SOA  example. root.example. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       IN NS   example.
        IN A    127.0.0.1
        IN PTR  localhost.
12      IN PTR  openstack.example.

控制器和计算节点的第二个反向区域文件

# cat openstack.rzone
$TTL 1D
@       IN SOA  example. root.example. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
@       IN NS   example.
        IN A    127.0.0.1
        IN PTR  localhost.
49      IN PTR  controller.example.
215     IN PTR  compute.example.
12      IN PTR  controller-rhel.example.
13      IN PTR  compute-rhel.example.

启动Compute VM

基本服务之一是OpenStack Compute(Nova)。

此服务安装在所有群集计算机节点上。
它管理虚拟设备(处理器,内存,块设备,网络适配器)的抽象级别。
Nova提供了对虚拟机实例的管理,该虚拟机可以对虚拟机管理程序进行寻址,并在启动和停止时发出命令。

注意:实例使用的存储空间将位于/var/lib/glance目录下,因为/var使用的任何分区都必须具有一些可用的存储空间才能创建实例。
以下是我的设置摘要

[root@compute-rhel ~]# lvs
  LV   VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home rhel -wi-ao---- 134.49g
  root rhel -wi-ao----  50.00g
  swap rhel -wi-ao----  14.50g
[root@compute-rhel ~]# pvs
  PV         VG   Fmt  Attr PSize    PFree
  /dev/vda2  rhel lvm2 a--  <199.00g 4.00m
[root@compute-rhel ~]# vgs
  VG   #PV #LV #SN Attr   VSize    VFree
  rhel   1   3   0 wz--n- <199.00g 4.00m
[root@compute-rhel ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   50G  2.3G   48G   5% /
devtmpfs                15G     0   15G   0% /dev
tmpfs                   15G     0   15G   0% /dev/shm
tmpfs                   15G   17M   15G   1% /run
tmpfs                   15G     0   15G   0% /sys/fs/cgroup
/dev/vda1             1014M  131M  884M  13% /boot
/dev/mapper/rhel-home  135G   33M  135G   1% /home
tmpfs                  2.9G     0  2.9G   0% /run/user/0
[root@compute-rhel ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:             28           0          26           0           1          27
Swap:            14           0          14

前提条件

在CentOS 7上安装OpenStack之前,请使用所示命令禁用并停止以下服务。

# systemctl disable NetworkManager --now
# systemctl disable firewalld --now
# systemctl restart network
# systemctl enable network

对于RHEL 7节点:按照控制器的要求注册并订阅必要的Red Hat通道。

在开始之前,请禁用所有存储库。

# subscription-manager repos --disable=*

接下来,启用"在RHEL 7上安装OpenStack"所需的所有必需Repo协议。

# subscription-manager repos --enable=rhel-7-server-rh-common-rpms
Repository 'rhel-7-server-rh-common-rpms' is enabled for this system.
# subscription-manager repos --enable=rhel-7-server-openstack-8-rpms
Repository 'rhel-7-server-openstack-8-rpms' is enabled for this system.
# subscription-manager repos --enable=rhel-7-server-extras-rpms
Repository 'rhel-7-server-extras-rpms' is enabled for this system.
# subscription-manager repos --enable=rhel-7-server-rpms
Repository 'rhel-7-server-rpms' is enabled for this system.

启用以下存储库以使用Packstack在CentOS 7上安装OpenStack。

# yum install -y https://rdoproject.org/repos/rdo-release.rpm

接下来,通过安装以下rpm安装openstack存储库

# yum install -y centos-release-openstack-stein

确保已启用存储库:

# yum-config-manager --enable openstack-stein

启动控制器VM

Controller节点是运行大多数共享OpenStack服务和其他工具的位置。
它为云提供API,调度和其他共享服务。

我已经共享了虚拟机的配置。
由于控制器节点将仅托管重要的openstack服务,因此我们无需为此节点分配过多的资源。

注意:我还将创建一个额外的卷组" cinder-volumes",以供CINDER服务使用。

因此,请确保在创建控制器节点时,创建一个具有足够空间的其他卷组cinder-volumes,对我来说,我给了100GB,它将用于在启动Instance时用于添加其他卷。

以下是我的设置摘要

[root@controller-rhel ~]# pvs
  PV         VG             Fmt  Attr PSize    PFree
  /dev/vda3  rhel           lvm2 a--   <38.52g   <7.69g
  /dev/vdb1  cinder-volumes lvm2 a--  <100.00g <100.00g
[root@controller-rhel ~]# vgs
  VG             #PV #LV #SN Attr   VSize    VFree
  cinder-volumes   1   0   0 wz--n- <100.00g <100.00g
  rhel             1   2   0 wz--n-  <38.52g   <7.69g
[root@controller-rhel ~]# lvs
  LV     VG   Attr       LSize  Pool   Origin Data%  Meta%  Move Log Cpy%Sync Convert
  pool00 rhel twi-aotz-- 30.79g               15.04  11.48
  root   rhel Vwi-aotz-- 30.79g pool00        15.04
[root@controller-rhel ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              9           2           4           0           3           7
Swap:             0           0           0

前提条件

前提条件列表与上面对"计算节点"所做的操作相同。

安装Packstack

现在要在CentOS 7上安装OpenStack,我们需要PackStack实用程序,我们可以使用yum进行安装。

# yum install -y openstack-packstack

接下来生成答案文件/root/answers.txt并查看生成的文件

# packstack --gen-answer-file ~/answer-file.txt

现在,我们准备创建和修改我们的答案文件,以在控制器和计算节点上部署openstack服务

创建答案文件并安装Openstack

以下是我为在CentOS 7上安装OpenStack的设置所做的更改。

接下来,在控制器节点上执行packstack实用程序,以使用如下所示的语法在CentOS 7上安装OpenStack。

[root@controller-rhel ~]# packstack --answer-file /root/answers.txt
Welcome to the Packstack setup utility
The installation log file is available at: /var/tmp/packstack/20160707-225026-DOdBB6/openstack-setup.log
Installing:
Clean Up                                             [ DONE ]
Discovering ip protocol version                      [ DONE ]
Setting up ssh keys                                  [ DONE ]
Preparing servers                                    [ DONE ]
Pre installing Puppet and discovering hosts' details [ DONE ]
Adding pre install manifest entries                  [ DONE ]
Installing time synchronization via NTP              [ DONE ]
Setting up CACERT                                    [ DONE ]
Adding AMQP manifest entries                         [ DONE ]
Adding MariaDB manifest entries                     [ DONE ]
Adding Apache manifest entries                       [ DONE ]
Fixing Keystone LDAP config parameters to be undef if empty[ DONE ]
Adding Keystone manifest entries                     [ DONE ]
Adding Glance Keystone manifest entries              [ DONE ]
Adding Glance manifest entries                       [ DONE ]
Adding Cinder Keystone manifest entries              [ DONE ]
Checking if the Cinder server has a cinder-volumes vg[ DONE ]
Adding Cinder manifest entries                       [ DONE ]
Adding Nova API manifest entries                     [ DONE ]
Adding Nova Keystone manifest entries                [ DONE ]
Adding Nova Cert manifest entries                    [ DONE ]
Adding Nova Conductor manifest entries               [ DONE ]
Creating ssh keys for Nova migration                 [ DONE ]
Gathering ssh host keys for Nova migration           [ DONE ]
Adding Nova Compute manifest entries                 [ DONE ]
Adding Nova Scheduler manifest entries               [ DONE ]
Adding Nova VNC Proxy manifest entries               [ DONE ]
Adding OpenStack Network-related Nova manifest entries[ DONE ]
Adding Nova Common manifest entries                  [ DONE ]
Adding Neutron VPNaaS Agent manifest entries         [ DONE ]
Adding Neutron FWaaS Agent manifest entries          [ DONE ]
Adding Neutron LBaaS Agent manifest entries          [ DONE ]
Adding Neutron API manifest entries                  [ DONE ]
Adding Neutron Keystone manifest entries             [ DONE ]
Adding Neutron L3 manifest entries                   [ DONE ]
Adding Neutron L2 Agent manifest entries             [ DONE ]
Adding Neutron DHCP Agent manifest entries           [ DONE ]
Adding Neutron Metering Agent manifest entries       [ DONE ]
Adding Neutron Metadata Agent manifest entries       [ DONE ]
Adding Neutron SR-IOV Switch Agent manifest entries  [ DONE ]
Checking if NetworkManager is enabled and running    [ DONE ]
Adding OpenStack Client manifest entries             [ DONE ]
Adding Horizon manifest entries                      [ DONE ]
Adding post install manifest entries                 [ DONE ]
Copying Puppet modules and manifests                 [ DONE ]
Applying 192.168.122.13_prescript.pp
Applying 192.168.122.12_prescript.pp
192.168.122.13_prescript.pp:                         [ DONE ]
192.168.122.12_prescript.pp:                         [ DONE ]
Applying 192.168.122.13_chrony.pp
Applying 192.168.122.12_chrony.pp
192.168.122.13_chrony.pp:                            [ DONE ]
192.168.122.12_chrony.pp:                            [ DONE ]
Applying 192.168.122.12_amqp.pp
Applying 192.168.122.12_mariadb.pp
192.168.122.12_amqp.pp:                              [ DONE ]
192.168.122.12_mariadb.pp:                           [ DONE ]
Applying 192.168.122.12_apache.pp
192.168.122.12_apache.pp:                            [ DONE ]
Applying 192.168.122.12_keystone.pp
Applying 192.168.122.12_glance.pp
Applying 192.168.122.12_cinder.pp
192.168.122.12_keystone.pp:                          [ DONE ]
192.168.122.12_cinder.pp:                            [ DONE ]
192.168.122.12_glance.pp:                            [ DONE ]
Applying 192.168.122.12_api_nova.pp
192.168.122.12_api_nova.pp:                          [ DONE ]
Applying 192.168.122.12_nova.pp
Applying 192.168.122.13_nova.pp
192.168.122.12_nova.pp:                              [ DONE ]
192.168.122.13_nova.pp:                              [ DONE ]
Applying 192.168.122.13_neutron.pp
Applying 192.168.122.12_neutron.pp
192.168.122.12_neutron.pp:                           [ DONE ]
192.168.122.13_neutron.pp:                           [ DONE ]
Applying 192.168.122.12_osclient.pp
Applying 192.168.122.12_horizon.pp
192.168.122.12_osclient.pp:                          [ DONE ]
192.168.122.12_horizon.pp:                           [ DONE ]
Applying 192.168.122.13_postscript.pp
Applying 192.168.122.12_postscript.pp
192.168.122.12_postscript.pp:                        [ DONE ]
192.168.122.13_postscript.pp:                        [ DONE ]
Applying Puppet manifests                            [ DONE ]
Finalizing                                           [ DONE ]
 ** ** Installation completed successfully ** ****
Additional information:
 * File /root/keystonerc_admin has been created on OpenStack client host 192.168.122.12. To use the command line tools you need to source the file.
 * To access the OpenStack Dashboard browse to http://192.168.122.12/dashboard .
Please, find your login credentials stored in the keystonerc_admin in your home directory.
 * The installation log file is available at: /var/tmp/packstack/20160707-225026-DOdBB6/openstack-setup.log
 * The generated manifests are available at: /var/tmp/packstack/20160707-225026-DOdBB6/manifests

如果一切顺利,那么我们应该会看到所有的绿色,并且最后我们将获得指向仪表板的链接(突出显示)。
因此,这意味着我们在RHEL/CentOS 7上的openstack安装已完成。

说明:

但是,如果需要更新配置,则可以使用选项-d重新运行PackStack。

检查OpenStack服务状态

安装openstack-utils以检查所有openstack服务的状态

# yum -y install openstack-utils

接下来检查状态

[root@controller-rhel ~]# openstack-status
== Nova services ==
openstack-nova-api:                     active
openstack-nova-cert:                    active
openstack-nova-compute:                 inactive  (disabled on boot)
openstack-nova-network:                 inactive  (disabled on boot)
openstack-nova-scheduler:               active
openstack-nova-conductor:               active
== Glance services ==
openstack-glance-api:                   active
openstack-glance-registry:              active
== Keystone service ==
openstack-keystone:                     inactive  (disabled on boot)
== Horizon service ==
openstack-dashboard:                    active
== neutron services ==
neutron-server:                         active
neutron-dhcp-agent:                     active
neutron-l3-agent:                       active
neutron-metadata-agent:                 active
neutron-openvswitch-agent:              active
== Cinder services ==
openstack-cinder-api:                   active
openstack-cinder-scheduler:             active
openstack-cinder-volume:                active
openstack-cinder-backup:                inactive  (disabled on boot)
== Support services ==
mysqld:                                 unknown
libvirtd:                               active
openvswitch:                            active
dbus:                                   active
target:                                 active
rabbitmq-server:                        active
memcached:                              active
== Keystone users ==
Warning keystonerc not sourced

源keystonerc文件

现在,一旦在CentOS 7上安装OpenStack,接下来我们就可以获取keystoncerc文件来获取openstack-service状态的更详细列表。
keystonerc文件将在root用户的主文件夹中可用,如下所示:

[root@controller-rhel ~]# ls -l keystonerc_admin
-rw-------. 1 root root 229 Jul  7 22:57 keystonerc_admin
[root@controller-rhel ~]# pwd
/root
[root@controller-rhel ~]# source keystonerc_admin

接下来检查openstack服务的状态

[root@controller-rhel ~(keystone_admin)]# openstack-status
== Nova services ==
openstack-nova-api:                     active
openstack-nova-cert:                    active
openstack-nova-compute:                 inactive  (disabled on boot)
openstack-nova-network:                 inactive  (disabled on boot)
openstack-nova-scheduler:               active
openstack-nova-conductor:               active
== Glance services ==
openstack-glance-api:                   active
openstack-glance-registry:              active
== Keystone service ==
openstack-keystone:                     inactive  (disabled on boot)
== Horizon service ==
openstack-dashboard:                    active
== neutron services ==
neutron-server:                         active
neutron-dhcp-agent:                     active
neutron-l3-agent:                       active
neutron-metadata-agent:                 active
neutron-openvswitch-agent:              active
== Cinder services ==
openstack-cinder-api:                   active
openstack-cinder-scheduler:             active
openstack-cinder-volume:                active
openstack-cinder-backup:                inactive  (disabled on boot)
== Support services ==
mysqld:                                 unknown
libvirtd:                               active
openvswitch:                            active
dbus:                                   active
target:                                 active
rabbitmq-server:                        active
memcached:                              active
== Keystone users ==
+----------------------------------+---------+---------+-------------------+
|                id                |   name  | enabled |       email       |
+----------------------------------+---------+---------+-------------------+
| e97f18a9994e4b99bcc0e6fe8db95cd3 |  admin  |   True  |   root@localhost  |
| dccbaca5e2ee4866b343573678ec3bf7 |  cinder |   True  |  cinder@localhost |
| 7dec80c93f8a4aafa1559a59e6bf606c |  glance |   True  |  glance@localhost |
| 778e4fbefdfa4329bf9b7143ce6ffe74 | neutron |   True  | neutron@localhost |
| e3d85ca8a8bb4ba5a9457712ce5814f5 |   nova  |   True  |   nova@localhost  |
+----------------------------------+---------+---------+-------------------+
== Glance images ==
+----+------+
| ID | Name |
+----+------+
+----+------+
== Nova managed services ==
+----+------------------+------------------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary           | Host                   | Zone     | Status  | State | Updated_at                 | Disabled Reason |
+----+------------------+------------------------+----------+---------+-------+----------------------------+-----------------+
| 1  | nova-consoleauth | controller-rhel.example| internal | enabled | up    | 2016-07-07T18:02:59.000000 | -               |
| 2  | nova-scheduler   | controller-rhel.example| internal | enabled | up    | 2016-07-07T18:03:00.000000 | -               |
| 3  | nova-conductor   | controller-rhel.example| internal | enabled | up    | 2016-07-07T18:03:01.000000 | -               |
| 4  | nova-cert        | controller-rhel.example| internal | enabled | up    | 2016-07-07T18:02:57.000000 | -               |
| 5  | nova-compute     | compute-rhel.example   | nova     | enabled | up    | 2016-07-07T18:03:04.000000 | -               |
+----+------------------+------------------------+----------+---------+-------+----------------------------+-----------------+
== Nova networks ==
+----+-------+------+
| ID | Label | Cidr |
+----+-------+------+
+----+-------+------+
== Nova instance flavors ==
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
== Nova instances ==
+----+------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+----+------+--------+------------+-------------+----------+
+----+------+--------+------------+-------------+----------+

如我们所见,它为我提供了所有OpenStack服务的详细状态。

访问OpenStack Horizon仪表板

因此,现在我们已经在CentOS/RHEL 7上使用packstack完成了OpenStack的安装,并且我们可以看到我们的服务也已正常运行。
现在,我们终于可以登录到地平线仪表盘了。