0. 前沿
經過一段時間的折騰,終於在自己的Mac上裝好了Juno版本的四節點環境。這過程中,花了大量的時間,碰到了許多問題,學到不少知識,折騰過不少其實不需要折騰的東西,本文試着來對這過程做個總結。
1. 初始環境
說明:
1. VirtualBox Ubuntu 安裝:(VirtualBox網卡配置可見 http://www.cnblogs.com/sammyliu/p/4137772.html)
安裝的是14.04 server 版本,裝好后:
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
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 for OpenStack。
(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。
VG #PV #LV #SN Attr VSize VFree
cinder-volumes 1 2 0 wz--n- 5.34g 3.36g
2. 通過LVMISCSIDriver來使用本地硬盤,使用tgtadm做為iscsi helper。
默認的LVMISCSIDriver沒有提供接口來讓用戶配置iSCSI使用的IP地址,所以它就自動使用management network的網卡來建立iSCSI session了。其它的一些Vendor提供的iSCSI實現可以使用其它的網卡,因此storage network可以與management network分離。
tcp: [2] 192.168.1.24:3260,1 iqn.2010-10.org.openstack:volume-870d464f-5c2f-4220-869f-92039f766758
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都正常運行
+------------------+------------+------+---------+-------+----------------------------+-----------------+
| 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 |
+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+
| 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 | - |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| 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:
+--------------------------------------+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 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 |
+--------------------------------------+----------+-----------------------------------------------------+
| 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 |
+--------------------------------------+--------------+----------------+----------------------------------------------------+
| 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"} |
+--------------------------------------+--------------+----------------+----------------------------------------------------+
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| 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 |
+--------------------------------------+-------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
+--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
| 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 |






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要求
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