openstack學習筆記一__openstack

來源:互聯網
上載者:User
一. OpenStack概要

OpenStack既是一個社區,也是一個項目和一個開源軟體,它提供了一個部署雲的操作平台或工具集。其宗旨在於,協助組織運行為虛擬計算或儲存服務的雲,為公用雲端、私人雲端,也為大雲、小雲提供可擴充的、靈活的雲端運算。
1.以下是5個重要組成部分

nova--計算服務 swift--儲存服務 glance--鏡像服務 keystone--認證服務 horizon--UI服務 OpenStack Compute (Nova)是一套控制器,用於為單個使用者或使用群組啟動虛擬機器執行個體。它同樣能夠用於為包含著多個執行個體的特定項目設定網路
OpenStack Object Storage Service(Swift)是一套用於在大規模可擴充系統中通過內建冗餘及容錯機制實現Object Storage Service的系統。這些對象能夠通過一個REST API或是像Cyberduck這樣可以對接Object Storage ServiceAPI的用戶端加以恢複 OpenStack鏡像服務 (Glance)是一套虛擬機器鏡像尋找及檢索系統

OpenStack Nova 使用 nova-volume 服務來管理儲存,實現和 Amazon 的 Elastic Block Storage (EBS) 不同,nova-volume 提供的是一種基於 Linux LVM 的 iSCSI 解決方案










二. swift(虛擬機器鏡像 圖片儲存 郵件儲存 存檔備份) http://www.programmer.com.cn/12403/
Swift主要有三個組成部分:Proxy Server、Storage Server和Consistency Server
其中Storage和Consistency服務均允許在Storage Node上。Auth認證服務目前已從Swift中剝離出來,使用OpenStack的認證服務Keystone,目的在於實現統一OpenStack各個項目間的認證管理。



Proxy Server
Server是提供Swift API的伺服器處理序,負責Swift其餘組件間的相互連信。對於每個用戶端的請求,它將在Ring中查詢Account、Container或Object的位置,並且相應地轉寄請求。Proxy提供了Rest-full API,並且符合標準的HTTP協議規範,這使得開發人員可以快捷構建定製的Client與Swift互動 Storage Server

Storage Server提供了磁碟裝置上的儲存服務。在Swift中有三類儲存伺服器:Account、Container和Object。其中Container伺服器負責處理Object的列表,Container伺服器並不知道對象存放位置,只知道指定Container裡存的哪些Object。這些Object資訊以sqlite資料庫檔案的形式儲存。Container伺服器也做一些跟蹤統計,例如Object的總數、Container的使用方式
Consistency Servers

在磁碟上儲存資料並向外提供Rest-ful API並不是難以解決的問題,最主要的問題在於故障處理。Swift的Consistency Servers的目的是尋找並解決由資料損毀和硬體故障引起的錯誤。主要存在三個Server:Auditor、Updater和Replicator。 Auditor運行在每個Swift伺服器的後台持續地掃描磁碟來檢測對象、Container和帳號的完整性。如果探索資料損壞,Auditor就會將該檔案移動到隔離地區,然後由Replicator負責用一個完好的拷貝來替代該資料。圖2給出了隔離對象的處理流圖。 在系統高負荷或者發生故障的情況下,Container或帳號中的資料不會被立即更新。如果更新失敗,該次更新在本地檔案系統上會被排入佇列,然後Updaters會繼續處理這些失敗了的更新工作,其中由Account Updater和Container Updater分別負責Account和Object列表的更新。 Replicator的功能是處理資料的存放位置是否正確並且保持資料的合理拷貝數,它的設計目的是Swift伺服器在面臨如網路中斷或者磁碟機故障等臨時性故障情況時可以保持系統的一致性。

1.swift源碼分析--服務啟動
swift-init main start執行swift初始化工作(bin/swift-init)
commands = dict(Manager.list_commands()).keys() 擷取所有可公開訪問的命令
manager = Manager(servers, run_dir=options.run_dir) Manager管理各個server執行操作的類

commands = ['status', 'start', 'force-reload', 'stop', 'no-wait', 'no-daemon', 'reload', 'shutdown', 'restart', 'once']

servers = ['swift-init', 'main']
server_names = ['proxy-server', 'account-server', 'container-server', 'object-server'],這是swift四個服務的名稱
for name in server_names:
      self.servers.add(Server(name, run_dir))

command = start

options = {'run_dir': '/var/run/swift', 'daemon': True, 'verbose': False, 'number': 0, 'kill_wait': 15, 'graceful': False, 'wait': True, 'once': False} status = manager.run_command(command, **options. __dict__)

這個方法中將會依次啟動servers指定的服務,即servers = ['proxy-server', 'account-server', 'container-server', 'object-server'];
def start(self, **kwargs)
for server in self.servers:               server.launch(**kwargs)


一. Nove Scheduler

1.request_spce

{   u'num_instances': 1,   u'block_device_mapping': [ {          u'instance_uuid': u'c99560fa-6580-4b5f-a94e-28e81db75d81',          u'guest_format': None,          u'boot_index': 0,          u'delete_on_termination': True,          u'no_device': None,          u'connection_info': None,          u'snapshot_id': None,          u'device_name': None,          u'disk_bus': None,          u'image_id': u'a0247584-9a5e-4d43-861a-e4a78f708d3b',          u'source_type': u'image',          u'device_type': u'disk',          u'volume_id': None,          u'destination_type': u'local',          u'volume_size': None       }],   u'image': {         u'status': u'active',          u'name': u'F17-x86_64-cfntools',          u'deleted': False,          u'container_format': u'bare',          u'created_at': u'2014-08-19T07:03:32.000000',          u'disk_format': u'qcow2',          u'updated_at': u'2014-08-19T07:05:38.000000',          u'id': u'a0247584-9a5e-4d43-861a-e4a78f708d3b',          u'owner': u'eca87d47c0fe4a05bc4d24802658fa10',          u'min_ram': 0,          u'checksum': u'afab0f79bac770d61d24b4d0560b5f70',          u'min_disk': 0,          u'is_public': True,          u'deleted_at': None,          u'properties': {},          u'size': 476704768       },   u'instance_type': {           u'root_gb': 4,          u'name': u'm1.small',          u'ephemeral_gb': 0,          u'memory_mb': 2048,          u'vcpus': 1,          u'extra_specs': {},          u'swap': 0,          u'rxtx_factor': 1.0,          u'flavorid': u'c75e2199-b09e-4e9e-9997-bd6d6676541d',          u'vcpu_weight': None,          u'id': 10      },   u'instance_properties': {         u'vm_state': u'building',          u'availability_zone': u'nova',          u'terminated_at': None,          u'ephemeral_gb': 0,          u'instance_type_id': 10,          u'user_data': None,          u'cleaned': False,          u'vm_mode': None,          u'deleted_at': None,          u'reservation_id': u'r-a58urz33',          u'id': 576,          u'security_groups': [],          u'disable_terminate': False,          u'display_name': u'CCCC',          u'uuid': u'c99560fa-6580-4b5f-a94e-28e81db75d81',          u'default_swap_device': None,          u'info_cache': {                   u'instance_uuid': u'c99560fa-6580-4b5f-a94e-28e81db75d81',                 u'deleted': False,                 u'created_at': u'2014-08-22T03:47:00.000000',                 u'updated_at': None,                 u'network_info': [],                 u'deleted_at': None           },          u'hostname': u'cccc',          u'launched_on': None,          u'display_description': u'CCCC',          u'key_data': None,          u'kernel_id': u'',          u'power_state': 0,          u'default_ephemeral_device': None,          u'progress': 0,          u'project_id': u'eca87d47c0fe4a05bc4d24802658fa10',          u'launched_at': None,          u'scheduled_at': None,          u'node': None,          u'ramdisk_id': u'',          u'access_ip_v6': None,          u'access_ip_v4': None,          u'deleted': False,          u'key_name': None,          u'updated_at': None,          u'host': None,          u'ephemeral_key_uuid': None,          u'architecture': None,          u'user_id': u'7ae57473c4de4bfa84015a2e73f7182b',          u'system_metadata': {               u'image_min_disk': u'4',                u'instance_type_memory_mb': u'2048',                u'instance_type_swap': u'0',                u'instance_type_vcpu_weight': None,                u'instance_type_root_gb': u'4',                u'instance_type_id': u'10',                u'instance_type_name': u'm1.small',                u'instance_type_ephemeral_gb': u'0',                u'instance_type_rxtx_factor': u'1.0',                u'instance_type_flavorid': u'c75e2199-b09e-4e9e-9997-bd6d6676541d',                u'image_container_format': u'bare',                u'instance_type_vcpus': u'1',                u'image_min_ram': u'0',                u'image_disk_format': u'qcow2',                u'image_base_image_ref': u'a0247584-9a5e-4d43-861a-e4a78f708d3b'         },          u'task_state': u'scheduling',          u'shutdown_terminate': False,          u'cell_name': None,          u'root_gb': 4,          u'locked': False,          u'name': u'instance-00000240',          u'created_at': u'2014-08-22T03:47:00.000000',          u'locked_by': None,          u'launch_index': 0,          u'metadata': {},          u'memory_mb': 2048,          u'vcpus': 1,          u'image_ref': u'a0247584-9a5e-4d43-861a-e4a78f708d3b',          u'root_device_name': None,          u'auto_disk_config': True,          u'os_type': None,          u'config_drive': u''   },    u'security_group': [u'default'],    u'instance_uuids': [u'c99560fa-6580-4b5f-a94e-28e81db75d81']}

2.filter_properties
{   u'instance_type': {       u'memory_mb': 2048,        u'root_gb': 4,        u'deleted_at': None,        u'name': u'm1.small',        u'deleted': 0,        u'created_at': u'2014-08-21T03:27:37.000000',        u'ephemeral_gb': 0,        u'updated_at': None,        u'disabled': False,        u'vcpus': 1,        u'extra_specs': {},        u'swap': 0,        u'rxtx_factor': 1.0,        u'is_public': True,        u'flavorid': u'c75e2199-b09e-4e9e-9997-bd6d6676541d',        u'vcpu_weight': None,        u'id': 10   },    u'scheduler_hints': {} }



2.get_all_host_states()

{"host1":hoststate for host1, "host2":hoststate for host2,...}. 

3.filter_host()
'nova.scheduler.filters.isolated_hosts_filter.IsolatedHostsFilter''nova.scheduler.filters.compute_filter.ComputeFilter''nova.scheduler.filters.availability_zone_filter.AvailabilityZoneFilter''nova.scheduler.filters.ram_filter.RamFilter''nova.scheduler.filters.json_filter.JsonFilter''nova.scheduler.filters.all_hosts_filter.AllHostsFilter''nova.scheduler.filters.core_filter.CoreFilter''nova.scheduler.filters.affinity_filter.AffinityFilter''nova.scheduler.filters.affinity_filter.DifferentHostFilter''nova.scheduler.filters.affinity_filter.SameHostFilter''nova.scheduler.filters.affinity_filter.SimpleCIDRAffinityFilter

4.filter_host()





2.openstack scheduler 
(1) SchedulerManager.run_instance    |    |-->(11) driver.scheduler_run_instance             |             |-->(111) _scheduler(context, request_spec, filter_properties)                       |                       |-->(1111) _setup_instance_group(context, filter_properties)                                  |-->(1112) _get_configuration_options()                                  |-->(1113) populate_filter_properties(request_spec, filter_properties)                                  |-->(1114) self.get_all_host_state(elevated)                                  |          |                                  |          |-->(11141) HostManager.get_all_host_states(self, context)                                  |                                  |-->(1115) HostManager.get_filtered_hosts(hosts, filter_properties, index=num)                                  |-->(1116) HostManager.get_weighed_hosts(hosts, filter_proerties)

(2) HostManager.get_all_host_states(self, context)    |    |-->(21) db.compute_node_get_all(context)             |             |-->(211) compute_node_get_all  [db/sqlalchemy/api.py]                       |                        |-->(2111) select                       |-->(2112) conn.execute                      



                                             
最後. openstack相關網路連結

http://docs.openstack.org/admin-guide-cloud/content/index.html

http://docs.openstack.org/api/openstack-network/2.0/content/

https://wiki.openstack.org/wiki/NeutronDevelopment

https://wiki.openstack.org/wiki/Neutron

http://docs.openstack.org/icehouse/install-guide/install/apt/content/

//swift 開發資料

http://docs.openstack.org/developer/swift/deployment_guide.html

//swift 用戶端

https://github.com/openstack/python-swiftclient

//neutron部落格文章

http://blog.csdn.net/ustc_dylan/article/category/1659861

http://blog.csdn.net/lynn_kong/article/category/1259739/2
http://www.cnblogs.com/feisky/category/391781.html

//////   IBM http://www.ibm.com/developerworks/cn/
http://www.ibm.com/developerworks/cn/cloud/library/1311_zhanghua_openstacknetwork2/index.html


///////////////////////////////////////////////////////////// OpenStack Nova源碼結構  http://wanglianghuaihua.blog.163.com/blog/static/54251531201311190653205/

http://docs.openstack.org/grizzly/openstack-image/content/centos-image.html
NOVA代碼總體結構和資料流向總結
http://openstack.wiaapp.com/?p=177


http://www.aboutyun.com/thread-6307-1-1.html
http://bbs.vmsky.com/forum.php


類圖類圖類圖 http://fossies.org/dox/nova-2013.2.3/classnova_1_1scheduler_1_1filters_1_1BaseHostFilter.html
http://fossies.org/dox/nova-2014.1.1/

/////// 比較全串連 http://blog.csdn.net/bingxx11/article/details/19110031

http://blog.chinaunix.net/uid-20940095-id-4061153.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.