安装三个节点OpenStack Queens集群

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

创建和启动虚拟机实例 安装Horizon

第一步:使用我们在系统中之前创建的新用户登录,让我们继续创建实例

[Hyman@theitroad ~(keystone)]# su - tech ##use your username
 [Hyman@theitroad ~]$
 [Hyman@theitroad ~]$vim ~/keystonerc
 export OS_PROJECT_DOMAIN_NAME=default
 export OS_USER_DOMAIN_NAME=default
 export OS_PROJECT_NAME=helloworld #remember the project we had created
 export OS_USERNAME=penchant   #remember the username we had created for the project
 export OS_PASSWORD=helloworld123 #remember the password we had created for the project
 export OS_AUTH_URL=http://192.168.122.130:5000/v3
 export OS_IDENTITY_API_VERSION=3
 export OS_IMAGE_API_VERSION=2
 export PS1='[\Hyman@theitroad\h \W(keystone)]$'
[Hyman@theitroad ~]$chmod 600 ~/keystonerc
[Hyman@theitroad ~]$source ~/keystonerc 
[Hyman@theitroad ~(keystone)]$echo "source ~/keystonerc " >> ~/.bash_profile

第二步:检查Flavors,网络和图像

[Hyman@theitroad ~(keystone)]$openstack flavor list                         
 +----+-------+-----+------+-----------+-------+-----------+
 | ID | Name  | RAM | Disk | Ephemeral | VCPUs | Is Public |
 +----+-------+-----+------+-----------+-------+-----------+
 | 0  | Basic | 512 |   10 |         0 |     1 | True      |
 +----+-------+-----+------+-----------+-------+-----------+
[Hyman@theitroad ~(keystone)]$openstack network list 
 +--------------------------------------+-----------+--------------------------------------+
 | ID                                   | Name      | Subnets                              |
 +--------------------------------------+-----------+--------------------------------------+
 | e9927eb9-7467-4e7e-844a-fc07db9c9b85 | firstnet1 | 800efe16-5a49-40f9-8523-e43a48560650 |
 +--------------------------------------+-----------+--------------------------------------+
[Hyman@theitroad ~(keystone)]$openstack image list   
 +--------------------------------------+---------+--------+
 | ID                                   | Name    | Status |
 +--------------------------------------+---------+--------+
 | c13fd621-0d74-4e8f-9481-5cbb02decbd3 | CentOS7 | active |
 +--------------------------------------+---------+--------+

第三步:为实例创建一个安全组,我们可以称之为"securegrooupone"部分的任何名称

[Hyman@theitroad ~(keystone)]$openstack security group create securegroupone
 +-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
 | Field           | Value                                                                                                                                                 |
 +-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
 | created_at      | 2019-03-14T10:41:10Z                                                                                                                                  |
 | description     | securegroupone                                                                                                                                        |
 | id              | 05e8cdf2-d59b-40fa-ad55-59d9a3c8af04                                                                                                                  |
 | name            | securegroupone                                                                                                                                        |
 | project_id      | f5547f8c879c41bea9c60e4541745c35                                                                                                                      |
 | revision_number | 2                                                                                                                                                     |
 | rules           | created_at='2019-03-14T10:41:10Z', direction='egress', ethertype='IPv6', id='80d35496-b370-4699-ac7b-a55e96466d23', updated_at='2019-03-14T10:41:10Z' |
 |                 | created_at='2019-03-14T10:41:10Z', direction='egress', ethertype='IPv4', id='ddc1edd5-8ce2-411a-933c-acb1765d43b1', updated_at='2019-03-14T10:41:10Z' |
 | updated_at      | 2019-03-14T10:41:10Z                                                                                                                                  |
 +-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+

第四步:创建一个用于连接到实例的SSH Keypair

[Hyman@theitroad ~(keystone)]$ssh-keygen -q -N ""                                                              
 Enter file in which to save the key (/home/tech/.ssh/id_rsa):

第五步:添加公钥

[Hyman@theitroad ~(keystone)]$openstack keypair create --public-key ~/.ssh/id_rsa.pub penchantkey
 +-------------+-------------------------------------------------+
 | Field       | Value                                           |
 +-------------+-------------------------------------------------+
 | fingerprint | b6:25:cb:6c:a6:ff:29:5b:4f:59:76:aa:d2:6e:0c:25 |
 | name        | penchantkey                                     |
 | user_id     | 1e03edc140cf47858778ab44319391f6                |
 +-------------+-------------------------------------------------+
[Hyman@theitroad ~(keystone)]$netID=$(openstack network list | grep firstnet1 | awk '{ print  }')
[Hyman@theitroad ~(keystone)]$openstack server create --flavor Basic --image CentOS7 --security-group securegroupone --nic net-id=$netID --key-name penchantkey Cent7
 +-----------------------------+------------------------------------------------+
 | Field                       | Value                                          |
 +-----------------------------+------------------------------------------------+
 | OS-DCF:diskConfig           | MANUAL                                         |
 | OS-EXT-AZ:availability_zone |                                                |
 | OS-EXT-STS:power_state      | NOSTATE                                        |
 | OS-EXT-STS:task_state       | scheduling                                     |
 | OS-EXT-STS:vm_state         | building                                       |
 | OS-SRV-USG:launched_at      | None                                           |
 | OS-SRV-USG:terminated_at    | None                                           |
 | accessIPv4                  |                                                |
 | accessIPv6                  |                                                |
 | addresses                   |                                                |
 | adminPass                   | SLpUbJgmuwd4                                   |
 | config_drive                |                                                |
 | created                     | 2019-03-14T10:53:50Z                           |
 | flavor                      | Basic (0)                                      |
 | hostId                      |                                                |
 | id                          | 37822ec3-7b4b-4354-bafe-76d1e34c90c2           |
 | image                       | CentOS7 (c13fd621-0d74-4e8f-9481-5cbb02decbd3) |
 | key_name                    | penchantkey                                    |
 | name                        | Cent7                                          |
 | progress                    | 0                                              |
 | project_id                  | f5547f8c879c41bea9c60e4541745c35               |
 | properties                  |                                                |
 | security_groups             | name='05e8cdf2-d59b-40fa-ad55-59d9a3c8af04'    |
 | status                      | BUILD                                          |
 | updated                     | 2019-03-14T10:53:51Z                           |
 | user_id                     | 1e03edc140cf47858778ab44319391f6               |
 | volumes_attached            |                                                |
 +-----------------------------+------------------------------------------------+
[Hyman@theitroad ~(keystone)]$openstack server list
 +--------------------------------------+-------+--------+----------+---------+--------+
 | ID                                   | Name  | Status | Networks | Image   | Flavor |
 +--------------------------------------+-------+--------+----------+---------+--------+
 | 37822ec3-7b4b-4354-bafe-76d1e34c90c2 | Cent7 | BUILD  |          | CentOS7 | Basic  |
 +--------------------------------------+-------+--------+----------+---------+--------+

第六步:为我们创建的安全组配置安全设置,这将为我们提供SSH和ICMP

[Hyman@theitroad ~(keystone)]$openstack security group rule create --protocol icmp --ingress securegroupone
 +-------------------+--------------------------------------+
 | Field             | Value                                |
 +-------------------+--------------------------------------+
 | created_at        | 2019-03-14T15:17:04Z                 |
 | description       |                                      |
 | direction         | ingress                              |
 | ether_type        | IPv4                                 |
 | id                | 43a93b70-0907-407f-a559-2be73a395cdd |
 | name              | None                                 |
 | port_range_max    | None                                 |
 | port_range_min    | None                                 |
 | project_id        | f5547f8c879c41bea9c60e4541745c35     |
 | protocol          | icmp                                 |
 | remote_group_id   | None                                 |
 | remote_ip_prefix  | 0.0.0.0/0                            |
 | revision_number   | 0                                    |
 | security_group_id | 05e8cdf2-d59b-40fa-ad55-59d9a3c8af04 |
 | updated_at        | 2019-03-14T15:17:04Z                 |
 +-------------------+--------------------------------------+

第七步:允许SSH

[Hyman@theitroad ~(keystone)]$openstack security group rule create --protocol tcp --dst-port 22:22 securegroupone
 +-------------------+--------------------------------------+
 | Field             | Value                                |
 +-------------------+--------------------------------------+
 | created_at        | 2019-03-14T15:17:36Z                 |
 | description       |                                      |
 | direction         | ingress                              |
 | ether_type        | IPv4                                 |
 | id                | 39f53276-e0c4-4955-8caa-0a62f52a06cd |
 | name              | None                                 |
 | port_range_max    | 22                                   |
 | port_range_min    | 22                                   |
 | project_id        | f5547f8c879c41bea9c60e4541745c35     |
 | protocol          | tcp                                  |
 | remote_group_id   | None                                 |
 | remote_ip_prefix  | 0.0.0.0/0                            |
 | revision_number   | 0                                    |
 | security_group_id | 05e8cdf2-d59b-40fa-ad55-59d9a3c8af04 |
 | updated_at        | 2019-03-14T15:17:36Z                 |
 +-------------------+--------------------------------------+

列出已创建的组规则

[Hyman@theitroad ~(keystone)]$openstack security group rule list
 +--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
 | ID                                   | IP Protocol | IP Range  | Port Range | Remote Security Group                | Security Group                       |
 +--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
 | 39f53276-e0c4-4955-8caa-0a62f52a06cd | tcp         | 0.0.0.0/0 | 22:22      | None                                 | 05e8cdf2-d59b-40fa-ad55-59d9a3c8af04 |
 | 3f2d46e5-3ca5-4b0f-b263-e09d27184707 | None        | None      |            | None                                 | 4ca419b0-6e49-49ad-a365-b3fda3f409e1 |
 | 43a93b70-0907-407f-a559-2be73a395cdd | icmp        | 0.0.0.0/0 |            | None                                 | 05e8cdf2-d59b-40fa-ad55-59d9a3c8af04 |
 | 6c80f5c1-be37-431d-ac6f-323d959e8ce2 | None        | None      |            | 4ca419b0-6e49-49ad-a365-b3fda3f409e1 | 4ca419b0-6e49-49ad-a365-b3fda3f409e1 |
 | 80d35496-b370-4699-ac7b-a55e96466d23 | None        | None      |            | None                                 | 05e8cdf2-d59b-40fa-ad55-59d9a3c8af04 |
 | 9f71dd53-cf8a-4871-b404-a4ab9c429958 | None        | None      |            | 4ca419b0-6e49-49ad-a365-b3fda3f409e1 | 4ca419b0-6e49-49ad-a365-b3fda3f409e1 |
 | ddc1edd5-8ce2-411a-933c-acb1765d43b1 | None        | None      |            | None                                 | 05e8cdf2-d59b-40fa-ad55-59d9a3c8af04 |
 | e998a70b-4cf4-48cd-ab3d-23e5c195b633 | None        | None      |            | None                                 | 4ca419b0-6e49-49ad-a365-b3fda3f409e1 |
 +--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+

安装地平线

通过以下安装到root用户并跟进以进行地平线。

[Hyman@theitroad ~(keystone)]$sudo su 
[Hyman@theitroad ~(keystone)]#
[Hyman@theitroad ~(keystone)]#  yum --enablerepo=centos-openstack-queens,epel -y install openstack-dashboard
 Loaded plugins: fastestmirror
 Loading mirror speeds from cached hostfile
 base: mirror.ucu.ac.ug
 centos-qemu-ev: mirror.ucu.ac.ug
 extras: mirror.ucu.ac.ug
 updates: mirror.ucu.ac.ug
 base                                                                                      | 3.6 kB  00:00:00     
 centos-ceph-luminous                                                                      | 2.9 kB  00:00:00     
 centos-openstack-queens                                                                   | 2.9 kB  00:00:00     
 centos-qemu-ev                                                                            | 2.9 kB  00:00:00     
 extras                                                                                    | 3.4 kB  00:00:00     
 updates                                                                                   | 3.4 kB  00:00:00     
 Resolving Dependencies
 --> Running transaction check
 ---> Package openstack-dashboard.noarch 1:13.0.1-1.el7 will be installed

继续配置Horizo n

[Hyman@theitroad ~(keystone)]# vim /etc/openstack-dashboard/local_settings
# Jump to line 38 and add Dashboard Host depending on the domain name you require here
 ALLOWED_HOSTS = ['horizon.example.com', 'localhost'] #input your FQDN at horizon.example.com
# on line 64: uncomment the lines to look like below
 OPENSTACK_API_VERSIONS = {
 "data-processing": 1.1,
 "identity": 3, "volume": 2, "compute": 2,
 }
# on line 75: uncomment, edit as shown
 OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT = True
# uncomment line 97 as shown below
 OPENSTACK_KEYSTONE_DEFAULT_DOMAIN = 'Default'
# on about line 167 and 168: change the IP and add Memcache server to your own
 CACHES = {
     'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
         'LOCATION': '192.168.122.130:11211',
     },
 }
# on the line 189: change OPENSTACK_HOST to the ip of your host
 OPENSTACK_HOST = "192.168.122.130"
 OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
 OPENSTACK_KEYSTONE_DEFAULT_ROLE = "member"

编辑如下所示仪表板的httpd文件:

[Hyman@theitroad ~(keystone)]# vim /etc/httpd/conf.d/openstack-dashboard.conf
# on about line 4: add the following lines
 WSGIDaemonProcess dashboard
 WSGIProcessGroup dashboard
 WSGISocketPrefix run/wsgi
 WSGIApplicationGroup %{GLOBAL}

通过在http://(输入服务器的主机名或者IP地址以下)/仪表板/下面)通过Web浏览器访问仪表板