Openstack配置手册-04Nova配置

snow chuai汇总、整理、撰写---2020/2/5

最后更新时间---2023/07/24


1. 添加Nova账户并注册至Keystone
[root@node1 ~(keystone)]# openstack user create --domain default --project service --password servicepassword nova
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | 1be75e85ec9445ab9ff7dd7ec2f02b71 |
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 052dd6166c2c41f3ae49293740fd88c8 |
| name                | nova                             |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
[root@node1 ~(keystone)]# openstack role add --project service --user nova admin
[root@node1 ~(keystone)]# openstack user create --domain default --project service --password servicepassword placement +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | default_project_id | 1be75e85ec9445ab9ff7dd7ec2f02b71 | | domain_id | default | | enabled | True | | id | c10da0fb58dd4cf2ac353fe6218eb569 | | name | placement | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
[root@node1 ~(keystone)]# openstack role add --project service --user placement admin
[root@node1 ~(keystone)]# openstack service create --name nova --description "OpenStack Compute service" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute service | | enabled | True | | id | 63778130ffd14cf89f0932125b648bff | | name | nova | | type | compute | +-------------+----------------------------------+
[root@node1 ~(keystone)]# openstack service create --name placement --description "OpenStack Compute Placement service" placement +-------------+-------------------------------------+ | Field | Value | +-------------+-------------------------------------+ | description | OpenStack Compute Placement service | | enabled | True | | id | 0b9a9016fab84043a6c760854e2c30c3 | | name | placement | | type | placement | +-------------+-------------------------------------+
[root@node1 ~(keystone)]# openstack endpoint create --region RegionOne compute public http://192.168.10.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | 7f49605eb0e642ff8704180c0a3e5caa | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 63778130ffd14cf89f0932125b648bff | | service_name | nova | | service_type | compute | | url | http://192.168.10.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+
[root@node1 ~(keystone)]# openstack endpoint create --region RegionOne compute internal http://192.168.10.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | 18538494d8c346b98f35236dc1dce6ee | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 63778130ffd14cf89f0932125b648bff | | service_name | nova | | service_type | compute | | url | http://192.168.10.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+
[root@node1 ~(keystone)]# openstack endpoint create --region RegionOne compute admin http://192.168.10.11:8774/v2.1/%\(tenant_id\)s +--------------+----------------------------------------------+ | Field | Value | +--------------+----------------------------------------------+ | enabled | True | | id | 9dba2c3fda6b460bb14429131a3d9001 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 63778130ffd14cf89f0932125b648bff | | service_name | nova | | service_type | compute | | url | http://192.168.10.11:8774/v2.1/%(tenant_id)s | +--------------+----------------------------------------------+
[root@node1 ~(keystone)]# openstack endpoint create --region RegionOne placement public http://192.168.10.11:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | f57ca7164d784c0e8ac3d7e2505df99b | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 0b9a9016fab84043a6c760854e2c30c3 | | service_name | placement | | service_type | placement | | url | http://192.168.10.11:8778 | +--------------+----------------------------------+
[root@node1 ~(keystone)]# openstack endpoint create --region RegionOne placement internal http://192.168.10.11:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 86d45e74e9524a71875ea9ac9af48ffa | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 0b9a9016fab84043a6c760854e2c30c3 | | service_name | placement | | service_type | placement | | url | http://192.168.10.11:8778 | +--------------+----------------------------------+
[root@node1 ~(keystone)]# openstack endpoint create --region RegionOne placement admin http://192.168.10.11:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 26cfd826e527493c9ad047b030abdb9e | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 0b9a9016fab84043a6c760854e2c30c3 | | service_name | placement | | service_type | placement | | url | http://192.168.10.11:8778 | +--------------+----------------------------------+
2. 设置Nova数据库
[root@node1 ~(keystone)]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 22
Server version: 10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database nova; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova.* to nova@'localhost' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova.* to nova@'%' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create database nova_api; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova_api.* to nova@'localhost' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova_api.* to nova@'%' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create database nova_placement; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova_placement.* to nova@'localhost' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova_placement.* to nova@'%' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> create database nova_cell0; Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova_cell0.* to nova@'localhost' identified by 'password'; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nova_cell0.* to nova@'%' 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
3. 安装及配置Nova
1) 安装Nova
[root@node1 ~(keystone)]# yum --enablerepo=centos-openstack-queens,epel install openstack-nova -y
# 使用openstack源自带的novnc工具 [root@node1 ~(keystone)]# yum remove novnc -y [root@node1 ~(keystone)]# yum --enablerepo=centos-openstack-queens install openstack-nova -y
2) 配置Nova [root@node1 ~(keystone)]# mv /etc/nova/nova.conf /etc/nova/nova.conf.bak [root@node1 ~(keystone)]# vim /etc/nova/nova.conf [DEFAULT] # 定义本机IP my_ip = 192.168.10.11 state_path = /var/lib/nova enabled_apis = osapi_compute,metadata log_dir = /var/log/nova
# RabbitMQ所在位置 transport_url = rabbit://openstack:password@192.168.10.11
[api] auth_strategy = keystone
# glance位置 [glance] api_servers = http://192.168.10.11:9292
[oslo_concurrency] lock_path = $state_path/tmp
# 定义连接数据库的信心 [api_database] connection = mysql+pymysql://nova:password@192.168.10.11/nova_api
[database] connection = mysql+pymysql://nova:password@192.168.10.11/nova
# 定义keystone信息 [keystone_authtoken] www_authenticate_uri = http://192.168.10.11:5000 auth_url = http://192.168.10.11:5000 memcached_servers = 192.168.10.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = servicepassword
[placement] auth_url = http://192.168.10.11:5000 os_region_name = RegionOne auth_type = password project_domain_name = default user_domain_name = default project_name = service username = placement password = servicepassword
[placement_database] connection = mysql+pymysql://nova:password@192.168.10.11/nova_placement
[wsgi] api_paste_config = /etc/nova/api-paste.ini

[root@node1 ~(keystone)]# chmod 640 /etc/nova/nova.conf [root@node1 ~(keystone)]# chgrp nova /etc/nova/nova.conf
[root@node1 ~(keystone)]# vim /etc/httpd/conf.d/00-nova-placement-api.conf # 于15行一下添加如下内容 ...... ...... <Directory /usr/bin> Require all granted </Directory> ...... ......
4. SELinux及防火墙设置
[root@node1 ~(keystone)]# semanage port -a -t http_port_t -p tcp 8778
[root@node1 ~(keystone)]# yum --enablerepo=centos-openstack-queens -y install openstack-selinux
[root@node1 ~(keystone)]# firewall-cmd --add-port={6080/tcp,6081/tcp,6082/tcp,8774/tcp,8775/tcp,8778/tcp} --permanent success [root@node1 ~(keystone)]# firewall-cmd --reload success
5. 同步数据库并启动Nova相关服务
[root@node1 ~(keystone)]# su -s /bin/bash nova -c "nova-manage api_db sync"
[root@node1 ~(keystone)]# su -s /bin/bash nova -c "nova-manage cell_v2 map_cell0"
[root@node1 ~(keystone)]# su -s /bin/bash nova -c "nova-manage db sync"
[root@node1 ~(keystone)]# su -s /bin/bash nova -c "nova-manage cell_v2 create_cell --name cell1"
[root@node1 ~(keystone)]# systemctl restart httpd
[root@node1 ~(keystone)]# chown nova. /var/log/nova/nova-placement-api.log
[root@node1 ~(keystone)]# systemctl enable --now openstack-nova-api openstack-nova-consoleauth \ openstack-nova-conductor openstack-nova-scheduler openstack-nova-novncproxy
[root@node1 ~(keystone)]# openstack compute service list +----+------------------+------------------+----------+---------+-------+----------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+------------------+------------------+----------+---------+-------+----------------------------+ | 1 | nova-scheduler | node1.1000cc.net | internal | enabled | up | 2020-02-05T14:38:02.000000 | | 2 | nova-consoleauth | node1.1000cc.net | internal | enabled | up | 2020-02-05T14:38:03.000000 | | 3 | nova-conductor | node1.1000cc.net | internal | enabled | up | 2020-02-05T14:38:03.000000 | +----+------------------+------------------+----------+---------+-------+----------------------------+
6. 安装Nova-compute
1) 确认KVM已经安装完毕
2) 安装Nova-Compute [root@node1 ~(keystone)]# yum --enablerepo=centos-openstack-queens,epel install openstack-nova-compute -y
3) 配置VNC(便于后续直接通过浏览器控制实例) # 于文档最后追加如下内容 [root@node1 ~(keystone)]# vim /etc/nova/nova.conf ...... ...... ...... ...... ...... ......
[vnc] enabled = True server_listen = 0.0.0.0 server_proxyclient_address = 192.168.10.11 novncproxy_base_url = http://192.168.10.11:6080/vnc_auto.html
7. 为Nova-Compute设定SELinux及防火墙
[root@node1 ~(keystone)]# yum --enablerepo=centos-openstack-queens install openstack-selinux -y
[root@node1 ~(keystone)]# firewall-cmd --add-port=5900-5999/tcp --permanent success [root@node1 ~(keystone)]# firewall-cmd --reload success
8. 启动并验证Nova-Compute
[root@node1 ~(keystone)]# systemctl enable --now openstack-nova-compute
# 发现Nova-Compute [root@node1 ~(keystone)]# su -s /bin/bash nova -c "nova-manage cell_v2 discover_hosts"
[root@node1 ~(keystone)]# openstack compute service list +----+------------------+------------------+----------+---------+-------+----------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+------------------+------------------+----------+---------+-------+----------------------------+ | 1 | nova-scheduler | node1.1000cc.net | internal | enabled | up | 2020-02-05T14:47:33.000000 | | 2 | nova-consoleauth | node1.1000cc.net | internal | enabled | up | 2020-02-05T14:47:33.000000 | | 3 | nova-conductor | node1.1000cc.net | internal | enabled | up | 2020-02-05T14:47:33.000000 | | 6 | nova-compute | node1.1000cc.net | nova | enabled | up | 2020-02-05T14:47:27.000000 | +----+------------------+------------------+----------+---------+-------+----------------------------+
9. 添加扩展计算节点
1) 拓扑
     ------------+-----------------------------+------------
                 |                             |
             eth0|192.168.10.11            eth0|192.168.10.12
     +-----------+-----------+     +-----------+-----------+
     |    [ Control Node ]   |     |    [ Compute Node ]   |
     |   [node1.1000cc.net]  |     |    [node2.1000cc.net] |
     |  MariaDB    RabbitMQ  |     |        Libvirt        |
     |  Memcached  httpd     |     |      Nova Compute     |
     |  Keystone   Glance    |     |                       |
     |  Nova API             |     |                       |
     +-----------------------+     +-----------------------+
2) 在扩展的计算节点上安装KVM并启动 [root@node2 ~]# yum install qemu-kvm libvirt virt-install bridge-utils -y [root@node3 ~]# lsmod | grep kvm [root@node3 ~]# systemctl enable --now libvirtd
3) 安装Nova-Compute [root@node2 ~]# yum --enablerepo=centos-openstack-queens,epel install openstack-nova-compute -y
4) 配置Nova Compute [root@node2 ~]# mv /etc/nova/nova.conf /etc/nova/nova.conf.bak [root@node2 ~]# vim /etc/nova/nova.conf [DEFAULT] my_ip = 192.168.10.12 state_path = /var/lib/nova enabled_apis = osapi_compute,metadata log_dir = /var/log/nova
transport_url = rabbit://openstack:password@192.168.10.11
[api] auth_strategy = keystone
[vnc] enabled = True server_listen = 0.0.0.0 server_proxyclient_address = $my_ip novncproxy_base_url = http://192.168.10.11:6080/vnc_auto.html
[glance] api_servers = http://192.168.10.11:9292
[oslo_concurrency] lock_path = $state_path/tmp
[keystone_authtoken] www_authenticate_uri = http://192.168.10.11:5000 auth_url = http://192.168.10.11:5000 memcached_servers = 192.168.10.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = servicepassword
[placement] auth_url = http://192.168.10.11:5000 os_region_name = RegionOne auth_type = password project_domain_name = default user_domain_name = default project_name = service username = placement password = servicepassword
[wsgi] api_paste_config = /etc/nova/api-paste.ini

[root@node2 ~]# chmod 640 /etc/nova/nova.conf [root@node2 ~]# chgrp nova /etc/nova/nova.conf
5) 设置SELinux及Firwalld [root@node2 ~]# yum --enablerepo=centos-openstack-queens -y install openstack-selinux
[root@node2 ~]# firewall-cmd --add-port=5900-5999/tcp --permanent success [root@node2 ~]# firewall-cmd --reload success
6) 启动Nova Compute [root@node2 ~]# systemctl enable --now openstack-nova-compute
7) 确认 # 未添加扩展计算节点时 [root@node1 ~(keystone)]# su -s /bin/bash nova -c "nova-manage cell_v2 discover_hosts" [root@node1 ~(keystone)]# openstack compute service list +----+------------------+------------------+----------+---------+-------+-------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+------------------+------------------+----------+---------+-------+----------------------------+ | 1 | nova-scheduler | node1.1000cc.net | internal | enabled | up | 2020-02-05T15:17:57.000000 | | 2 | nova-consoleauth | node1.1000cc.net | internal | enabled | up | 2020-02-05T15:17:57.000000 | | 3 | nova-conductor | node1.1000cc.net | internal | enabled | up | 2020-02-05T15:17:56.000000 | | 6 | nova-compute | node1.1000cc.net | nova | enabled | up | 2020-02-05T15:17:56.000000 | | 7 | nova-compute | node2.1000cc.net | nova | enabled | up | 2020-02-05T15:18:00.000000 | +----+------------------+------------------+----------+---------+-------+-------------------------+

 

如对您有帮助,请随缘打个赏。^-^

gold