添加 Compute 服务
控制节点:
完成下面的步骤以创建数据库:
用数据库连接客户端以 root 用户连接到数据库服务器:
$ mysql -u root -p
创建 nova数据库:
CREATE DATABASE nova;
对nova数据库授予恰当的访问权限:
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \ IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \ IDENTIFIED BY 'NOVA_DBPASS';
使用合适的密码替换NOVA_DBPASS。
退出数据库客户端。
获得 admin 凭证来获取只有管理员能执行命令的访问权限:
$ source admin-openrc.sh
要创建服务证书,完成这些步骤:
创建 nova 用户:
$ openstack user create --domain default --password-prompt nova User Password: Repeat User Password: +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | default | | enabled | True | | id | 8c46e4760902464b889293a74a0c90a8 | | name | nova | +-----------+----------------------------------+
添加admin 角色到 nova 用户:
$ openstack role add --project service --user nova admin
创建nova 服务实体:
$ openstack service create --name nova \ --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | 060d59eac51b4594815603d75a00aba2 | | name | nova | | type | compute | +-------------+----------------------------------+
创建计算服务API端点:
$ openstack endpoint create --region RegionOne \ compute public http://controller:8774/v2/%\(tenant_id\)s +--------------+-----------------------------------------+ | Field | Value | +--------------+-----------------------------------------+ | enabled | True | | id | 3c1caa473bfe4390a11e7177894bcc7b | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | e702f6f497ed42e6a8ae3ba2e5871c78 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2/%(tenant_id)s | +--------------+-----------------------------------------+ $ openstack endpoint create --region RegionOne \ compute internal http://controller:8774/v2/%\(tenant_id\)s +--------------+-----------------------------------------+ | Field | Value | +--------------+-----------------------------------------+ | enabled | True | | id | e3c918de680746a586eac1f2d9bc10ab | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | e702f6f497ed42e6a8ae3ba2e5871c78 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2/%(tenant_id)s | +--------------+-----------------------------------------+ $ openstack endpoint create --region RegionOne \ compute admin http://controller:8774/v2/%\(tenant_id\)s +--------------+-----------------------------------------+ | Field | Value | +--------------+-----------------------------------------+ | enabled | True | | id | 38f7af91666a47cfb97b4dc790b94424 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | e702f6f497ed42e6a8ae3ba2e5871c78 | | service_name | nova | | service_type | compute | | url | http://controller:8774/v2/%(tenant_id)s | +--------------+-----------------------------------------+
安全并配置组件
控制节点:
安装软件包:
# yum install openstack-nova-api openstack-nova-cert \ openstack-nova-conductor openstack-nova-console \ openstack-nova-novncproxy openstack-nova-scheduler \ python-novaclient
编辑/etc/nova/nova.conf文件并完成下面的操作:
在 [database] 部分,配置数据库访问:
[database] ... connection = mysql://nova:NOVA_DBPASS@controller/nova
使用你为计算数据库选择的密码替换NOVA_DBPASS 。
在 [DEFAULT] 和 [oslo_messaging_rabbit]部分,配置 “RabbitMQ” 消息队列访问:
[DEFAULT] ... rpc_backend = rabbit [oslo_messaging_rabbit] ... rabbit_host = controller rabbit_userid = openstack rabbit_password = RABBIT_PASS
用你在 “RabbitMQ” 中为 “openstack” 用户选择的密码替换 “RABBIT_PASS”。
在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:
[DEFAULT] ... auth_strategy = keystone [keystone_authtoken] ... auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = nova password = NOVA_PASS
使用你在身份认证服务中选择的nova 用户密码替换NOVA_PASS。
在 [DEFAULT] 部分,配置 my_ip 来使用控制节点的管理接口的IP 地址。
[DEFAULT] ... my_ip = 10.0.0.11
在 [DEFAULT]部分,启用网络服务支持:
[DEFAULT] ... network_api_class = nova.network.neutronv2.api.API security_group_api = neutron linuxnet_interface_driver = nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver firewall_driver = nova.virt.firewall.NoopFirewallDriver
在[vnc]部分,配置VNC代理使用控制节点的管理IP地址 :
[vnc] ... vncserver_listen = $my_ip vncserver_proxyclient_address = $my_ip
在[glance]部分,配置镜像服务的位置:
[glance] ... host = controller
在 [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency] ... lock_path = /var/lib/nova/tmp
在[DEFAULT]部分,禁用EC2 API:
[DEFAULT] ... enabled_apis=osapi_compute,metadata
(可选的)为帮助排错,在 “[DEFAULT]”部分启用详细日志。
[DEFAULT] ... verbose = True
同步Compute 数据库:
# su -s /bin/sh -c "nova-manage db sync" nova
启动 Compute 服务并将其设置为随系统启动:
# 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 # 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
安装和配置计算节点
计算节点:
安装软件包:
yum install openstack-nova-compute sysfsutils
编辑/etc/nova/nova.conf文件并完成下面的操作:
在[DEFAULT] 和 [oslo_messaging_rabbit]部分,配置RabbitMQ消息队列:
[DEFAULT] ... rpc_backend = rabbit [oslo_messaging_rabbit] ... rabbit_host = controller rabbit_userid = openstack rabbit_password = RABBIT_PASS
用你在 “RabbitMQ” 中为 “openstack” 用户选择的密码替换 “RABBIT_PASS”。
在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:
[DEFAULT] ... auth_strategy = keystone [keystone_authtoken] ... auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = nova password = NOVA_PASS
使用你在身份认证服务中选择的nova用户密码替换NOVA_PASS。
在 [DEFAULT] 部分,配置 my_ip 选项:
[DEFAULT] ... my_ip = MANAGEMENT_INTERFACE_IP_ADDRESS将其中的 MANAGEMENT_INTERFACE_IP_ADDRESS 替换为计算节点上的管理网络接口的IP 地址,例如 :ref:`example architecture <overview-example-architectures>`中所示的第一个节点 10.0.0.31 。
在 [DEFAULT]部分,启用网络服务支持:
[DEFAULT] ... network_api_class = nova.network.neutronv2.api.API security_group_api = neutron linuxnet_interface_driver = nova.network.linux_net.NeutronLinuxBridgeInterfaceDriver firewall_driver = nova.virt.firewall.NoopFirewallDriver
在[vnc]部分,启用并配置远程控制台访问:
[vnc] ... enabled = True vncserver_listen = 0.0.0.0 vncserver_proxyclient_address = $my_ip novncproxy_base_url = http://controller:6080/vnc_auto.html服务器组件监听所有的 IP 地址,而代理组件仅仅监听计算节点管理网络接口的 IP 地址。基本的 URL 指示您可以使用 web 浏览器访问位于该计算节点上实例的远程控制台的位置。
在[glance]部分,配置镜像服务的位置:
[glance] ... host = controller
在 [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency] ... lock_path = /var/lib/nova/tmp
(可选的)为帮助排错,在 “[DEFAULT]”部分启用详细日志。
[DEFAULT] ... verbose = True
完成安装
计算节点:
确定您的计算节点是否支持虚拟机的硬件加速。
$ egrep -c '(vmx|svm)' /proc/cpuinfo
如果这个命令返回 1或者更大的值,说明您的计算节点支持硬件加速,一般不需要进行额外的配置。
如果这个命令返回0,你的计算节点不支持硬件加速,你必须配置 libvirt 使用QEMU而不是使用KVM。
在/etc/nova/nova.conf 文件像下面这样编辑 [libvirt]部分:
[libvirt] ... virt_type = qemu
启动计算服务及其依赖,并将其配置为随系统自动启动:
# systemctl enable libvirtd.service openstack-nova-compute.service # systemctl start libvirtd.service openstack-nova-compute.service
验证操作:
控制节点:
获得 admin 凭证来获取只有管理员能执行命令的访问权限:
$ source admin-openrc.sh
列出服务组件,以验证是否成功启动并注册了每个进程:
$ nova service-list +----+------------------+------------+----------+---------+-------+--------------+-----------------+ | Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | +----+------------------+------------+----------+---------+-------+--------------+-----------------+ | 1 | nova-conductor | controller | internal | enabled | up | 2014-09-16.. | - | | 2 | nova-consoleauth | controller | internal | enabled | up | 2014-09-16.. | - | | 3 | nova-scheduler | controller | internal | enabled | up | 2014-09-16.. | - | | 4 | nova-cert | controller | internal | enabled | up | 2014-09-16.. | - | | 5 | nova-compute | compute1 | nova | enabled | up | 2014-09-16.. | - | +----+------------------+------------+----------+---------+-------+--------------+-----------------+
列出身份认证服务中的 API 端点来验证身份认证服务的连通性:
$ nova endpoints +-----------+------------------------------------------------------------+ | nova | Value | +-----------+------------------------------------------------------------+ | id | 1fb997666b79463fb68db4ccfe4e6a71 | | interface | public | | region | RegionOne | | region_id | RegionOne | | url | http://controller:8774/v2/ae7a98326b9c455588edd2656d723b9d | +-----------+------------------------------------------------------------+ +-----------+------------------------------------------------------------+ | nova | Value | +-----------+------------------------------------------------------------+ | id | bac365db1ff34f08a31d4ae98b056924 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | url | http://controller:8774/v2/ae7a98326b9c455588edd2656d723b9d | +-----------+------------------------------------------------------------+ +-----------+------------------------------------------------------------+ | nova | Value | +-----------+------------------------------------------------------------+ | id | e37186d38b8e4b81a54de34e73b43f34 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | url | http://controller:8774/v2/ae7a98326b9c455588edd2656d723b9d | +-----------+------------------------------------------------------------+ +-----------+----------------------------------+ | glance | Value | +-----------+----------------------------------+ | id | 41ad39f6c6444b7d8fd8318c18ae0043 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | url | http://controller:9292 | +-----------+----------------------------------+ +-----------+----------------------------------+ | glance | Value | +-----------+----------------------------------+ | id | 50ecc4ce62724e319f4fae3861e50f7d | | interface | internal | | region | RegionOne | | region_id | RegionOne | | url | http://controller:9292 | +-----------+----------------------------------+ +-----------+----------------------------------+ | glance | Value | +-----------+----------------------------------+ | id | 7d3df077a20b4461a372269f603b7516 | | interface | public | | region | RegionOne | | region_id | RegionOne | | url | http://controller:9292 | +-----------+----------------------------------+ +-----------+----------------------------------+ | keystone | Value | +-----------+----------------------------------+ | id | 88150c2fdc9d406c9b25113701248192 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | url | http://controller:5000/v2.0 | +-----------+----------------------------------+ +-----------+----------------------------------+ | keystone | Value | +-----------+----------------------------------+ | id | cecab58c0f024d95b36a4ffa3e8d81e1 | | interface | public | | region | RegionOne | | region_id | RegionOne | | url | http://controller:5000/v2.0 | +-----------+----------------------------------+ +-----------+----------------------------------+ | keystone | Value | +-----------+----------------------------------+ | id | fc90391ae7cd4216aca070042654e424 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | url | http://controller:35357/v2.0 | +-----------+----------------------------------+
列出镜像服务目录的镜像,验证镜像服务的连通性:
$ nova image-list +--------------------------------------+--------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+--------+--------+--------+ | 38047887-61a7-41ea-9b49-27987d5e8bb9 | cirros | ACTIVE | | +--------------------------------------+--------+--------+--------+