Openstack(九)部署nova服务(控制节点)
9.1nova服务介绍
nova是openstack最早的组件之一,nova分为控制节点和计算节点,计算节点通过nova computer进行虚拟机创建,通过libvirt调用kvm创建虚拟机,nova之间通信通过rabbitMQ队列进行通信,其组件和功能如下:
API:负责接收和响应外部请求。
Scheduler:负责调度虚拟机所在的物理机。
Conductor:计算节点访问数据库的中间件。
Consoleauth:用于控制台的授权认证。
Novncproxy:VNC 代理,用于显示虚拟机操作终端。
官方部署文档:https://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/common/get_started_compute.html
Nova-API的功能:
Nova-api组件实现了restful API的功能,接收和响应来自最终用户的计算API请求,接收外部的请求并通过message queue将请求发动给其他服务组件,同时也兼容EC2 API,所以也可以使用EC2的管理工具对nova进行日常管理。
nova scheduler:
nova scheduler模块在openstack中的作用是决策虚拟机创建在哪个主机(计算节点)上。决策一个虚拟机应该调度到某物理节点,需要分为两个步骤:
过滤(filter),过滤出可以创建虚拟机的主机
9.2安装nove控制节点
官方安装文档:https://docs.openstack.org/ocata/zh_CN/install-guide-rdo/nova-controller-install.html
9.2.1安装nova控制端
# 在控制服务器安装
# yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api
9.2.2数据库准备
# 注mariaDB使用时需三个库都添加本主机权限GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'<主机名>' IDENTIFIED BY 'nova123';
# mysql
> CREATE DATABASE nova_api;
> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova123';
> CREATE DATABASE nova;
> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova123';
> CREATE DATABASE nova_cell0;
> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova123';
> flush privileges;
9.2.3验证数据库
9.3配置nova控制端服务
控制端服务器操作
9.3.1创建nova服务
# openstack service create --name nova --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | f5d5af647ae040eca5bf7d878c23086d |
| name | nova |
| type | compute |
+-------------+----------------------------------+
9.3.2创建公共端点
# openstack endpoint create --region RegionOne compute public http://192.168.10.100:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 9ea17b1200fc40ed84de2c66651d8298 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | f5d5af647ae040eca5bf7d878c23086d |
| service_name | nova |
| service_type | compute |
| url | http://192.168.10.100:8774/v2.1 |
+--------------+----------------------------------+
9.3.3创建私有端点
# openstack endpoint create --region RegionOne compute internal http://192.168.10.100:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | cc3e3b629fbf44a69948922773836804 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | f5d5af647ae040eca5bf7d878c23086d |
| service_name | nova |
| service_type | compute |
| url | http://192.168.10.100:8774/v2.1 |
+--------------+----------------------------------+
9.3.4创建管理端点
# openstack endpoint create --region RegionOne compute admin http://192.168.10.100:8774/v2.1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 51dca1e673ee419f8c75fb9646520003 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | f5d5af647ae040eca5bf7d878c23086d |
| service_name | nova |
| service_type | compute |
| url | http://192.168.10.100:8774/v2.1 |
+--------------+----------------------------------+
9.3.5创建placement用户
# Placement用户密码设置为placement
# openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | 961b40ed4c6b40a9b266ce5e451a4292 |
| enabled | True |
| id | f052cbbd13d341e3bee6a0da23588802 |
| name | placement |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
9.3.6授权placement用户admin权限
# openstack role add --project service --user placement admin
9.3.7创建placement API并注册
# openstack service create --name placement --description "Placement API" placement
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Placement API |
| enabled | True |
| id | af5b2be1a8e24a2d9a619f318a04022a |
| name | placement |
| type | placement |
+-------------+----------------------------------+
# openstack endpoint create --region RegionOne placement public http://192.168.10.100:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | c1eb9cc9c3bf42bd9b49ac86b309fe2b |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | af5b2be1a8e24a2d9a619f318a04022a |
| service_name | placement |
| service_type | placement |
| url | http://192.168.10.100:8778 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne placement internal http://192.168.10.100:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 65cf7e1dbeac440ea6a4e369e816d83e |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | af5b2be1a8e24a2d9a619f318a04022a |
| service_name | placement |
| service_type | placement |
| url | http://192.168.10.100:8778 |
+--------------+----------------------------------+
# openstack endpoint create --region RegionOne placement admin http://192.168.10.100:8778
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 8c073907d3d84c5995df683b0a2c4f5b |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | af5b2be1a8e24a2d9a619f318a04022a |
| service_name | placement |
| service_type | placement |
| url | http://192.168.10.100:8778 |
+--------------+----------------------------------+
9.3.8配置nova.conf配置文件
# 详细配置文件/etc/nova/nova.conf
1:[DEFAULT]
2306:use_neutron=true
2465:firewall_driver=nova.virt.firewall.NoopFirewallDriver
2629:enabled_apis=osapi_compute,metadata
3021:transport_url = rabbit://openstack:123456@192.168.10.205
3028:rpc_backend=rabbit
3069:[api]
3085:auth_strategy=keystone
3367:[api_database]
3380:connection = mysql+pymysql://nova:nova123@192.168.10.100/nova_api
4370:[database]
4398:connection = mysql+pymysql://nova:nova123@192.168.10.100/nova
4939:[glance]
4957:api_servers=http://192.168.10.100:9292
5598:[keystone_authtoken]
5599:auth_uri = http://192.168.10.100:5000
5600:auth_url = http://192.168.10.100:35357
5601:memcached_servers = 192.168.10.100:11211
5602:auth_type = password
5603:project_domain_name = default
5604:user_domain_name = default
5605:project_name = service
5606:username = nova
5607:password = nova
7235:[oslo_concurrency]
7250:lock_path=/var/lib/nova/tmp
8081:[placement]
8082:os_region_name = RegionOne
8083:project_domain_name = Default
8084:project_name = service
8085:auth_type = password
8086:user_domain_name = Default
8087:auth_url = http://192.168.10.100:35357/v3
8088:username = placement
8089:password = placement
9669:[vnc]
9685:enabled=true
9708:vncserver_listen=192.168.10.201
9720:vncserver_proxyclient_address=192.168.10.201
9.3.9配置apache服务placement API
# 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>
# systemctl restart httpd #重启http服务
9.3.10初始化数据库
#nova_api数据库
# su -s /bin/sh -c "nova-manage api_db sync" nova
#nova数据库
# su -s /bin/sh -c "nova-manage db sync" nova
#nova cell0数据库
# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
#nova cell1 数据库
# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
7972a48a-bddb-4957-b773-852565a25725
9.4验证nova cell0和nova cell1是否正常注册
# nova-manage cell_v2 list_cells
+-------+--------------------------------------+
| Name | UUID |
+-------+--------------------------------------+
| cell0 | 00000000-0000-0000-0000-000000000000 |
| cell1 | 7972a48a-bddb-4957-b773-852565a25725 |
+-------+--------------------------------------+
9.5启动并将nova服务设置为开机启动
# 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
9.6重启nova控制端脚本
# cat nova-restart.sh
#!/bin/bash
systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
# chmod a+x nova-restart.sh
9.7查看nova服务日志
9.8查看rabbitMQ连接
9.9验证nova控制端:
# nova service-list