openstack实验(四):计算服务

被刻印的时光 ゝ 提交于 2019-11-27 16:06:13
  • 安装并配置控制节点
    1.数据库的配置
    (1)以 root 用户连接到数据库服务器

[root@controller ~]# mysql -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 37
Server version: 10.1.20-MariaDB MariaDB Server
Copyright © 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

(2)创建 nova_api 和 nova 数据库:

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

(3)对两个数据库进行正确的授权:

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

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

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

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

MariaDB [(none)]> exit
Bye

2.创建 nova 用户

[root@controller ~]# openstack user create --domain default --password nova nova
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 63a9992134eb452da1c8d950231c2b06 |
| enabled   | True                             |
| id        | 067877547f764797a4ea7c410afaadc8 |
| name      | nova                             |
+-----------+----------------------------------+

3.给 nova 用户添加 admin 角色:

[root@controller ~]# openstack role add --project service --user nova admin

4.创建 nova 服务实体

[root@controller ~]# openstack service create --name nova \
>   --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled     | True                             |
| id          | 49b5aaa3ebbc4d43bfe5106c969a0354 |
| name        | nova                             |
| type        | compute                          |
+-------------+----------------------------------+

5.创建 Compute 服务 API 端点 :

[root@controller ~]# openstack endpoint create --region RegionOne \
>   compute public http://controller:8774/v2.1/%\(tenant_id\)s
+--------------+-------------------------------------------+
| Field        | Value                                     |
+--------------+-------------------------------------------+
| enabled      | True                                      |
| id           | a00e9c25cd69433da99937e92ec5a9f9          |
| interface    | public                                    |
| region       | RegionOne                                 |
| region_id    | RegionOne                                 |
| service_id   | 49b5aaa3ebbc4d43bfe5106c969a0354          |
| service_name | nova                                      |
| service_type | compute                                   |
| url          | http://controller:8774/v2.1/%(tenant_id)s |
+--------------+-------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
>   compute internal http://controller:8774/v2.1/%\(tenant_id\)s
+--------------+-------------------------------------------+
| Field        | Value                                     |
+--------------+-------------------------------------------+
| enabled      | True                                      |
| id           | bf40813b02ca44849f5bb81422ccd521          |
| interface    | internal                                  |
| region       | RegionOne                                 |
| region_id    | RegionOne                                 |
| service_id   | 49b5aaa3ebbc4d43bfe5106c969a0354          |
| service_name | nova                                      |
| service_type | compute                                   |
| url          | http://controller:8774/v2.1/%(tenant_id)s |
+--------------+-------------------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne \
>   compute admin http://controller:8774/v2.1/%\(tenant_id\)s
+--------------+-------------------------------------------+
| Field        | Value                                     |
+--------------+-------------------------------------------+
| enabled      | True                                      |
| id           | 0c4d290dabbb44469af0aba0c27aab9b          |
| interface    | admin                                     |
| region       | RegionOne                                 |
| region_id    | RegionOne                                 |
| service_id   | 49b5aaa3ebbc4d43bfe5106c969a0354          |
| service_name | nova                                      |
| service_type | compute                                   |
| url          | http://controller:8774/v2.1/%(tenant_id)s |
+--------------+-------------------------------------------+

6.安装软件包:

[root@controller ~]# yum install openstack-nova-api openstack-nova-conductor \
>   openstack-nova-console openstack-nova-novncproxy \
>   openstack-nova-scheduler

7.编辑/etc/nova/nova.conf文件

[root@controller ~]# vim /etc/nova/nova.conf

[DEFAULT]
enabled_apis = osapi_compute,metadata   ##只启用计算和元数据API
rpc_backend = rabbit      ##配置 “RabbitMQ” 消息队列访问
auth_strategy = keystone   ##配置认证服务访问
my_ip = 172.25.43.1        ## 来使用控制节点的管理接口的IP 地址
use_neutron = True        ##使能 Networking 服务
firewall_driver = nova.virt.firewall.NoopFirewallDriver

[api_database]      ##配置数据库的连接
connection = mysql+pymysql://nova:nova@controller/nova_api

[database]     ##配置数据库的连接
connection = mysql+pymysql://nova:nova@controller/nova

[oslo_messaging_rabbit]    ##配置 “RabbitMQ” 消息队列访问
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack

[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 = nova
password = nova

[vnc]          ##配置VNC代理使用控制节点的管理接口IP地址
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip

[glance]       ##配置镜像服务 API 的位置
api_servers = http://controller:9292

[oslo_concurrency]      ##配置锁路径
lock_path = /var/run/nova/tmp

8.同步Compute 数据库

[root@controller ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
[root@controller ~]# su -s /bin/sh -c "nova-manage db sync" nova
/usr/lib/python2.7/site-packages/pymysql/cursors.py:166: Warning: (1831, u'Duplicate index `block_device_mapping_instance_uuid_virtual_name_device_name_idx`. This is deprecated and will be disallowed in a future release.')
  result = self._query(query)
/usr/lib/python2.7/site-packages/pymysql/cursors.py:166: Warning: (1831, u'Duplicate index `uniq_instances0uuid`. This is deprecated and will be disallowed in a future release.')
  result = self._query(query)

9.启动 Compute 服务并将其设置为随系统启动

[root@controller ~]# systemctl enable openstack-nova-api.service   openstack-nova-consoleauth.service openstack-nova-scheduler.service   openstack-nova-conductor.service openstack-nova-novncproxy.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-api.service to /usr/lib/systemd/system/openstack-nova-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-consoleauth.service to /usr/lib/systemd/system/openstack-nova-consoleauth.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-scheduler.service to /usr/lib/systemd/system/openstack-nova-scheduler.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-conductor.service to /usr/lib/systemd/system/openstack-nova-conductor.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-novncproxy.service to /usr/lib/systemd/system/openstack-nova-novncproxy.service.
[root@controller ~]# systemctl start openstack-nova-api.service \
>   openstack-nova-consoleauth.service openstack-nova-scheduler.service \
>   openstack-nova-conductor.service openstack-nova-novncproxy.service

10.列出计算服务的信息

[root@controller ~]# openstack compute service list
+----+------------------+------------+----------+---------+-------+----------------------------+
| Id | Binary           | Host       | Zone     | Status  | State | Updated At                 |
+----+------------------+------------+----------+---------+-------+----------------------------+
|  1 | nova-conductor   | controller | internal | enabled | up    | 2019-06-23T07:26:39.000000 |
|  2 | nova-scheduler   | controller | internal | enabled | up    | 2019-06-23T07:26:40.000000 |
|  5 | nova-consoleauth | controller | internal | enabled | up    | 2019-06-23T07:26:40.000000 |
+----+------------------+------------+----------+---------+-------+----------------------------+
  • 安装和配置计算节点

1.先做时间同步

[root@compute1 ~]# yum install chrony -y
[root@compute1 ~]# vim /etc/chrony.conf 
server 172.25.43.250 iburst
[root@compute1 ~]# systemctl start chronyd
[root@compute1 ~]# date

2.配置新的yum源

[root@controller yum.repos.d]# scp openstack.repo compute1:/etc/yum.repos.d/
[root@compute1 ~]# yum repolist
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
openstack                                                                 | 2.9 kB  00:00:00     
openstack/primary_db                                                      | 141 kB  00:00:00     
repo id                                       repo name                                    status
openstack                                     mitaka                                         279
rhel7.3                                       rhel7.3                                      4,751
repolist: 5,030

3.配置双网卡,eth1不需要ip只需要开启即可

[root@compute1 ~]# cd /etc/sysconfig/network-scripts/
[root@compute1 network-scripts]# ls
ifcfg-eth0   ifdown-isdn      ifup          ifup-plip      ifup-tunnel
ifcfg-lo     ifdown-post      ifup-aliases  ifup-plusb     ifup-wireless
ifdown       ifdown-ppp       ifup-bnep     ifup-post      init.ipv6-global
ifdown-bnep  ifdown-routes    ifup-eth      ifup-ppp       network-functions
ifdown-eth   ifdown-sit       ifup-ib       ifup-routes    network-functions-ipv6
ifdown-ib    ifdown-Team      ifup-ippp     ifup-sit
ifdown-ippp  ifdown-TeamPort  ifup-ipv6     ifup-Team
ifdown-ipv6  ifdown-tunnel    ifup-isdn     ifup-TeamPort
[root@compute1 network-scripts]# cp ifcfg-eth0 ifcfg-eth1
[root@compute1 network-scripts]# vim ifcfg-eth1
[root@compute1 network-scripts]# cat ifcfg-eth1
BOOTPROTO=none
DEVICE=eth0
ONBOOT=yes
[root@compute1 network-scripts]# ifup eth1
[root@compute1 network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:f9:e7:8f brd ff:ff:ff:ff:ff:ff
    inet 172.25.43.2/24 brd 172.25.43.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fef9:e78f/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:54:00:5c:8a:6f brd ff:ff:ff:ff:ff:ff

4.更新一下

[root@compute1 ~]# yum upgrade -y

5.安装软件包

[root@compute1 ~]# yum install openstack-nova-compute -y

6.编辑/etc/nova/nova.conf文件

[root@compute1 ~]# vim /etc/nova/nova.conf
[DEFAULT]
rpc_backend = rabbit ##配置RabbitMQ消息队列的连接:
auth_strategy = keystone ## 配置认证服务访问
my_ip = 172.25.43.2 ##配置 my_ip 选项
use_neutron = True ##使能 Networking 服务
firewall_driver = nova.virt.firewall.NoopFirewallDriver
##配置RabbitMQ消息队列的连接:
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = openstack
##配置认证服务访问
[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 = nova
password = nova
##启用并配置远程控制台访问
[vnc]
enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = $my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html
##配置镜像服务 API 的位置:
[glance]
api_servers = http://controller:9292
##配置锁路径
[oslo_concurrency]
lock_path = /var/lib/nova/tmp

7.启动计算服务及其依赖,并将其配置为随系统自动启动:

[root@compute1 ~]# systemctl enable libvirtd.service openstack-nova-compute.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-compute.service to /usr/lib/systemd/system/openstack-nova-compute.service.
[root@compute1 ~]# systemctl start libvirtd.service openstack-nova-compute.service
  • 验证

1.列出服务组件,以验证是否成功启动并注册了每个进程:

[root@controller yum.repos.d]# openstack compute service list
+----+------------------+------------+----------+---------+-------+----------------------------+
| Id | Binary           | Host       | Zone     | Status  | State | Updated At                 |
+----+------------------+------------+----------+---------+-------+----------------------------+
|  1 | nova-conductor   | controller | internal | enabled | up    | 2019-06-23T07:46:09.000000 |
|  2 | nova-scheduler   | controller | internal | enabled | up    | 2019-06-23T07:46:08.000000 |
|  5 | nova-consoleauth | controller | internal | enabled | up    | 2019-06-23T07:46:04.000000 |
|  6 | nova-compute     | compute1   | nova     | enabled | up    | 2019-06-23T07:46:00.000000 |
+----+------------------+------------+----------+---------+-------+----------------------------+

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!