文章总目录
1、nova是什么?
Openstack 是由Rackspace 和NASA 共同开发的云计算平台类似于AmazonEC2和S3的云基础架构服务Nova
在Openstack 中提供云计算服务超过140 家企业及18470 为开发者参与开发
2、nova组件
nova-api service 接收并响应终端用户计算API 调用。该服务支持OpenStack 计算API,Amazon EC2 和特殊的管理特权API
nova-api-metadata service 接受从实例元数据发来的请求。该服务通常与nova-network 服务在安装多主机模式下运行
nova-compute service 一个守护进程,通过虚拟化层API接口创建和终止虚拟机实例。例如:XenAPI for XenServer/XCP,libvirt for KVM or QEMU,VMwareAPI for Vmware
ova-scheduler service 从队列中获取虚拟机实例请求,并确认由哪台计算服务运行该虚拟机
nova-conductor module 协调nova-compute 服务和database 之间的交互数据。避免nova-compute 服务直接访问云数据库。不要将该模块部署在nova-compute 运行的节点上
nova-network worker daemon 类似于nova-compute服务,接受来自队列的网络任务和操控网络。比如这只网卡桥接或改变iptables规则
nova-consoleauth daemon 在控制台代理提供用户授权令牌
nova-novncproxy daemon 提供了一个通过VNC连接来访问运行的虚拟机实例的代理。支持基于浏览器的novnc客户端
nova-spicehtml5proxy daemon 提供了一个通过spice 连接来访问运行的虚拟机实例的代理。支持基于浏览器的HTML5 客户端
nova-xvncproxy daemon 提供了一个通过VNC连接来访问运行的虚拟机实例的代理。支持OpenStack-specific Java 客户端
nova-cert daemon x509 证书
nova-objectstore daemon 一个Amazon S3 的接口,用于将Amazon S3 的镜像注册到OpenStack
euca2ools client 用于兼容于Amazon E2 接口的命令行工具
nova client nova命令行工具
The queue 在进程之间传递消息的中心。通常使用RabbitMQ
SQL database 保存云基础设置建立和运行时的状态信息
通过引擎发送给Libvirt,它是一个虚拟化管理平台,通过libvirt创建虚拟机
1、基础配置computer节点
[root@compute ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.222.5 controller.nice.com
192.168.222.6 network.nice.com
192.168.222.10 compute1.nice.com
192.168.222.20 block1.nice.com
2、时间与controller节点同步
[root@compute ~]# yum install -y ntpdate
[root@compute ~]# ntpdate -u controller.nice.com
24 Jul 09:07:13 ntpdate[11003]: step time server 192.168.222.5 offset 9415.809954 sec
[root@compute ~]# crontab -e
# 分钟,小时,日,月,周,年
*/1 * * * * ntpdate -u controller.nice.com &> /dev/null
[root@compute ~]# systemctl restart crond
[root@compute ~]# systemctl enable crond
1、下面内容和keystone大体步骤一致,不在赘述细节
[root@controller ~]# mysql -uroot -pa
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 22
Server version: 5.5.37-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program 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 'NOVA_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@controller ~]# source admin-openrc.sh
[root@controller ~]# keystone user-create --name nova --pass NOVA_PASS
+----------+----------------------------------+
| Property | Value |
+----------+----------------------------------+
| email | |
| enabled | True |
| id | dc2dd2a42a84495d9f6373465ffbd971 |
| name | nova |
| username | nova |
+----------+----------------------------------+
[root@controller ~]# keystone user-role-add --user nova --tenant service --role admin
[root@controller ~]# keystone service-create --name nova --type compute --description "OpenStackCompute"
+-------------+----------------------------------+
| Property | Value |
+-------------+----------------------------------+
| description | OpenStackCompute |
| enabled | True |
| id | 83dffa8f523446b3b39066bca8039d96 |
| name | nova |
| type | compute |
+-------------+----------------------------------+
[root@controller ~]# keystone endpoint-create \
> --service-id $(keystone service-list |awk '/compute/{print $2}')\
> --publicurl http://controller.nice.com:8774/v2/%\(tenant_id\)s \
> --internalurl http://controller.nice.com:8774/v2/%\(tenant_id\)s \
> --adminurl http://controller.nice.com:8774/v2/%\(tenant_id\)s \
> --region regionOne
+-------------+--------------------------------------------------+
| Property | Value |
+-------------+--------------------------------------------------+
| adminurl | http://controller.nice.com:8774/v2/%(tenant_id)s |
| id | 6c9721728da34340bec08af358f418e3 |
| internalurl | http://controller.nice.com:8774/v2/%(tenant_id)s |
| publicurl | http://controller.nice.com:8774/v2/%(tenant_id)s |
| region | regionOne |
| service_id | 83dffa8f523446b3b39066bca8039d96 |
+-------------+--------------------------------------------------+
[root@controller ~]# yum install openstack-nova-api openstack-nova-cert openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler python-novaclient
2、更改配置文件
[root@controller ~]# vim /etc/nova/nova.conf
a.编辑[database]小节,配置数据库访问:
[database]
...
connection = mysql://nova:NOVA_DBPASS@controller.nice.com/nova
b.编辑[DEFAULT]小节,配置RabbitMQ消息队列访问:
[DEFAULT]
...
rpc_backend= rabbitrabbit_host= controller.nice.com
rabbit_password= RABBIT_PASS
c.编辑[DEFAULT]和[keystone_authtoken]小节,配置认证服务[DEFAULT]
...
auth_strategy= keystone
[keystone_authtoken]
...
auth_uri= http://controller.nice.com:5000/v2.0
identity_uri= http://controller.nice.com:35357
admin_tenant_name= service
admin_user= nova
admin_password= NOVA_PASS
d.编辑[DEFAULT]小节,配置my_ip选项为controller节点的管理接口ip:[DEFAULT]
...
my_ip= 192.168.1.5
e.编辑[DEFAULT]小节,配置VNCdialing服务的使用controller节点的管理接口ip:
[DEFAULT]
...
vncserver_listen= 192.168.1.5
vncserver_proxyclient_address= 192.168.1.5
f.编辑[glance]小节,配置镜像服务器的位置:
[glance]
...
host = controller.nice.comg.(可选)
在[DEFAULT]小节中配置详细日志输出。方便排错。
[DEFAULT]
...
verbose = True
3、初始化计算数据库
[root@controller ~]# su -s /bin/sh -c "nova-manage db sync" nova
启动计算服务并配置开机自动启动
[root@controller ~]# systemctl start openstack-nova-api.service openstack-nova-cert.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
[root@controller ~]# systemctl enable openstack-nova-api.service openstack-nova-cert.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
ln -s '/usr/lib/systemd/system/openstack-nova-api.service' '/etc/systemd/system/multi-user.target.wants/openstack-nova-api.service'
ln -s '/usr/lib/systemd/system/openstack-nova-cert.service' '/etc/systemd/system/multi-user.target.wants/openstack-nova-cert.service'
ln -s '/usr/lib/systemd/system/openstack-nova-consoleauth.service' '/etc/systemd/system/multi-user.target.wants/openstack-nova-consoleauth.service'
ln -s '/usr/lib/systemd/system/openstack-nova-scheduler.service' '/etc/systemd/system/multi-user.target.wants/openstack-nova-scheduler.service'
ln -s '/usr/lib/systemd/system/openstack-nova-conductor.service' '/etc/systemd/system/multi-user.target.wants/openstack-nova-conductor.service'
ln -s '/usr/lib/systemd/system/openstack-nova-novncproxy.service' '/etc/systemd/system/multi-user.target.wants/openstack-nova-novncproxy.service'
1、安装软件包
# yum install openstack-nova-compute sysfsutils
[root@controller ~]# vim /etc/nova/nova.conf
a.编辑[DEFAULT]小节,配置RabbitMQ消息队列访问:
[DEFAULT]
...
rpc_backend= rabbit
rabbit_host= controller.nice.com
rabbit_password= RABBIT_PASS
b.编辑[DEFAULT]和[keystone_authtoken]小节,配置认证服务访问:
[DEFAULT]
...
auth_strategy= keystone
[keystone_authtoken]
...
auth_uri= http://controller.nice.com:5000/v2.0
identity_uri= http://controller.nice.com:35357
admin_tenant_name= service
admin_user= nova
admin_password= NOVA_PASS
c.编辑[DEFAULT]小节,配置my_ip配置项:
[DEFAULT]
...
my_ip= MANAGEMENT_INTERFACE_IP_ADDRESS
d.编辑[DEFAULT]小节,开启并配置远程控制台访问
[DEFAULT]
...
vnc_enabled= True
vncserver_listen= 0.0.0.0
vncserver_proxyclient_address= MANAGEMENT_INTERFACE_IP_ADDRESS
novncproxy_base_url= http://controller.nice.com:6080/vnc_auto.html
e.编辑[glance]小节,配置镜像服务器位置
[glance]
...
host = controller.nice.com
f.(可选)在[DEFAULT]小节中配置详细日志输出。方便排错。
[DEFAULT]
...
verbose = True
完成安装
1、确认你的计算节点是否支持硬件虚拟化
# egrep-c '(vmx|svm)' /proc/cpuinfo
如果返回值>=1,则说明你的计算节点硬件支持虚拟化,无需额外配置。如果返回值=0,则活命你的计算节点硬件不支持虚拟化,你必须配置libvirt由使用KVM改为QEMU。
在/etc/nova/nova.conf文件中编辑[libvirt]小节
[libvirt]
...
virt_type= qemu
2、启动计算服务及依赖服务,并设置他们开机自动启动。
# systemctlenable libvirtd.serviceopenstack-nova-compute.service# systemctlstart libvirtd.service# systemctlstart openstack-nova-compute.service
[root@controller ~]# source admin-openrc.sh
[root@controller ~]# nova service-list
+----+------------------+---------------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+---------------------+----------+---------+-------+----------------------------+-----------------+
| 1 | nova-scheduler | controller.nice.com | internal | enabled | up | 2020-07-24T14:36:43.000000 | - |
| 2 | nova-consoleauth | controller.nice.com | internal | enabled | up | 2020-07-24T14:36:43.000000 | - |
| 3 | nova-conductor | controller.nice.com | internal | enabled | up | 2020-07-24T14:36:43.000000 | - |
| 4 | nova-cert | controller.nice.com | internal | enabled | up | 2020-07-24T14:36:44.000000 | - |
| 5 | nova-compute | compute1.nice.com | nova | enabled | up | 2020-07-24T14:36:46.000000 | - |
+----+------------------+---------------------+----------+---------+-------+----------------------------+-----------------+
[root@controller ~]# nova image-list
+--------------------------------------+---------------------+--------+--------+
| ID | Name | Status | Server |
+--------------------------------------+---------------------+--------+--------+
| 807f460b-566a-4989-b166-dc83248d4a40 | cirros-0.3.3-x86_64 | ACTIVE | |
+--------------------------------------+---------------------+--------+--------+