OpenStack-Pike 搭建之Nova(四)

OpenStack-Pike 搭建之Nova(四)

Acha
2022-07-13 / 0 评论 / 106 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年07月21日,已超过617天没有更新,若内容或图片失效,请留言反馈。

Nova

概述

Use OpenStack Compute to host and manage cloud computing systems. OpenStack Compute is a major part of an Infrastructure-as-a-Service (IaaS) system. The main modules are implemented in Python.

OpenStack Compute interacts with OpenStack Identity for authentication; OpenStack Image service for disk and server images; and OpenStack Dashboard for the user and administrative interface. Image access is limited by projects, and by users; quotas are limited per project (the number of instances, for example). OpenStack Compute can scale horizontally on standard hardware, and download images to launch instances.

OpenStack Compute consists of the following areas and their components:

nova-api service

Accepts and responds to end user compute API calls. The service supports the OpenStack Compute API, the Amazon EC2 API, and a special Admin API for privileged users to perform administrative actions. It enforces some policies and initiates most orchestration activities, such as running an instance.

nova-api-metadata service

Accepts metadata requests from instances. The nova-api-metadata service is generally used when you run in multi-host mode with nova-network installations. For details, see Metadata service in the Compute Administrator Guide.

nova-compute service

A worker daemon that creates and terminates virtual machine instances through hypervisor APIs. For example:XenAPI for XenServer/XCPlibvirt for KVM or QEMUVMwareAPI for VMwareProcessing is fairly complex. Basically, the daemon accepts actions from the queue and performs a series of system commands such as launching a KVM instance and updating its state in the database.

nova-placement-api service

Tracks the inventory and usage of each provider. For details, see Placement API.

nova-scheduler service

Takes a virtual machine instance request from the queue and determines on which compute server host it runs.

nova-conductor module

Mediates interactions between the nova-compute service and the database. It eliminates direct accesses to the cloud database made by the nova-compute service. The nova-conductor module scales horizontally. However, do not deploy it on nodes where the nova-compute service runs. For more information, see the conductor section in the Configuration Options.

nova-consoleauth daemon

Authorizes tokens for users that console proxies provide. See nova-novncproxy and nova-xvpvncproxy. This service must be running for console proxies to work. You can run proxies of either type against a single nova-consoleauth service in a cluster configuration. For information, see About nova-consoleauth.

nova-novncproxy daemon

Provides a proxy for accessing running instances through a VNC connection. Supports browser-based novnc clients.

nova-spicehtml5proxy daemon

Provides a proxy for accessing running instances through a SPICE connection. Supports browser-based HTML5 client.

nova-xvpvncproxy daemon

Provides a proxy for accessing running instances through a VNC connection. Supports an OpenStack-specific Java client.

The queue

A central hub for passing messages between daemons. Usually implemented with RabbitMQ, also can be implemented with another AMQP message queue, such as ZeroMQ.

SQL database

Stores most build-time and run-time states for a cloud infrastructure, including:

  • Available instance types

  • Instances in use

  • Available networks

  • Projects

Theoretically, OpenStack Compute can support any database that SQLAlchemy supports. Common databases are SQLite3 for test and development work, MySQL, MariaDB, and PostgreSQL.


安装和配置 控制节点

前置条件

1、创建数据库并授权

  • 使用 root 用户登录数据库
 mysql -u root -p000000
  • 创建 nova_apinovanova_cell0 数据库
CREATE DATABASE nova_api;

CREATE DATABASE nova;

CREATE DATABASE nova_cell0;
  • 对 nova用户 授权
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \
  IDENTIFIED BY '000000';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \
  IDENTIFIED BY '000000';

GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \
  IDENTIFIED BY '000000';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \
  IDENTIFIED BY '000000';

GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \
  IDENTIFIED BY '000000';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \
  IDENTIFIED BY '000000';

2、获取 admin 凭证

. admin-openrc

3、创建 计算服务凭证

  • 创建 nova用户
openstack user create --domain default --password 000000 nova
  • 将 service项目 中 nova用户,设置为 admin角色
openstack role add --project service --user nova admin
  • 创建 nova服务实体
openstack service create --name nova --description "OpenStack Compute" compute

4、创建 计算服务 API 端点

openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1

openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1

openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1

5、创建 placement 凭证

  • 创建 placement 用户
openstack user create --domain default --password 000000 placement
  • 将 service项目 中 placement 用户,设置为 admin角色
openstack role add --project service --user placement admin
  • 创建 nova服务实体
openstack service create --name placement --description "Placement API" placement

6、创建 placement API端点

openstack endpoint create --region RegionOne placement public http://controller:8778

openstack endpoint create --region RegionOne placement internal http://controller:8778

openstack endpoint create --region RegionOne placement admin http://controller:8778

安装和配置组件

1、安装软件包

yum install -y openstack-nova-api openstack-nova-conductor \
  openstack-nova-console openstack-nova-novncproxy \
  openstack-nova-scheduler openstack-nova-placement-api

2、配置 nova.conf

sed -i.bak '/^#/d;/^$/d' /etc/nova/nova.conf

vim /etc/nova/nova.conf

[DEFAULT]
# 仅启用计算和元数据API
enabled_apis = osapi_compute,metadata
# 配置RabbitMQ消息队列访问
transport_url = rabbit://openstack:000000@controller
# 控制器节点的管理IP
my_ip = 178.120.2.10
# 启用对网络服务的支持
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver

[api_database]
# 配置数据库访问
connection = mysql+pymysql://nova:000000@controller/nova_api

[database]
# 配置数据库访问
connection = mysql+pymysql://nova:000000@controller/nova

[api]
# 配置身份服务访问
auth_strategy = keystone

[keystone_authtoken]
# 配置身份服务访问
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = 000000

[vnc]
enabled = true
# VNC代理配置为 使用控制器节点的管理接口IP地址
vncserver_listen = $my_ip
vncserver_proxyclient_address = $my_ip

[glance]
# 配置图像服务API的位置
api_servers = http://controller:9292

[oslo_concurrency]
# 配置锁定路径
lock_path = /var/lib/nova/tmp

[placement]
# 配置 Placement API
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:35357/v3
username = placement
password = 000000

3、配置 00-nova-placement-api.conf

vim /etc/httpd/conf.d/00-nova-placement-api.conf

# 启用对 Placement API 的访问
<Directory /usr/bin>
   <IfVersion >= 2.4>
      Require all granted
   </IfVersion>
   <IfVersion < 2.4>
      Order allow,deny
      Allow from all
   </IfVersion>
</Directory>

4、同步 nova 数据库

su -s /bin/sh -c "nova-manage api_db sync" nova

5、数据库同步

  • 注册 cell0 数据库
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" 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

5、验证 novacell0cell1 成功注册

nova-manage cell_v2 list_cells

安装完成

启动计算服务并设置开机自启

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

安装和配置 计算节点

安装和配置组件

1、安装软件包

yum install -y openstack-nova-compute
> Tip:
>    Error: Package: 1:openstack-nova-compute-16.1.6-1.el7.noarch (OpenStack-Pike-tuna)

rpm -ivh http://mirrors.163.com/centos/7/extras/x86_64/Packages/centos-release-virt-common-1-1.el7.centos.noarch.rpm  --replacepkgs
rpm -ivh http://mirrors.163.com/centos/7/extras/x86_64/Packages/centos-release-qemu-ev-1.0-4.el7.centos.noarch.rpm  --replacepkgs

2、配置 nova.conf

sed -i.bak '/^#/d;/^$/d' /etc/nova/nova.conf

vim /etc/nova/nova.conf

[DEFAULT]
# 启用 计算 和 元数据API
enabled_apis = osapi_compute,metadata
# 配置 RabbitMQ消息队列 访问
transport_url = rabbit://openstack:000000@controller
# 计算节点上管理网络 IP地址
my_ip = 178.120.2.20
# 启用对网络服务的支持
use_neutron = True
firewall_driver = nova.virt.firewall.NoopFirewallDriver

[api]
# 配置 身份服务访问
auth_strategy = keystone

[keystone_authtoken]
# 配置身份服务访问
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = nova
password = 000000

[vnc]
# 启用 和 配置远程控制台访问
enabled = True
vncserver_listen = 0.0.0.0
vncserver_proxyclient_address = $my_ip
novncproxy_base_url = http://178.120.2.10:6080/vnc_auto.html

[glance]
# 配置图像服务 API的位置
api_servers = http://controller:9292

[oslo_concurrency]
# 配置锁定路径
lock_path = /var/lib/nova/tmp

[placement]
# 配置 Placement API
os_region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:35357/v3
username = placement
password = 000000

完成安装

1、确认计算节点是否支持虚拟化

egrep -c '(vmx|svm)' /proc/cpuinfo

vim /etc/nova/nova.conf

[libvirt]
# 虚拟化选项(默认kvm)
virt_type = qemu

2、启动计算服务并设置开机自启

systemctl enable libvirtd.service openstack-nova-compute.service
systemctl start libvirtd.service openstack-nova-compute.service

添加计算节点

控制节点执行

1、检查数据库中有该计算节点

. admin-openrc

openstack compute service list --service nova-compute

2、注册 计算节点

su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova

自动注册(可选)

[scheduler]
# 自动注册主机时间
discover_hosts_in_cells_interval = 300

验证

1、获取 admin 凭证

. admin-openrc

2、查询 计算服务组件列表

openstack compute service list

3、查询 Keytone 中API端点 列表

openstack catalog list

4、 查询 placement API 和 Cell 是否工作

nova-status upgrade check

0

评论

博主关闭了当前页面的评论