博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
openstack部署之nova
阅读量:5835 次
发布时间:2019-06-18

本文共 15577 字,大约阅读时间需要 51 分钟。

简介

  本次部署nova组件,分别部署nova和nova-compute,nova部署到controller节点,nova-compute部署到另一台设备,这样部署说明nova-compute是可以部署多个进行横向扩展的。下边开始部署nova组件,controller节点IP 192.168.46.130,nova-compute节点IP 192.168.46.133

部署controller nova

创建数据库

  与其他组件的部署一样,首先需要创建nova需要的数据库,操作如下:

$ mysql -u root -p

  创建nova_api、nova、nova_cell0数据库

MariaDB [(none)]> CREATE DATABASE nova_api;MariaDB [(none)]> CREATE DATABASE nova;MariaDB [(none)]> CREATE DATABASE nova_cell0;

  授权数据库

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';

组件部署

  首先设置所需要的环境变量,这个在前边组件的部署中有过说明:

[root@localhost ~]# source admin-openstack.sh

1、创建nova user

$ openstack user create --domain default --password-prompt novaUser Password:Repeat User Password:+---------------------+----------------------------------+| Field               | Value                            |+---------------------+----------------------------------+| domain_id           | default                          || enabled             | True                             || id                  | 8a7dbf5279404537b1c7b86c033620fe || name                | nova                             || options             | {}                               || password_expires_at | None                             |+---------------------+----------------------------------+

2、为nova用户设置admin角色和项目

$ openstack role add --project service --user nova admin

3、注册服务

$ openstack service create --name nova --description "OpenStack Compute" compute+-------------+----------------------------------+| Field       | Value                            |+-------------+----------------------------------+| description | OpenStack Compute                || enabled     | True                             || id          | 060d59eac51b4594815603d75a00aba2 || name        | nova                             || type        | compute                          |+-------------+----------------------------------+

4、注册endpoints

$ openstack endpoint create --region RegionOne compute public http://192.168.46.130:8774/v2.1+--------------+-------------------------------------------+| Field        | Value                                     |+--------------+-------------------------------------------+| enabled      | True                                      || id           | 3c1caa473bfe4390a11e7177894bcc7b          || interface    | public                                    || region       | RegionOne                                 || region_id    | RegionOne                                 || service_id   | 060d59eac51b4594815603d75a00aba2          || service_name | nova                                      || service_type | compute                                   || url          | http://192.168.46.130:8774/v2.1           |+--------------+-------------------------------------------+$ openstack endpoint create --region RegionOne compute internal http://192.168.46.130:8774/v2.1+--------------+-------------------------------------------+| Field        | Value                                     |+--------------+-------------------------------------------+| enabled      | True                                      || id           | e3c918de680746a586eac1f2d9bc10ab          || interface    | internal                                  || region       | RegionOne                                 || region_id    | RegionOne                                 || service_id   | 060d59eac51b4594815603d75a00aba2          || service_name | nova                                      || service_type | compute                                   || url          | http://192.168.46.130:8774/v2.1           |+--------------+-------------------------------------------+$ openstack endpoint create --region RegionOne compute admin http://192.168.46.130:8774/v2.1+--------------+-------------------------------------------+| Field        | Value                                     |+--------------+-------------------------------------------+| enabled      | True                                      || id           | 38f7af91666a47cfb97b4dc790b94424          || interface    | admin                                     || region       | RegionOne                                 || region_id    | RegionOne                                 || service_id   | 060d59eac51b4594815603d75a00aba2          || service_name | nova                                      || service_type | compute                                   || url          | http://192.168.46.130:8774/v2.1           |+--------------+-------------------------------------------+

5、创建Placement service

$ openstack user create --domain default --password-prompt placementUser Password:Repeat User Password:+---------------------+----------------------------------+| Field               | Value                            |+---------------------+----------------------------------+| domain_id           | default                          || enabled             | True                             || id                  | fa742015a6494a949f67629884fc7ec8 || name                | placement                        || options             | {}                               || password_expires_at | None                             |+---------------------+----------------------------------+

6、为Placement service添加项目和角色

$ openstack role add --project service --user placement admin

7、注册Placement服务

$ openstack service create --name placement --description "Placement API" placement+-------------+----------------------------------+| Field       | Value                            |+-------------+----------------------------------+| description | Placement API                    || enabled     | True                             || id          | 2d1a27022e6e4185b86adac4444c495f || name        | placement                        || type        | placement                        |+-------------+----------------------------------+

8、为Placement服务注册endpoints

$ openstack endpoint create --region RegionOne placement public http://192.168.46.130:8778+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | 2b1b2637908b4137a9c2e0470487cbc0 || interface    | public                           || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 2d1a27022e6e4185b86adac4444c495f || service_name | placement                        || service_type | placement                        || url          | http://192.168.46.130:8778       |+--------------+----------------------------------+$ openstack endpoint create --region RegionOne placement internal http://192.168.46.130:8778+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | 02bcda9a150a4bd7993ff4879df971ab || interface    | internal                         || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 2d1a27022e6e4185b86adac4444c495f || service_name | placement                        || service_type | placement                        || url          | http://192.168.46.130:8778       |+--------------+----------------------------------+$ openstack endpoint create --region RegionOne placement admin http://192.168.46.130:8778+--------------+----------------------------------+| Field        | Value                            |+--------------+----------------------------------+| enabled      | True                             || id           | 3d71177b9e0f406f98cbff198d74b182 || interface    | admin                            || region       | RegionOne                        || region_id    | RegionOne                        || service_id   | 2d1a27022e6e4185b86adac4444c495f || service_name | placement                        || service_type | placement                        || url          | http://192.168.46.130:8778       |+--------------+----------------------------------+

配置组件

  • 安装组件包
# yum install openstack-nova-api openstack-nova-conductor \  openstack-nova-console openstack-nova-novncproxy \  openstack-nova-scheduler openstack-nova-placement-api
  • 修改/etc/nova/nova.conf配置文件

1、设置对外的API

[DEFAULT]# ...enabled_apis = osapi_compute,metadata

2、配置数据库

[api_database]# ...connection = mysql+pymysql://nova:nova@192.168.46.130/nova_api[database]# ...connection = mysql+pymysql://nova:nova@192.168.46.130/nova

3、配置RabbitMQ

[DEFAULT]# ...transport_url = rabbit://openstack:openstack@192.168.46.130

4、打开keystone认证和配置认证token

[api]# ...auth_strategy = keystone[keystone_authtoken]auth_uri = http://192.168.46.130:5000auth_url = http://192.168.46.130:35357memcached_servers = 192.168.46.130:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = novapassword = nova

5、关闭防火墙配置

[DEFAULT]# ...use_neutron = Truefirewall_driver = nova.virt.firewall.NoopFirewallDriver

6、vnc配置

[vnc]enabled = true# ...vncserver_listen = 192.168.46.130vncserver_proxyclient_address = 192.168.46.130

7、配置本地镜像服务API

[glance]# ...api_servers= http://192.168.46.130:9292

8、锁文件路径

[oslo_concurrency]# ...lock_path = /var/lib/nova/tmp

9、配置Placement API

[placement]os_region_name = RegionOneproject_domain_name = Defaultproject_name = serviceauth_type = passworduser_domain_name = Defaultauth_url = http://192.168.46.130:35357/v3username = placementpassword = placement

10、修改当前版本bug,编辑/etc/httpd/conf.d/00-nova-placement-api.conf文件,增加以下代码

= 2.4> Require all granted
< 2.4> Order allow,deny Allow from all

11、启动httpd服务

# systemctl restart httpd

最后的配置

1、同步cell0数据库

# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova

2、创建cell1

# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova109e1d4b-536a-40d0-83c6-5f121b82b650

3、同步nova数据库

# su -s /bin/sh -c "nova-manage db sync" nova

4、验证cell0和cell1

# nova-manage cell_v2 list_cells+-------+--------------------------------------+| Name  | UUID                                 |+-------+--------------------------------------+| cell1 | 109e1d4b-536a-40d0-83c6-5f121b82b650 || cell0 | 00000000-0000-0000-0000-000000000000 |+-------+--------------------------------------+

配置服务自动启动

# 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

  

部署compute node

1、安装包

# yum install openstack-nova-compute

2、编辑/etc/nova/nova.conf配置文件

  • 打开API
[DEFAULT]# ...enabled_apis = osapi_compute,metadata
  • 配置RabbitMQ
[DEFAULT]# ...transport_url= rabbit://openstack:openstack@192.168.46.130
  • 配置keystone认证
[api]# ...auth_strategy = keystone[keystone_authtoken]auth_uri = http://192.168.46.130:5000auth_url = http://192.168.46.130:35357memcached_servers = 192.168.46.130:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = novapassword = nova
  • 关闭防火墙驱动
[DEFAULT]# ...use_neutron = Truefirewall_driver = nova.virt.firewall.NoopFirewallDriver
  • vnc配置
[vnc]# ...enabled = Truevncserver_listen= 192.168.46.133vncserver_proxyclient_address= 192.168.46.133novncproxy_base_url=http://192.168.46.130:6080/vnc_auto.html
  • 配置Glance服务API
[glance]# ...api_servers= http://192.168.46.130:9292
  • 锁文件路径
[oslo_concurrency]# ...lock_path = /var/lib/nova/tmp
  • 配置Placement API
[placement]os_region_name = RegionOneproject_domain_name = Defaultproject_name = serviceauth_type = passworduser_domain_name = Defaultauth_url = http://192.168.46.130:35357/v3username = placementpassword = placement
  • 配置libvirt,在生产环境中一般使用kvm
[libvirt]# ...virt_type = qemu
  • 启动服务
# systemctl enable libvirtd.service openstack-nova-compute.service  //设置自动启动# systemctl start libvirtd.service openstack-nova-compute.service   //启动服务

问题记录

在以上执行启动服务时,命令行长时间卡住,一般说明连接RabbitMQ失败,可以在/var/log/nova/nova-compute.log文件中查看详细报错,报错如下:

2019-05-11 12:02:57.432 5308 ERROR oslo.messaging._drivers.impl_rabbit [req-503bd955-7075-44a8-b553-f70b9437ff3b - - - - -] [84517112-2f15-4dfa-b9f0-e195a80a67c2] AMQP server on 192.168.46.130:5672 is unreachable: [Errno 113] EHOSTUNREACH. Trying again in 32 seconds.: error: [Errno 113] EHOSTUNREACH2019-05-11 12:03:29.606 5308 ERROR oslo.messaging._drivers.impl_rabbit [req-503bd955-7075-44a8-b553-f70b9437ff3b - - - - -] [84517112-2f15-4dfa-b9f0-e195a80a67c2] AMQP server on 192.168.46.130:5672 is unreachable: [Errno 113] EHOSTUNREACH. Trying again in 32 seconds.: error: [Errno 113] EHOSTUNREACH2019-05-11 12:04:01.792 5308 ERROR oslo.messaging._drivers.impl_rabbit [req-503bd955-7075-44a8-b553-f70b9437ff3b - - - - -] [84517112-2f15-4dfa-b9f0-e195a80a67c2] AMQP server on 192.168.46.130:5672 is unreachable: [Errno 113] EHOSTUNREACH. Trying again in 32 seconds.: error: [Errno 113] EHOSTUNREACH

以上错误说明nova-compute节点连接controller节点的RabbitMQ失败了,一般原因是controller上配置了iptables,需要设置iptables把RabbitMQ的5672端口打开。设置如下:

# iptables -I INPUT -p tcp --dport 5672 -j ACCEPT#添加规则# service iptables save#保存设置# service iptables restart# 重启iptables,生效规则

  

添加compute node到cell数据库

  •  在controller node上查看,确定在数据库中有nova-compute
[root@localhost ~]# source admin-openstack.sh[root@localhost ~]# openstack compute service list+----+------------------+-----------------------+----------+---------+-------+----------------------------+| ID | Binary           | Host                  | Zone     | Status  | State | Updated At                 |+----+------------------+-----------------------+----------+---------+-------+----------------------------+|  1 | nova-consoleauth | localhost.localdomain | internal | enabled | up    | 2019-05-12T10:36:09.000000 ||  2 | nova-conductor   | localhost.localdomain | internal | enabled | up    | 2019-05-12T10:36:09.000000 ||  3 | nova-scheduler   | localhost.localdomain | internal | enabled | up    | 2019-05-12T10:36:10.000000 ||  8 | nova-compute     | node2                 | nova     | enabled | up    | 2019-05-12T10:36:07.000000 |+----+------------------+-----------------------+----------+---------+-------+----------------------------+
  •  发现compute node,每次添加新的compute nodes时,都需要在controller node上执行nova-manage cell_v2 discover_hosts注册新的compute nodes
# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" novaFound 2 cell mappings.Skipping cell0 since it does not contain hosts.Getting compute nodes from cell 'cell1': ad5a5985-a719-4567-98d8-8d148aaae4bcFound 1 computes in cell: ad5a5985-a719-4567-98d8-8d148aaae4bcChecking host mapping for compute host 'compute': fe58ddc1-1d65-4f87-9456-bc040dc106b3Creating host mapping for compute host 'compute': fe58ddc1-1d65-4f87-9456-bc040dc106b3

  

  通过以上的组件部署,nova-compute可以有多个,并且当配置完一个nova-compute时,其他的与此类似。

 

转载于:https://www.cnblogs.com/baihl/p/10828764.html

你可能感兴趣的文章
FZU - 1688 Binary land
查看>>
Spring 3.1.0 Hibernate 3.0 Eclipse Spring WEB例子
查看>>
转换流,Properties 集合
查看>>
bootstrap列排序
查看>>
redis 常用操作
查看>>
如何用ABP框架快速完成项目(9) - 用ABP一个人快速完成项目(5) - 不要执着于设计模式和DDD理论,避免原教旨主义...
查看>>
用户交互
查看>>
【ubuntu 修改root密码】
查看>>
libkyototycoon.so.2: cannot open shared object file: No such file
查看>>
ASP.Net 后台发回错误
查看>>
systick定时器
查看>>
【微服务架构与实践】读后感
查看>>
使用Unicode写文本文件:一个简单类的示例
查看>>
阶乘素因子分解
查看>>
UVA-10212 The Last Non-zero Digit. 分解质因子+容斥定理
查看>>
80端口被占用时的终极解决方法
查看>>
NG-ZORRO 使用相关
查看>>
遗传算法
查看>>
Codeforces 1097G
查看>>
MySQL 5.7 innodb全文索引
查看>>