分享

openstack Juno neutron必读1:在Mac上部署Juno版本OpenStack 四节点环境介绍

nettman 发表于 2015-2-25 20:21:58 [显示全部楼层] 只看大图 回帖奖励 阅读模式 关闭右栏 5 27181
本帖最后由 nettman 于 2015-2-25 21:38 编辑

问题导读

1.CPU不支持针对虚机的硬件加速,因此配置libvirt该如何配置?
2.如何创建网络、子网及路由?








前沿
经过一段时间的折腾,终于在自己的Mac上装好了Juno版本的四节点环境。这过程中,花了大量的时间,碰到了许多问题,学到不少知识,折腾过不少其实不需要折腾的东西,本文试着来对这过程做个总结。

1. 初始环境

1.jpg
说明:
1. VirtualBox Ubuntu 安装:(VirtualBox网卡配置可见 http://www.cnblogs.com/sammyliu/p/4137772.html)
安装的是14.04 server 版本,装好后:
(1)修改sources.list来使用厦大的源
(2)运行:
    echo "deb http://ubuntu-cloud.archive.canonical.com/ubuntu"  "trusty-updates/juno main" > /etc/apt/sources.list.d/cloudarchive-juno.list
    apt-get update
    apt-get upgrade
    add-apt-repository cloud-archive:juno
    apt-get dist-upgrade

2. 我的环境中,最缺乏的是内存,偏偏OpenStack很占用内存,特别是Controller节点,MySql和RabbitMQ都占了1G多的内存,所以每个节点的内存都是看着差不多刚刚好来分配的。同时也感叹下VirtualBox的好用,Ubuntu配置很方便,启动非常迅速,可能也是Mac使用SSD的缘故。
3。设置management 网络能访问外网,是为了安装方便。
4. 为什么storage network和VM traffic network用同一个网络,下文会有说明。

配置好了初始网络环境,接下来就是安装各个OpenStack node了。


2. 安装

安装OpenStack是按照Juno的正式安装文档进行的,过程不再重复,安装结果见下图:
2.jpg



3.配置

3.1 Cinder 配置

配置基本上是参考标准官方文档,详细过程不再重复。下面就一些重要的配置做下说明:
1. 使用volume group,Cinder会在该volume group里面创建virtual volume来创建volume。
root@block1:/home/s1# vgs
  VG             #PV #LV #SN Attr   VSize VFree
  cinder-volumes   1   2   0 wz--n- 5.34g 3.36g
  system           1   2   0 wz--n- 3.72g    0

2. 通过LVMISCSIDriver来使用本地硬盘,使用tgtadm做为iscsi helper。
默认的LVMISCSIDriver没有提供接口来让用户配置iSCSI使用的IP地址,所以它就自动使用management network的网卡来建立iSCSI session了。其它的一些Vendor提供的iSCSI实现可以使用其它的网卡,因此storage network可以与management network分离。
root@compute1:/home/s1# iscsiadm -m session
tcp: [2] 192.168.1.24:3260,1 iqn.2010-10.org.openstack:volume-870d464f-5c2f-4220-869f-92039f766758
tcp: [3] 192.168.1.24:3260,1 iqn.2010-10.org.openstack:volume-15d76291-d1a7-423f-82f0-14bd52652a7c

3. 没有使用multiple backend,所以不需要使用volume type。




3.2 Nova配置

1. 因为机器的CPU不支持针对虚机的硬件加速,因此配置libvirt使用qumu。

3.3 Neutron配置

1. 在nova中配置使用neutron,而不是默认的nova-network。

network_api_class = nova.network.neutronv2.api.APIsecurity_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver

2. 在ml2配置中,使用flat,gre,和 openvswitch。


4. 运行

0.确保所有的service都正常运行
root@controller:/home/s1# cinder service-list
+------------------+------------+------+---------+-------+----------------------------+-----------------+
|      Binary      |    Host    | Zone |  Status | State |         Updated_at         | Disabled Reason |
+------------------+------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | controller | nova | enabled |   up  | 2014-12-28T16:00:28.000000 |       None      |
|  cinder-volume   |   block1   | nova | enabled |   up  | 2014-12-28T16:00:28.000000 |       None      |
|  cinder-volume   | controller | nova | enabled |  down | 2014-12-28T14:25:29.000000 |       None      |
+------------------+------------+------+---------+-------+----------------------------+-----------------+

root@controller:/home/s1# nova service-list
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary           | Host       | Zone     | Status  | State | Updated_at                 | Disabled Reason |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 1  | nova-cert            | controller | internal | enabled | up    | 2014-12-28T16:00:45.000000 | -               |
| 2  | nova-consoleauth | controller | internal | enabled | up    | 2014-12-28T16:00:46.000000 | -               |
| 3  | nova-scheduler    | controller | internal | enabled | up    | 2014-12-28T16:00:45.000000 | -               |
| 4  | nova-conductor   | controller | internal | enabled | up    | 2014-12-28T16:00:43.000000 | -               |
| 5  | nova-compute     | compute1   | nova   | enabled | up    | 2014-12-28T16:00:42.000000 | -               |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+

root@controller:/home/s1# neutron agent-list
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| id                                   | agent_type         | host     | alive | admin_state_up | binary                    |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| 262b412c-0c3c-446d-8e9f-313a09970a8b | Open vSwitch agent | compute1 | :-)   | True           | neutron-openvswitch-agent |
| 3c7067be-6711-4479-8f64-7162a889feb1 | Metadata agent        | network  | :-)    | True           | neutron-metadata-agent    |
| 465b0881-dcb3-4adc-9df3-3035fca02661 | DHCP agent             | network  | :-)     | True           | neutron-dhcp-agent        |
| 79fbacd2-5b08-4b34-b252-d0094d2b99fd | Open vSwitch agent | network  | :-)    | True           | neutron-openvswitch-agent |
| bc276c9d-63c5-4918-86c9-fe83edc31901 | L3 agent                  | network  | :-)    | True           | neutron-l3-agent          |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+

1. 因为资源有限,创建一个比m1.tiny更少系统要求的flavor tiny:
root@controller:/home/s1# nova flavor-list
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID                                   | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1                                    | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2                                    | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3                                    | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4                                    | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5                                    | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
| a0317e03-d265-4dd3-a9e4-275a2b25c100 | tiny      | 300       | 1    | 0         |      | 1     | 1.0         | True      |
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
2. 创建neutron 网络

root@controller:/home/s1# neutron net-list
+--------------------------------------+----------+-----------------------------------------------------+
| id                                   | name     | subnets                                             |
+--------------------------------------+----------+-----------------------------------------------------+
| 2e068976-92b2-4a50-bbcb-14b70d4195af | ext-net     | a04711a2-0917-4d1b-9f93-cc2691c22517 192.168.1.0/24 |
| 0a4cd030-d951-401a-8202-937b788bea43 | demo-net  | 08b53624-63a7-4c99-97b0-c8bae3b3cbce 10.0.1.0/24    |
|                                                               | demo-net2  |5598bdf9-2de4-4a4e-9054-2070102e0f1f 10.0.0.0/24    |
+--------------------------------------+----------+-----------------------------------------------------+

root@controller:/home/s1# neutron subnet-list
+--------------------------------------+--------------+----------------+----------------------------------------------------+
| id                                   | name         | cidr           | allocation_pools                                   |
+--------------------------------------+--------------+----------------+----------------------------------------------------+
| a04711a2-0917-4d1b-9f93-cc2691c22517 | ext-subnet   | 192.168.1.0/24 | {"start": "192.168.1.100", "end": "192.168.1.200"} |
| 08b53624-63a7-4c99-97b0-c8bae3b3cbce | demo-subnet  | 10.0.1.0/24    | {"start": "10.0.1.2", "end": "10.0.1.254"}         |
| 5598bdf9-2de4-4a4e-9054-2070102e0f1f | demo-subnet2 | 10.0.0.0/24    | {"start": "10.0.0.2", "end": "10.0.0.254"}         |
+--------------------------------------+--------------+----------------+----------------------------------------------------+
root@controller:/home/s1# neutron router-list
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| id                                   | name        | external_gateway_info                                                                                                                                                                     | distributed | ha    |
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| 9ba04071-f32b-435e-8f44-e32936568102 | demo-router | {"network_id": "2e068976-92b2-4a50-bbcb-14b70d4195af", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "a04711a2-0917-4d1b-9f93-cc2691c22517", "ip_address": "192.168.1.100"}]} | False       | False |
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+

3. 创建volume

root@controller:/home/s1# cinder list
+--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
|                  ID                  | Status | Display Name | Size | Volume Type | Bootable |             Attached to              |
+--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
| 15d76291-d1a7-423f-82f0-14bd52652a7c | in-use |    vol22     |  1   |     None    |   true   | 9ff3776b-6835-4a4e-8b11-b440591ca9b9 |
| 870d464f-5c2f-4220-869f-92039f766758 | in-use |    vol33     |  1   |     None    |   true   | 20c011e1-de8f-4ac8-ac6a-5ba0f9dd9b42 |
+--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
3.jpg

4. 从volume创建虚机

4.jpg

5. 检查虚机
1. VM可使用
5.jpg

2. VM可以互相访问
6.jpg

3. 虚机可以访问外网

7.jpg

6. 创建虚机后的网络
8.jpg





5. 遇到过的问题及解决办法


5.1 Ubuntu安装失败

现象:VirtualBox无法辨识ubuntu iso文件

原因:iso文件有问题,需要重新下载iso文件,注意确保下载的iso文件的md5值和服务器上iso的md5值相同,不同则表示下载有问题。

5.2 创建虚机失败

日志:Filter RamFilter returned 0 hosts

原因:nova-scheduler找不到符合flavor要求的host来创建虚机

解决:减小flavor要求

5.3 虚机无法启动
console:Boot failed,not a bootable disk。No bootable device。
原因:启动虚机的volume的image不含boot loader。
解决:测试目的的话,可从http://download.cirros-cloud.net/0.3.2/下载image,比如cirros-0.3.2-x86_64-disk.img

5.4 虚机build失败
日志:
BuildAbortException: Build of instance 66fbb471-21a9-4f45-9ca7-37a6e4606179 aborted: Failed to allocate the network(s), not rescheduling.
RemoteError: Remote error: OperationalError (OperationalError) (1048, “Column 'instance_uuid' cannot be null”)
原因:nova更新数据库表instance_extra失败。开了一个bug给OpenStack,https://bugs.launchpad.net/nova/+bug/1405741,但是还没有人理我。
解决:修改code,注释掉出错地方的代码,重新运行,结果是虚机的状态一直停留在building状态,可手动修改数据库记录将其变为active。
update instances set vm_state='active' where uuid='9ff3776b-6835-4a4e-8b11-b440591ca9b9';



6. 感想

1.学习OpenStack,得从搭环境开始,devstack是不够的。

2. open source的产品的一大好处是可以按需修改代码

3. 在config文件中设置debug=True,可以得到最详细的日志,编译调试。

4. 免费的VirtualBox比收费的Parallels Desktop好用,详见我的另一篇blog: http://www.cnblogs.com/sammyliu/p/4149005.html

5. OpenStack要学的东西很多。。。

6. 其它的想到再加过来吧 TBD


同时补充:
对于创建网络、子网,admin创建的外网需要共享,才能被其它租户网络所用,详细参考
admin创建外部网络的子网,其他租户看不到子网,是怎么回事

相关内容


openstack Juno neutron必读1:在Mac上部署Juno版本OpenStack 四节点环境介绍
openstack Juno neutron必读2:Neutron 深入学习之 OVS + GRE 之 Compute node、ne...
openstack Juno neutron必读3:Neutron 深入探索之 OVS + GRE 之 完整网络流程 篇




加微信w3aboutyun,可拉入技术爱好者群

已有(5)人评论

跳转到指定楼层
lf61nol 发表于 2015-2-26 12:18:39
回复

使用道具 举报

cylboy 发表于 2015-2-27 17:09:24
楼主,您好!请问是在一台MAC物理机上用virtualbox虚拟了四个系统安装4个节点吗?
回复

使用道具 举报

轨迹 发表于 2015-4-7 16:00:22
楼主可以详细说一下neutron网络部分的配置么?我照着你的做还是失败了
回复

使用道具 举报

Ankse 发表于 2015-4-19 23:04:25
关于虚拟机启动失败
nova-compute.log:2015-04-19 22:47:41.000 1874 TRACE nova.compute.manager [instance: dd68d637-9dcc-4ed2-bc64-2c100a0f806f] BuildAbortException: Build of instance dd68d637-9dcc-4ed2-bc64-2c100a0f806f aborted: Failed to allocate the network(s), not rescheduling.

解决方法找到稍微简单点的
root@compute1:~# vim /etc/nova/nova.conf
[DEFAULT]
vif_plugging_is_fatal = False
vif_plugging_timeout = 0

service nova-compute restart
回复

使用道具 举报

yudar1024 发表于 2015-7-22 09:45:39
virtualbox的网络配置失效了,能更新一下嘛?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条