学习OpenStack之(5):在Mac上部署Juno版本OpenStack 四节点环境
0. 前沿 经过一段时间的折腾,终于在自己的Mac上装好了Juno版本的四节点环境。这过程中,花了大量的时间,碰到了许多问题,学到不少知识,折腾过不少其实不需要折腾的东西,本文试着来对这过程做个总结。 1. 初始环境 说明: 1. VirtualBoxUbuntu 安装:(VirtualBox网卡配置可见http://www.cnblogs.com/sammyliu/p/4137772.html) 安装的是14.04 server 版本,装好后: (1)修改 /etc/apt/sources.list来使用厦大的源 deb http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty main restricted universe multiverse deb http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-backports restricted universe multiverse deb http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-proposed main restricted universe multiverse deb http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-security main restricted universe multiverse deb http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-updates main restricted universe multiverse deb-src http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty main restricted universe multiverse deb-src http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-backports main restricted universe multiverse deb-src http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-security main restricted universe multiverse deb-src http://mirrors.xmu.edu.cn/ubuntu/archive/ trusty-updates main restricted universe multiverse 清华大学的源的配置可以参考 https://mirror.tuna.tsinghua.edu.cn/help/ubuntu/. (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了。 备注: (1). Ubuntu 下载地址:http://releases.ubuntu.com/trusty/ (2). Ubuntu 版本以及 Ubuntu 和 OpenStack 版本的对照关系:http://www.ubuntu.com/info/release-end-of-life (3). Ubuntu 对 OpenStack 版本的支持采取 Cloud Archive 方案。每个 LTS (long term support)版本在发布的 image 中就包含了某个 OpenStack 版本(见上图,14.04 中包含了 IceHouse,16.04 包含了 Mitaka),此时用户可以直接安装该版本的 OpenStack。在新的 OpenStack 版本发布后,Ubuntu 会在老的版本中增加对新的 OpenStack 版本的支持。比如,在 14.04 LTS 版本中增加支持Juno 和 Kilo,此时,用户需要手工添加 Cloud Archive 中的该版本的 repository,比如add-apt-repository cloud-archive:juno。更详细的信息,可以参考Configuring Ubuntu Cloud Archive forOpenStack。 (4)ubuntu 的云镜像(cloud image)可以从https://cloud-images.ubuntu.com/下载到。 2. 安装 安装OpenStack是按照Juno的正式安装文档进行的,过程不再重复,安装结果见下图: 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 | +--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+ 4. 从volume创建虚机 5. 检查虚机 1. VM可使用 2. VM可以互相访问 3. 虚机可以访问外网 6. 创建虚机后的网络 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/4139246.html 5. OpenStack要学的东西很多。。。 6. 其它的想到再加过来吧 TBD 本文转自SammyLiu博客园博客,原文链接:http://www.cnblogs.com/sammyliu/p/4190843.html,如需转载请自行联系原作者