Openstack Nova 控制服务 和 计算服务 (六)

Openstack Nova 控制服务 和 计算服务 (六)

引用: https://docs.openstack.org/ocata/zh_CN/install-guide-rdo/nova.html

先决条件

1 ) 在安装和配置 Compute 服务前,你必须创建数据库服务的凭据以及 API endpoints。
    mysql -u root -p
    
2 ) Create the nova_api, nova, and nova_cell0 databases:
   MariaDB [(none)]> CREATE DATABASE nova_api;
   MariaDB [(none)]> CREATE DATABASE nova;
   MariaDB [(none)]> CREATE DATABASE nova_cell0;

3 )对数据库进行正确的授权:
   GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY '123456';
   GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '123456';
   GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY '123456';

4)获得 admin 凭证来获取只有管理员能执行的命令的访问权限:
   source admin.sh
   
5) 创建nova用户:
   openstack user create --domain default --password-prompt nova   # 我设置了123456
[root@cont-1 ~]# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | 317ace63cb8f4562af682ca6c7bdf955 |
| enabled             | True                             |
| id                  | ebe9faf1e4964d7ab022780190c713be |
| name                | nova                             |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

6 ) 给 nova 用户添加 admin 角色:
openstack role add --project service --user nova admin
*** 此命令没有任何输出

7 )  创建计算节点的 Compute API service endpoints:

[root@cont-1 ~]# openstack endpoint create --region RegionOne compute public http://openstack-linux36-vip.magedu.net:8774/v2.1
 RegionOne compute admin http://openstack-linux36-vip.magedu.net:8774/v2.1
+--------------+---------------------------------------------------+
| Field        | Value                                             |
+--------------+---------------------------------------------------+
| enabled      | True                                              |
| id           | 64d7113f699c414bb4ba419f24caf3c6                  |
| interface    | public                                            |
| region       | RegionOne                                         |
| region_id    | RegionOne                                         |
| service_id   | 7563ddce71f2419f9042b1cb4b737c00                  |
| service_name | nova                                              |
| service_type | compute                                           |
| url          | http://openstack-linux36-vip.magedu.net:8774/v2.1 |
+--------------+---------------------------------------------------+
[root@cont-1 ~]# openstack endpoint create --region RegionOne compute internal http://openstack-linux36-vip.magedu.net:8774/v2.1
+--------------+---------------------------------------------------+
| Field        | Value                                             |
+--------------+---------------------------------------------------+
| enabled      | True                                              |
| id           | 09b6f2906f864125ae2c0c2721beeb4e                  |
| interface    | internal                                          |
| region       | RegionOne                                         |
| region_id    | RegionOne                                         |
| service_id   | 7563ddce71f2419f9042b1cb4b737c00                  |
| service_name | nova                                              |
| service_type | compute                                           |
| url          | http://openstack-linux36-vip.magedu.net:8774/v2.1 |
+--------------+---------------------------------------------------+
[root@cont-1 ~]# openstack endpoint create --region RegionOne compute admin http://openstack-linux36-vip.magedu.net:8774/v2.1
+--------------+---------------------------------------------------+
| Field        | Value                                             |
+--------------+---------------------------------------------------+
| enabled      | True                                              |
| id           | f650c9a98b6a437994b6ba698b30213c                  |
| interface    | admin                                             |
| region       | RegionOne                                         |
| region_id    | RegionOne                                         |
| service_id   | 7563ddce71f2419f9042b1cb4b737c00                  |
| service_name | nova                                              |
| service_type | compute                                           |
| url          | http://openstack-linux36-vip.magedu.net:8774/v2.1 |
+--------------+---------------------------------------------------+


#########################################################################################################

## 
openstack user create --domain default --password-prompt placement
[root@cont-1 ~]# openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | 317ace63cb8f4562af682ca6c7bdf955 |
| enabled             | True                             |
| id                  | e6e27d0f656d42c6afa07653c1e5707e |
| name                | placement                        |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

## 
openstack role add --project service --user placement admin

## 
openstack service create --name placement --description "Placement API" placement
[root@cont-1 ~]# openstack service create --name placement --description "Placement API" placement
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Placement API                    |
| enabled     | True                             |
| id          | aba655abd8ef4ed699b675f7a9744718 |
| name        | placement                        |
| type        | placement                        |
+-------------+----------------------------------+

## 
openstack endpoint create --region RegionOne placement public http://openstack-linux36-vip.magedu.net:8778
openstack endpoint create --region RegionOne placement internal http://openstack-linux36-vip.magedu.net:8778
openstack endpoint create --region RegionOne placement admin http://openstack-linux36-vip.magedu.net:8778

[root@cont-1 ~]# openstack endpoint create --region RegionOne placement public http://openstack-linux36-vip.magedu.net:8778
+--------------+----------------------------------------------+
| Field        | Value                                        |
+--------------+----------------------------------------------+
| enabled      | True                                         |
| id           | 14a2b9a8f27a40668e7efab09e422f94             |
| interface    | public                                       |
| region       | RegionOne                                    |
| region_id    | RegionOne                                    |
| service_id   | aba655abd8ef4ed699b675f7a9744718             |
| service_name | placement                                    |
| service_type | placement                                    |
| url          | http://openstack-linux36-vip.magedu.net:8778 |
+--------------+----------------------------------------------+
[root@cont-1 ~]# openstack endpoint create --region RegionOne placement internal http://openstack-linux36-vip.magedu.net:8778
+--------------+----------------------------------------------+
| Field        | Value                                        |
+--------------+----------------------------------------------+
| enabled      | True                                         |
| id           | 77700950759c4dd8a11c5471ce03b34d             |
| interface    | internal                                     |
| region       | RegionOne                                    |
| region_id    | RegionOne                                    |
| service_id   | aba655abd8ef4ed699b675f7a9744718             |
| service_name | placement                                    |
| service_type | placement                                    |
| url          | http://openstack-linux36-vip.magedu.net:8778 |
+--------------+----------------------------------------------+
[root@cont-1 ~]# openstack endpoint create --region RegionOne placement admin http://openstack-linux36-vip.magedu.net:8778
+--------------+----------------------------------------------+
| Field        | Value                                        |
+--------------+----------------------------------------------+
| enabled      | True                                         |
| id           | f231546406754b5797f24e44b588629b             |
| interface    | admin                                        |
| region       | RegionOne                                    |
| region_id    | RegionOne                                    |
| service_id   | aba655abd8ef4ed699b675f7a9744718             |
| service_name | placement                                    |
| service_type | placement                                    |
| url          | http://openstack-linux36-vip.magedu.net:8778 |
+--------------+----------------------------------------------+


## 安装软件包:
yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy 
  openstack-nova-scheduler openstack-nova-placement-api

## 编辑``/etc/nova/nova.conf``文件并完成下面的操作:
   在``[DEFAULT]``部分,只启用计算和元数据API:

      [DEFAULT]
       # ...
       2630   enabled_apis = osapi_compute,metadata

    在``[api_database]``和``[database]``部分,配置数据库的连接:

     [api_database]
      # ...
      3381  connection = mysql+pymysql://nova:123456@openstack-linux36-vip.magedu.net/nova_api

     [database]
       # ...
     4400  connection = mysql+pymysql://nova:123456@openstack-linux36-vip.magedu.net/nova

    在``[DEFAULT]``部分,配置``RabbitMQ``消息队列访问权限:
    [DEFAULT]
      # ...
    3023  transport_url = rabbit://openstack:RABBIT_PASS@controller
    transport_url = rabbit://openstack:123456@openstack-linux36-vip.magedu.net

    In the [api] and [keystone_authtoken] sections, configure Identity service access:
      [api]
       # ... 
       auth_strategy = keystone

      [keystone_authtoken]
       # ...
    auth_uri = http://openstack-linux36-vip.magedu.net:5000
    auth_url = http://openstack-linux36-vip.magedu.net:35357
    memcached_servers = openstack-linux36-vip.magedu.net:11211
    auth_type = password
    project_domain_name = default
    user_domain_name = default
    project_name = service
    username = nova
    password = 123456

     
    在 ``[DEFAULT]``部分,启用网络服务支持(用来开启网络组策略):
      [DEFAULT]
        # ...
        use_neutron = True
        firewall_driver = nova.virt.firewall.NoopFirewallDriver
    *** 注解:
    默认情况下,计算服务使用内置的防火墙服务。由于网络服务包含了防火墙服务,你必须使用``nova.virt.firewall.NoopFirewallDriver``防火墙服务来禁用掉计算服务内置的防火墙服务
    
    [DEFAULT]
    # ......
    transport_url = rabbit://openstack:openstack123@openstack-linux36-vip.magedu.net
    
    [vnc]
     enabled = true
     vncserver_listen = 0.0.0.0    # 可以写0.0.0.0  也可以写本机IP地址
     vncserver_proxyclient_address = 0.0.0.0
    
    [glance]
    api_servers = http://openstack-linux36-vip.magedu.net:9292

    [oslo_concurrency]
    # ...
    lock_path = /var/lib/nova/tmp

    [placement]
    os_region_name = RegionOne
    project_domain_name = Default
    project_name = service
    auth_type = password
    user_domain_name = Default
    auth_url = http://openstack-linux36-vip.magedu.net:35357/v3
    username = placement
    password = 123456
    
   ########################## 保存一下配置, 修复一下httpd的一个bug##################### 
   # Due to a packaging bug, you must enable access to the Placement API by adding the following configuration to   
    vim /etc/httpd/conf.d/00-nova-placement-api.conf
    <Directory /usr/bin>
       <IfVersion >= 2.4>
          Require all granted
       </IfVersion>
       <IfVersion < 2.4>
          Order allow,deny
          Allow from all
       </IfVersion>
    </Directory>
    
   # Restart the httpd service:
     systemctl restart httpd   


   # 初始化 nova-api database:
   su -s /bin/sh -c "nova-manage api_db sync" nova
   
   # Register the cell0 database:
   su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
   
   # 
   su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
   [root@cont-1 ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
    5944c763-cc8f-42f8-98d4-e0d57da4ff72

   # 
   su -s /bin/sh -c "nova-manage db sync" nova

   # Verify nova cell0 and cell1 are registered correctly:
   [root@cont-1 ~]# nova-manage cell_v2 list_cells
    +-------+--------------------------------------+
    |  Name |                 UUID                 |
    +-------+--------------------------------------+
    | cell0 | 00000000-0000-0000-0000-000000000000 |
    | cell1 | 5944c763-cc8f-42f8-98d4-e0d57da4ff72 |
    +-------+--------------------------------------+

    # 启动 Compute 服务并将其设置为随系统启动:
    systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service 
        openstack-nova-conductor.service openstack-nova-novncproxy.service
    systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service 
        openstack-nova-conductor.service openstack-nova-novncproxy.service
  
    #  做个haproxy 转发控制端的 6080
    listen  openstack_nova_port_6080
     bind 0.0.0.0:6080
     mode tcp
     log global
     server 10.10.5.138 10.10.5.138:6080 check inter 3000 fall 2 rise 5
   
    # 查看日志有无error错误:
     tail -f /var/log/nova/nova-*.log  
   
    # 查看rabbitmq 是否有数据连接进来:
    http://10.10.5.150:15672/#/connections    |  guest | guest 
   
   
    *** 增加其他机器:
     1 安装软件
     2 拷配置到目标主机
     3 更改配置(绑定的IP 等等)
     4 启动服务
     注意:  不需要重新添加账号,初始化数据库,直接启动即可.
   
   
   
   ####################################  nova 控制端安装完成 ####################################

nova 计算节点安装:

# 安装软件包:
 yum install openstack-nova-compute

# 编辑``/etc/nova/nova.conf``文件并完成下面的操作:
  [DEFAULT]
    # ...
    enabled_apis = osapi_compute,metadata

# 在``[DEFAULT]``部分,配置``RabbitMQ``消息队列访问权限:
transport_url = rabbit://openstack:openstack123@openstack-linux36-vip.magedu.net

# In the [api] and [keystone_authtoken] sections, configure Identity service access:
[api]
# ...
auth_strategy = keystone

[keystone_authtoken]
auth_uri = http://openstack-linux36-vip.magedu.net:5000
auth_url = http://openstack-linux36-vip.magedu.net:35357
memcached_servers = openstack-linux36-vip.magedu.net:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = 123456

# 启用网络服务支持:
[DEFAULT]
# ...
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver
** 缺省情况下,Compute 使用内置的防火墙服务。由于 Networking 包含了防火墙服务,所以你必须通过使用 nova.virt.firewall.NoopFirewallDriver 来去除 Compute 内置的防火墙服务。


# 在``[vnc]``部分,启用并配置远程控制台访问:
[vnc]
enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = 10.10.5.135   # 本地ip地址
novncproxy_base_url = http://openstack-linux36-vip.magedu.net:6080/vnc_auto.html  #控制端的地址
*** 如果你运行浏览器的主机无法解析``controller`` 主机名,你可以将 ``controller``替换为你控制节点管理网络的IP地址。

# 在 [glance] 区域,配置镜像服务 API 的位置:
[glance]
# ...
api_servers = http://openstack-linux36-vip.magedu.net:9292

# 在 [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency]
# ...
lock_path = /var/lib/nova/tmp

# In the [placement] section, configure the Placement API:
[placement]
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://openstack-linux36-vip.magedu.net:35357/v3
username = placement
password = 123456

# 确定您的计算节点是否支持虚拟机的硬件加速。
egrep -c '(vmx|svm)' /proc/cpuinfo
如果这个命令返回了 one or greater 的值,那么你的计算节点支持硬件加速且不需要额外的配置。
如果这个命令返回了 zero 值,那么你的计算节点不支持硬件加速。你必须配置 libvirt 来使用 QEMU 去代替 KVM

# 在 /etc/nova/nova.conf 文件的 [libvirt] 区域做出如下的编辑:
[libvirt]
# ...
virt_type = qemu

# 多久发现新的节点:
[scheduler]
discover_hosts_in_cells_interval = 300


# 启动计算服务及其依赖,并将其配置为随系统自动启动:
  systemctl enable libvirtd.service openstack-nova-compute.service
  systemctl start libvirtd.service openstack-nova-compute.service


# 验证操作 控制节点操作如下 获得 admin 凭证来获取只有管理员能执行的命令的访问权限:

  source admin.sh

# 列出服务组件,以验证是否成功启动并注册了每个进程:
[root@cont-1 ~]# openstack compute service list
+----+------------------+--------+----------+---------+-------+----------------------------+
| ID | Binary           | Host   | Zone     | Status  | State | Updated At                 |
+----+------------------+--------+----------+---------+-------+----------------------------+
|  1 | nova-scheduler   | cont-1 | internal | enabled | up    | 2020-05-26T07:42:49.000000 |
|  2 | nova-conductor   | cont-1 | internal | enabled | up    | 2020-05-26T07:42:47.000000 |
|  4 | nova-consoleauth | cont-1 | internal | enabled | up    | 2020-05-26T07:42:50.000000 |
|  7 | nova-compute     | node-1 | nova     | enabled | up    | 2020-05-26T07:42:51.000000 |
|  8 | nova-compute     | node-2 | nova     | enabled | up    | 2020-05-26T07:42:51.000000 |
+----+------------------+--------+----------+---------+-------+----------------------------+
*** 该输出应该显示三个服务组件在控制节点上启用,两个服务组件在计算节点上启用。

# 列出身份认证服务中的 API 端点来验证身份认证服务的连通性:
[root@cont-1 ~]# openstack catalog list
+-----------+-----------+---------------------------------------------------------------+
| Name      | Type      | Endpoints                                                     |
+-----------+-----------+---------------------------------------------------------------+
| keystone  | identity  | RegionOne                                                     |
|           |           |   public: http://openstack-linux36-vip.magedu.net:5000/v3     |
|           |           | RegionOne                                                     |
|           |           |   admin: http://openstack-linux36-vip.magedu.net:35357/v3     |
|           |           | RegionOne                                                     |
|           |           |   internal: http://openstack-linux36-vip.magedu.net:5000/v3   |
|           |           |                                                               |
| nova      | compute   | RegionOne                                                     |
|           |           |   internal: http://openstack-linux36-vip.magedu.net:8774/v2.1 |
|           |           | RegionOne                                                     |
|           |           |   public: http://openstack-linux36-vip.magedu.net:8774/v2.1   |
|           |           | RegionOne                                                     |
|           |           |   admin: http://openstack-linux36-vip.magedu.net:8774/v2.1    |
|           |           |                                                               |
| placement | placement | RegionOne                                                     |
|           |           |   public: http://openstack-linux36-vip.magedu.net:8778        |
|           |           | RegionOne                                                     |
|           |           |   internal: http://openstack-linux36-vip.magedu.net:8778      |
|           |           | RegionOne                                                     |
|           |           |   admin: http://openstack-linux36-vip.magedu.net:8778         |
|           |           |                                                               |
| glance    | image     | RegionOne                                                     |
|           |           |   internal: http://openstack-linux36-vip.magedu.net:9292      |
|           |           | RegionOne                                                     |
|           |           |   admin: http://openstack-linux36-vip.magedu.net:9292         |
|           |           | RegionOne                                                     |
|           |           |   public: http://openstack-linux36-vip.magedu.net:9292        |
|           |           |                                                               |
+-----------+-----------+---------------------------------------------------------------+

# List images in the Image service to verify connectivity with the Image service:
[root@cont-1 ~]# openstack image list
+--------------------------------------+--------------+--------+
| ID                                   | Name         | Status |
+--------------------------------------+--------------+--------+
| 1511da48-c7d3-4237-85fb-015a69d2134b | cirros-0.3.5 | active |
+--------------------------------------+--------------+--------+

# Check the cells and placement API are working successfully:

[root@cont-1 ~]# nova-status upgrade check
+---------------------------+
| Upgrade Check Results     |
+---------------------------+
| Check: Cells v2           |
| Result: Success           |
| Details: None             |
+---------------------------+
| Check: Placement API      |
| Result: Success           |
| Details: None             |
+---------------------------+
| Check: Resource Providers |
| Result: Success           |
| Details: None             |
+---------------------------+







原文地址:https://www.cnblogs.com/zhenxing06/p/13025326.html