0. 前沿
通過一段時間的折騰,終於在本身的Mac上裝好了Juno版本的四節點環境。這過程當中,花了大量的時間,碰到了許多問題,學到很多知識,折騰過很多其實不須要折騰的東西,本文試着來對這過程作個總結。html
1. 初始環境
說明:node
1. VirtualBox Ubuntu 安裝:(VirtualBox網卡配置可見 http://www.cnblogs.com/sammyliu/p/4137772.html)linux
安裝的是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
(2)運行:
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的緣故。ubuntu
3。設置management 網絡能訪問外網,是爲了安裝方便。api
4. 爲何storage network和VM traffic network用同一個網絡,下文會有說明。服務器
配置好了初始網絡環境,接下來就是安裝各個OpenStack node了。 網絡
備註:session
(1). Ubuntu 下載地址:http://releases.ubuntu.com/trusty/tcp
(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。
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。
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