學習OpenStack之(5):在Mac上部署Juno版本OpenStack 四節點環境

來源:互聯網
上載者:User

標籤:

0. 前沿

經過一段時間的折騰,終於在自己的Mac上裝好了Juno版本的四節點環境。這過程中,花了大量的時間,碰到了許多問題,學到不少知識,折騰過不少其實不需要折騰的東西,本文試著來對這過程做個總結。

1. 初始環境

說明:

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的正式安裝文檔進行的,過程不再重複,安裝結果見:

3.配置

配置基本上是參考標準官方文檔,詳細過程不再重複。下面就一些重要的配置做下說明:

3.1 Cinder 配置

1. 使用volume group,Cinder會在該volume group裡面建立virtual volume來建立volume。

[email protected]:/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分離。

[email protected]:/home/s1# iscsiadm -m session
tcp: [2] 192.168.1.24:3260,1 iqn.2010-10.org.openstack:volume-870d464f-5c2f-4220-869f-92039f766758tcp: [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都正常運行

[email protected]:/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      |+------------------+------------+------+---------+-------+----------------------------+-----------------+ [email protected]:/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 | -               |+----+------------------+------------+----------+---------+-------+----------------------------+-----------------+ [email protected]:/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:

[email protected]:/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 網路 [email protected]:/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    |+--------------------------------------+----------+-----------------------------------------------------+ [email protected]:/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"}         |
+--------------------------------------+--------------+----------------+----------------------------------------------------+[email protected]:/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 [email protected]:/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/4149005.html

5. OpenStack要學的東西很多。。。

6. 其它的想到再加過來吧 TBD

 

學習OpenStack之(5):在Mac上部署Juno版本OpenStack 四節點環境

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.