布署nova控制节点
nova分为控制节点和计算节点,计算节点通过nova computer进行虚拟机创建,通过libvirt调用kvm创建虚拟机,nova之间通信通过rabbitMQ队列进行通信
其组件和功能如下:
API:负责接收和响应外部请求。
Scheduler:负责调度虚拟机所在的物理机。
Conductor:计算节点访问数据库的中间件。
Consoleauth:用于控制台的授权认证。
Novncproxy:VNC 代理,用于显示虚拟机操作终端。
Nova-API的功能:
Nova-api组件实现了restful API的功能,接收和响应来自最终用户的计算API请求,接收外部的请求并通过message queue将请求发动给其他服务组件,同时也兼容EC2 API,所以也可以使用EC2的管理工具对nova进行日常管理。
nova scheduler:
nova scheduler模块在openstack中的作用是决策虚拟机创建在哪个主机(计算节点)上。决策一个虚拟机应该调度到某物理节点,需要分为两个步骤:
过滤(filter):过滤出可以创建虚拟机的主机
计算权值(weight):根据权重大进行分配,默认根据资源可用空间进行权重排序
安装并配置nova控制节点
官方安装文档
在数据库服务器操作
1. 准备数据库
mysql -uroot -p123
MariaDB [(none)]> CREATE DATABASE nova_api;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY '123'; MariaDB [(none)]> CREATE DATABASE nova;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '123';
MariaDB [(none)]> CREATE DATABASE nova_cell0;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY '123'; MariaDB [(none)]> flush privileges;
在控制端
1. 安装
yum -y install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler
2. 创建nova服务(类型compute)
openstack user create --domain default --password-prompt nova
openstack role add --project service --user nova admin
openstack service create --name nova \ --description "OpenStack Compute" compute
3. 创建公共端点
openstack endpoint create --region RegionOne \ compute public http://controller:8774/v2.1 12
4. 创建私有端点
openstack endpoint create --region RegionOne \ compute internal http://controller:8774/v2.1
5. 创建管理端点
openstack endpoint create --region RegionOne \ compute admin http://controller:8774/v2.1
6. 编辑/etc/nova/nova.conf
sed -i -e '/^#/d' -e '/^$/d' /etc/nova/nova.conf
详细配置:
[DEFAULT] my_ip = 192.168.99.111 use_neutron = true firewall_driver = nova.virt.firewall.NoopFirewallDriver enabled_apis = osapi_compute,metadata transport_url = rabbit://openstack:123@openvip.com rpc_backend=rabbit
[api] auth_strategy=keystone
[api_database] connection = mysql+pymysql://nova:123@openvip.com/nova_api
[database] connection = mysql+pymysql://nova:123@openvip.com/nova
[glance] api_servers = http://controller:9292
[keystone_authtoken] auth_url = http://controller:5000/v3 memcached_servers = openvip.com:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = 123
[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://controller:5000/v3 username = placement password = 123
[vnc] enabled = true server_listen = $my_ip server_proxyclient_address = $my_ip
7. 配置apache允许访问placement API
vim /etc/httpd/conf.d/00-placement-api.conf
最下方添加以下配置:
<Directory /usr/bin> <IfVersion >= 2.4> Require all granted </IfVersion> <IfVersion < 2.4> Order allow,deny Allow from all </IfVersion> </Directory>
重启http
systemctl restart httpd
8. 初始化数据库
#nova_api数据库
su -s /bin/sh -c "nova-manage api_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
#nova数据库
su -s /bin/sh -c "nova-manage db sync" nova
验证nova cell0和nova cell1是否正常注册
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
9. 启动并将nova服务设置为开机启动
systemctl enable openstack-nova-api.service \ openstack-nova-consoleauth.service \ openstack-nova-scheduler.service \ openstack-nova-conductor.service \ openstack-nova-novncproxy.service
systemctl restart openstack-nova-api.service \ openstack-nova-consoleauth.service \ openstack-nova-scheduler.service \ openstack-nova-conductor.service \ openstack-nova-novncproxy.service
10. 重启nova控制端脚本(nova-restart.sh)
#!/bin/bash
systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service
chmod a+x nova-restart.sh
资料来自: https://thson.blog.csdn.net/article/details/100055018