1. 计算服务Nova介绍
Nova提供一个工具来部署云平台,包括运行实例、管理实例等。它提供的软件能控制 IaaS 云计算平台。OpenStack Compute 没有包含任何的虚拟化软件,相反它定义和运行在主机操作系统上的虚拟化机制交互的驱动程序,并通过基于 Web 的程序应用接口(API)来提供功能的使用。即通过它调用各个虚拟机管理软件的 API 接口来实现对不同种类虚拟机的操作。
1.1 控制节点(API、Cert、ConsoleAuth、Conductor、Scheduler、NoVNCproxy)
nova-api
1. nova-api组件实现RESTful API功能,是外部访问Nova的唯一途径,监听8774
端口。
2. 接收外部的请求并通过Message Queue将请求发送给了其他的服务组件,同时也兼容EC2 API,所有也可以用EC2的管理工具对nova时行日常管理。
nova scheduler
Nova Scheduler模块在openstack中的作用就是决策虚拟机创建在哪个主机(计算节点)上。
决策一个虚机应该调试到某物理节点,需要分两个步骤:
1.过滤(Fliter):根据过滤属性,选出符合条件的计算节点主机。
2.计算权重(Weight):经过主机过滤后, 对主机进行权值计算,根据策略选择相应的某一台主机创建虚机。
1.2 计算节点(Nova-compute、Libvirt + Kvm)
2. Nova部署
2.1 安装软件包
[root@linux-node1 ~]# yum install -y openstack-nova-api openstack-nova-cert openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler
2.2 修改数据库配置
1.修改
/etc/nova/nova.conf
配置文件#在[api_database]和[database]部分,配置数据库的连接:
[api_database]
...
connection=mysql+pymysql://nova:nova@192.168.56.11/nova_api
[database]
...
connection=mysql+pymysql://nova:nova@192.168.56.11/nova2.同步
Compute
数据库#1.同步nova_api数据库
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
#2.同步nova数据库
[root@linux-node1 ~]# su -s /bin/sh -c "nova-manage db sync" nova
#3.检察是否同步成功
[root@linux-node1 ~]# mysql -h 192.168.56.11 -unova -pnova -e "use nova;show tables;"
+--------------------------------------------+
| Tables_in_nova |
+--------------------------------------------+
| agent_builds |
| aggregate_hosts |
| aggregate_metadata |
| aggregates |
...
[root@linux-node1 ~]# mysql -h 192.168.56.11 -unova -pnova -e "use nova_api;show tables;"
+--------------------+
| Tables_in_nova_api |
+--------------------+
| build_requests |
| cell_mappings |
| flavor_extra_specs |
| flavor_projects |
| flavors |
| host_mappings |
| instance_mappings |
| migrate_version |
| request_specs |
+--------------------+
2.3 配置Keystone、RabbitMQ
1.编辑
/etc/nova/nova.conf
配置keystone[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova2.配置RabbitMQ消息队列访问
[DEFAULT]
...
rpc_backend = rabbit
[oslo_messaging_rabbit]
...
rabbit_host=192.168.56.11
#之前rabbitmq添加的openstack用户
rabbit_userid=openstack
rabbit_password=openstack
2.4 配置Nova服务
1.在
[DEFAULT]
部分,启用Nova访问API[DEFAULT]
...
enabled_apis = osapi_compute,metadata2.在
[DEFAULT]
部分,配置使用neutron,使用 Networking 服务[DEFAULT]
...
#不使用Nova自身的网络,使用neutron的网络
use_neutron = True
#关闭Nova自身的防火墙,使用neutron的防火墙
firewall_driver = nova.virt.firewall.NoopFirewallDriver3.在
[vnc]
部分,配置VNC代理使用控制节点的管理接口IP地址[vnc]
...
vncserver_listen = 192.168.56.11
vncserver_proxyclient_address = 192.168.56.114.在
[glance]
区域,配置镜像服务 API 的位置[glance]
...
api_servers = http://192.168.56.11:92925.在
[oslo_concurrency]
部分,配置锁路径[oslo_concurrency]
...
lock_path = /var/lib/nova/tmp
2.5 查看/etc/nova/nova.conf配置
[root@linux-node1 ~]# egrep '^\[|^[a-Z]' /etc/nova/nova.conf
[DEFAULT]
enabled_apis=osapi_compute,metadata #启用api
auth_strategy=keystone #启用keystone
firewall_driver=nova.virt.firewall.NoopFirewallDriver #关闭防火墙
use_neutron=true #使用neutron
rpc_backend=rabbit #使用rabbitmq
[api_database] #连接nova_api数据库
connection=mysql+pymysql://nova:nova@192.168.56.11/nova_api
...
[database] #连接nova数据库
connection=mysql+pymysql://nova:nova@192.168.56.11/nova
...
[glance] #连接glance
api_servers=http://192.168.56.11:9292
...
[keystone_authtoken] #访问keystone配置
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = nova
...
[oslo_concurrency] #锁路径
lock_path=/var/lib/nova/tmp
...
[oslo_messaging_rabbit] #访问rabbitmq配置
rabbit_host=192.168.56.11
rabbit_userid=openstack
rabbit_password=openstack
...
[vnc] #vnc配置
vncserver_listen=192.168.56.11
vncserver_proxyclient_address=192.168.56.11
3. 启动Nova服务并在Keystone上注册
3.1 启动Nova服务
[root@linux-node1 ~]# systemctl start openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
3.2 设置开机启动
[root@linux-node1 ~]# systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
3.3 Nova注册
1.创建
Nova服务
[root@linux-node1 ~]# source admin-openstack.sh
[root@linux-node1 ~]# openstack service create --name nova --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Compute |
| enabled | True |
| id | 8c278ca2a9fb4fef92fc6695d81bbb83 |
| name | nova |
| type | compute |
+-------------+----------------------------------+2.创建
Nova服务API访问点
[root@linux-node1 ~]# openstack endpoint create --region RegionOne compute public http://192.168.56.11:8774/v2.1/%\(tenant_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | 01c5abf91ea649f6b0b8f1d9ca96ecb5 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c278ca2a9fb4fef92fc6695d81bbb83 |
| service_name | nova |
| service_type | compute |
| url | http://192.168.56.11:8774/v2.1/%(tenant_id)s |
+--------------+----------------------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne compute admin http://192.168.56.11:8774/v2.1/%\(tenant_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | e5ce5e1ee2564bb6a672222796a40530 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c278ca2a9fb4fef92fc6695d81bbb83 |
| service_name | nova |
| service_type | compute |
| url | http://192.168.56.11:8774/v2.1/%(tenant_id)s |
+--------------+----------------------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne compute internal http://192.168.56.11:8774/v2.1/%\(tenant_id\)s
+--------------+----------------------------------------------+
| Field | Value |
+--------------+----------------------------------------------+
| enabled | True |
| id | 73cdc2e576cb4e9f992db9fdeab1242f |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 8c278ca2a9fb4fef92fc6695d81bbb83 |
| service_name | nova |
| service_type | compute |
| url | http://192.168.56.11:8774/v2.1/%(tenant_id)s |
+--------------+----------------------------------------------+3.验证Nova是否注册成功
[root@linux-node1 ~]# openstack host list #有如下显示,表示注册成功
+-------------------------+-------------+----------+
| Host Name | Service | Zone |
+-------------------------+-------------+----------+
| linux-node1.example.com | consoleauth | internal |
| linux-node1.example.com | conductor | internal |
| linux-node1.example.com | scheduler | internal |
+-------------------------+-------------+----------+