如何使用OpenStack将云主机部署到特定的计算节点上_天生我材必有用-程序员宅基地

技术标签: OpenStack  云计算  

背景

Openstack已经成为主流IaaS云计算平台,国内多数云计算厂商提供的云计算服务底层都是使用的OpenStack。这里我们讲的“如何将实例部署到特定的计算节点上”是基于标准的Openstack平台。

通过Openstack我们可以申请以实例为核心的各类资源。通常情况下,我们只需要指定实例配置,如多少CPU、多大内存、挂多大数据盘、连接什么样的网络即可,Openstack会帮助我们将实例部署到指定的计算节点上。但是,需求往往是多样性的,有时候我们需要将实例部署到特定的计算节点上。例如Openstack资源池中的计算节点同时存在高性能的机架服务器和刀片服务器,我们希望将运行数据库的实例部署到机架服务器上,将运行中间件的实例部署到刀片服务器上。(这里的实例指的是虚拟主机实例,而非数据库实例或中间件实例)

Openstack的nova-scheduler服务可以帮我们实现这样个性化的需求。接下来我将介绍nova-scheduler如何帮助我们实现上述需求的工作原理,并且我会以两个示例分别用两种方法来实现“如何将实例部署到特定的计算节点上”。

原理(Nova Scheduler)

Openstack通过nova-scheduler来实现将实例部署到哪台计算节点上。Filter scheduler 是 nova-scheduler 默认的调度器,调度过程分为两步:

第一步:通过过滤器(filter)选择满足条件的计算节点(运行nova-compute)

第二步:通过权重计算(weighting)选择在最优(权重值最大)的计算节点上创建 Instance。

图 0‑1过滤



图0-2分析权重

 

Filters的调度策略有以下几种:

AggregateCoreFilter

AggregateDiskFilter

AggregateImagePropertiesIsolation

AggregateInstanceExtraSpecsFilter

AggregateIoOpsFilter

AggregateMultiTenancyIsolation

AggregateNumInstancesFilter

AggregateRamFilter

AggregateTypeAffinityFilter

AllHostsFilter

AvailabilityZoneFilter

ComputeCapabilitiesFilter

ComputeFilter

CoreFilter

NUMATopologyFilter

DifferentHostFilter

DiskFilter

GroupAffinityFilter

GroupAntiAffinityFilter

ImagePropertiesFilter

IsolatedHostsFilter

IoOpsFilter

JsonFilter

MetricsFilter

NumInstancesFilter

PciPassthroughFilter

RamFilter

RetryFilter

SameHostFilter

ServerGroupAffinityFilter

ServerGroupAntiAffinityFilter

SimpleCIDRAffinityFilter

TrustedFilter

TypeAffinityFilter

计算服务Filters的策略通过配置nova.conf配置文件中的配置项scheduler_available_filters完成。默认配置的是所有filters。配置如下:

scheduler_available_filters = nova.scheduler.filters.all_filters

这个配置项可以在nova.conf中多次出现,比如你可以通过Python实现自定义的filter(myFilter.MyFilter),只需要在配置文件中增加这个filter即可。

scheduler_available_filters = nova.scheduler.filters.all_filters

scheduler_available_filters = myfilter.MyFilter

详细介绍请参见这里

下面通过两个示例来实现将Openstack的示例部署到指定的主机中。

示例一:通过主机聚合的metadata实现将云主机部署到使用ssd的主机聚合中

假设我在公司的OpenStack环境中创建了一个主机聚合fast-io,这个聚合中,所有的计算节点都连接了SSD类型的本地磁盘。我想创建一个Flavor ssd.large,通过该Flavor申请的云主机全部部署到fast-io这个主机聚合中。

要完成这个任务,我们需要做6步工作:

1.    将AggregateInstanceExtraSpecsFilter添加到nova.conf文件的scheduler_default_filters配置项中,即:

scheduler_default_filters=AggregateInstanceExtraSpecsFilter,RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter

2.    创建一个主机聚合,命名为fast-io,可用域为nova

$ nova aggregate-create fast-io nova

+----+---------+-------------------+-------+----------+

| Id | Name    | Availability Zone | Hosts | Metadata |

+----+---------+-------------------+-------+----------+

| 1  | fast-io | nova              |       |          |

+----+---------+-------------------+-------+----------+

3.    设置集群元数据ssd=true

$ nova aggregate-set-metadata 1 ssd=true

+----+---------+-------------------+-------+-------------------+

| Id | Name    | Availability Zone | Hosts | Metadata          |

+----+---------+-------------------+-------+-------------------+

| 1  | fast-io | nova              | []    | {u'ssd': u'true'} |

+----+---------+-------------------+-------+-------------------+

 

4.    在主机聚合fast-io中增加两台主机node1和node2

$ nova aggregate-add-host 1 node1

+----+---------+-------------------+-----------+-------------------+

| Id | Name    | Availability Zone | Hosts      | Metadata          |

+----+---------+-------------------+------------+-------------------+

| 1  | fast-io | nova              | [u'node1'] | {u'ssd': u'true'} |

+----+---------+-------------------+------------+-------------------+

 

$ nova aggregate-add-host 1 node2

+----+---------+-------------------+---------------------+-------------------+

| Id | Name    | Availability Zone | Hosts                | Metadata          |

+----+---------+-------------------+----------------------+-------------------+

| 1  | fast-io | nova              | [u'node1', u'node2'] | {u'ssd': u'true'} |

+----+---------+-------------------+----------------------+-------------------+

5.    使用novaflavor-create命令创建flavor ssd.large,配置为4个vCPU、8GB内存和80GB root盘。

$ nova flavor-create ssd.large68192804

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

| 6  | ssd.large | 8192      | 80   | 0         |      | 4     | 1.0         | True      |

+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

 

6.    设置flavor ssd.large的元数据为ssd=true

$ nova flavor-key ssd.large set  aggregate_instance_extra_specs:ssd=true

完成以上6步工作后,当用户通过ssd.large这个flavor创建云主机时,nova-scheduler将会把这个云主机调度到元数据为ssd=true这个主机聚合的主机上。

示例二:通过配置flavor的Capability实现将云主机部署到厂商为intel的主机上

某些情况下,我们希望将申请的云主机与某些厂商的主机绑定。例如我想把使用flavor为vendor.intel的云主机全部部署到intel生产的主机上。

首先我们把compute-host-capabilities.json这个文件导入到元数据信息中。

其次我们创建一个flavor vendor.intel,并把元数据指定为cpu.info:vendor=intel。

此时申请flavor为vendor.intel的云主机会自动部署到intel生产的主机上。

compute-host-capabilities.json文件内容:

{

    "namespace":"OS::Compute::HostCapabilities",

    "display_name": "ComputeHost Capabilities",

    "description": "Hardwarecapabilities provided by the compute host. This provides the ability to finetune the hardware specification required when an instance is requested. TheComputeCapabilitiesFilter should be enabled in the Nova scheduler to use theseproperties. When enabled, this filter checks that the capabilities provided bythe compute host satisfy any extra specifications requested. Only hosts thatcan provide the requested capabilities will be eligible for hosting theinstance.",

    "visibility": "public",

    "protected": true,

    "resource_type_associations": [

        {

            "name":"OS::Nova::Flavor",

            "prefix":"capabilities:"

        },

        {

            "name":"OS::Nova::Aggregate",

            "prefix":"aggregate_instance_extra_specs:"

        }

    ],

    "properties": {

        "cpu_info:vendor": {

            "title":"Vendor",

            "description":"Specifies the CPU manufacturer.",

            "operators":["<or>"],

            "type":"string",

            "enum": [

                "Intel",

                "AMD"

            ]

        },

        "cpu_info:model": {

            "title":"Model",

            "description":"Specifies the CPU model. Use this property to ensure that your vm runs ona a specific cpu model.",

            "operators":["<or>"],

            "type":"string",

            "enum": [

                "Conroe",

                "Core2Duo",

                "Penryn",

                "Nehalem",

                "Westmere",

                "SandyBridge",

                "IvyBridge",

                "Haswell",

                "Broadwell",

                "Delhi",

                "Seoul",

                "Abu Dhabi",

                "Interlagos",

                "Kabini",

                "Valencia",

                "Zurich",

                "Budapest",

                "Barcelona",

                "Suzuka",

                "Shanghai",

                "Istanbul",

                "Lisbon",

                "Magny-Cours",

                "Valencia",

                "Cortex-A57",

                "Cortex-A53",

                "Cortex-A12",

                "Cortex-A17",

                "Cortex-A15",

                "Coretx-A7",

                "X-Gene"

            ]

        },

        "cpu_info:arch": {

            "title": "Architecture",

            "description":"Specifies the CPU architecture. Use this property to specify thearchitecture supported by the hypervisor.",

            "operators":["<or>"],

            "type":"string",

            "enum": [

                "x86",

                "x86_64",

                "i686",

                "ia64",

                "ARMv8-A",

                "ARMv7-A"

            ]

        },

        "cpu_info:topology:cores": {

            "title":"cores",

            "description":"Number of cores.",

            "type":"integer",

            "readonly": false,

            "default": 1

        },

        "cpu_info:topology:threads":{

            "title":"threads",

            "description":"Number of threads.",

            "type":"integer",

            "readonly": false,

            "default": 1

        },

        "cpu_info:topology:sockets":{

            "title":"sockets",

            "description":"Number of sockets.",

            "type":"integer",

            "readonly": false,

            "default": 1

        },

        "cpu_info:features": {

            "title":"Features",

            "description":"Specifies CPU flags/features. Using this property you can specify therequired set of instructions supported by a vm.",

            "operators":["<or>", "<all-in>"],

            "type":"array",

            "items": {

                "type":"string",

                "enum": [

                    "fpu",

                    "vme",

                    "de",

                    "pse",

                    "tsc",

                    "msr",

                    "pae",

                    "mce",

                    "cx8",

                    "apic",

                    "sep",

                    "mtrr",

                    "pge",

                    "mca",

                    "cmov",

                    "pat",

                    "pse36",

                    "pn",

                    "clflush",

                    "dts",

                    "acpi",

                    "mmx",

                    "fxsr",

                    "sse",

                    "sse2",

                    "ss",

                    "ht",

                    "tm",

                    "ia64",

                    "pbe",

                    "syscall",

                    "mp",

                    "nx",

                    "mmxext",

                    "fxsr_opt",

                    "pdpe1gb",

                    "rdtscp",

                    "lm",

                    "3dnowext",

                    "3dnow",

                    "arch_perfmon",

                    "pebs",

                    "bts",

                    "rep_good",

                    "nopl",

                    "xtopology",

                    "tsc_reliable",

                    "nonstop_tsc",

                    "extd_apicid",

                    "amd_dcm",

                    "aperfmperf",

                    "eagerfpu",

                    "nonstop_tsc_s3",

                    "pni",

                    "pclmulqdq",

                    "dtes64",

                    "monitor",

                    "ds_cpl",

                    "vmx",

                    "smx",

                    "est",

                    "tm2",

                    "ssse3",

                    "cid",

                    "fma",

                    "cx16",

                    "xtpr",

                    "pdcm",

                    "pcid",

                    "dca",

                    "sse4_1",

                    "sse4_2",

                    "x2apic",

                    "movbe",

                    "popcnt",

                   "tsc_deadline_timer",

                    "aes",

                    "xsave",

                    "avx",

                    "f16c",

                    "rdrand",

                    "hypervisor",

                    "rng",

                    "rng_en",

                    "ace",

                    "ace_en",

                    "ace2",

                    "ace2_en",

                    "phe",

                    "phe_en",

                    "pmm",

                    "pmm_en",

                    "lahf_lm",

                    "cmp_legacy",

                    "svm",

                    "extapic",

                    "cr8_legacy",

                    "abm",

                    "sse4a",

                    "misalignsse",

                    "3dnowprefetch",

                    "osvw",

                    "ibs",

                    "xop",

                    "skinit",

                    "wdt",

                    "lwp",

                    "fma4",

                    "tce",

                    "nodeid_msr",

                    "tbm",

                    "topoext",

                    "perfctr_core",

                    "perfctr_nb",

                    "bpext",

                    "perfctr_l2",

                    "mwaitx",

                    "ida",

                    "arat",

                    "cpb",

                    "epb",

                    "pln",

                    "pts",

                    "dtherm",

                    "hw_pstate",

                    "proc_feedback",

                    "hwp",

                    "hwp_notify",

                    "hwp_act_window",

                    "hwp_epp",

                    "hwp_pkg_req",

                    "intel_pt",

                    "tpr_shadow",

                    "vnmi",

                    "flexpriority",

                    "ept",

                    "vpid",

                    "npt",

                    "lbrv",

                    "svm_lock",

                    "nrip_save",

                    "tsc_scale",

                    "vmcb_clean",

                    "flushbyasid",

                    "decodeassists",

                    "pausefilter",

                    "pfthreshold",

                    "vmmcall",

                    "fsgsbase",

                    "tsc_adjust",

                    "bmi1",

                    "hle",

                    "avx2",

                    "smep",

                    "bmi2",

                    "erms",

                    "invpcid",

                    "rtm",

                    "cqm",

                    "mpx",

                    "avx512f",

                    "rdseed",

                    "adx",

                    "smap",

                    "pcommit",

                    "clflushopt",

                    "clwb",

                    "avx512pf",

                    "avx512er",

                    "avx512cd",

                    "sha_ni",

                    "xsaveopt",

                    "xsavec",

                    "xgetbv1",

                    "xsaves",

                    "cqm_llc",

                    "cqm_occup_llc",

                    "clzero"

                ]

            }

        }

    },

    "objects": []

}

参考资料

http://www.codexiu.cn/openstack/blog/14729/#OSC_h2_9

http://docs.openstack.org/kilo/config-reference/content/section_compute-scheduler.html

 

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/zztflyer/article/details/51770634

智能推荐

如何使用OpenStack将云主机部署到特定的计算节点上

本文简要介绍了openstack调度器nova-scheduler实现的基本原理,并通过两个示例介绍了基于某些特殊场景如何将云主机部署到特定的计算节点上。

4-6-使用Kolla部署Pike版本的OpenStack-多节点云平台-随堂笔记_iphone旧版本软件下载

第六章 使用 Kolla 部署 Pike 版本的 OpenStack-多节点于平台 本节所讲内容 6.1 准备 openstack 多结点实验环境 6.2 安装 kolla-ansible 6.3 自定义kolla-ansible 安装 openstack 的相关配置文件 6.4 开始基亍 kolla...

centos下部署openstack计算节点文档

介绍在centos下快速准确部署openstack计算节点

OpenStack-ocata部署时无法将计算节点添加到cell数据库

OpenStack-ocata部署时将计算节点添加到cell数据库时报错如下:发现计算主机:#su-s /bin/sh -c “nova-manage cell_v2 discover_hosts --verbose” nova当出现上面错误的时候,是因为缺少数据库连接参数,在出现问题...

Centos 7 部署 OpenStack_Rocky版高可用集群3-3

文章目录Centos 7 部署 OpenStack_Rocky版高可用集群3-311、 Horizon集群11.1 部署dashboard (在全部控制节点操作 cont01 cont02 cont03)11.2 配置local_settings 文件(在全部控制节点操作 cont01 cont02 cont03...

OpenStackWorksOnArm:概念验证展示了基于多节点Armv8的OpenStack云-源码

使用Terraform在Packet上快速轻松地创建由Armv8和/或x86裸机服务器提供支持的OpenStack云。 具体而言,此部署展示了如何在Armv8裸机上部署多节点云。 部署默认为最少4个节点的OpenStack云,该云由3个Armv8节点和一...

openstack多节点搭建

这是自己参考文档所搭建的openstack多节点这里分享给初学者这是自己参考文档所搭建的openstack多节点这里分享给初学者这是自己参考文档所搭建的openstack多节点这里分享给初学者这是自己参考文档所搭建的openstack多...

OpenStack云安全部署指导书.zip

Queen版本Openstack云计算平台搭建,服务节点包括控制节点、计算节点(centos7),服务组件包括keystone、neutron、nova、cinder、glance、horizon、barbican;另外,对平台安全性进行配置,包括https传输加密、存储...

使用Kolla部署Pike版本的OpenStack-allinone云平台

使用Kolla部署Pike版本的OpenStack-allinone云平台,非常详细,很好

华为云计算——FusionSphere OpenStack单节点部署实例-附件资源

华为云计算——FusionSphere OpenStack单节点部署实例-附件资源

OpenStack-ocata部署时计算节点无法启动

OpenStack-ocata部署时计算节点无法启动,这个问题困扰了我好久,查过各种CSDN文档,都没有有效的解决方案。具体报错如下:#systemctl start openstack-nova-compute.serviceJob for openstack-nova-compute.service...

OpenStack使用[搭建一套简单的网络环境及创建云主机实例]

OpenStack使用[搭建一套简单的网络环境及创建云主机实例]

openstack-ansible:使用Ansible进行Openstack部署-源码

该存储库提供了一系列剧本,可用于在单个节点上安装Openstack冰屋服务,并在ubuntu 12.04上使用单个NIC。 使用说明 在您的客户端计算机上安装ansible: 为ansible创建主机intentory 文件:/ etc / ansible / ...

openstack创建实例到指定计算节点

实例创建到新加计算节点,验证是否成功,需要以下几步。 官方原文:https://docs.openstack.org/nova/rocky/admin/availability-zones.html 1、查看有效区域 openstack availability zone list 2、查看有效...

openstack创建云主机

全网第一份使用open stack命令创建云主机 一.上传镜像 #使用open stack命令上传cirros镜像,命名为cirros [[email protected] ~]# openstack image create --disk-format qcow2 --file /root/cirros-0.3.1-x86_64-disk...

使用kolla-ansible部署多节点OpenStack(T版)及对接Ceph

近期使用kolla-ansible部署一套OpenStack多节点测试环境,用于测试计算节点宕机撤离的生产场景。 虽然官方文档写的非常详细,但是整个部署过程也多多少少遇到些问题。 现在将整个基于Kolla-ansible 快速部署的...

OpenStack双节点部署—M 通过命令创建云主机

运行云主机一、 创建云网络二、 创建云主机实例 本节全部在Controller节点完成 一、 创建云网络 1.Provider Network 1)生效admin用户环境变量,创建flat网络 # . admin-openrc # neutron ...

openstack安装部署5——计算服务(控制节点&计算节点)

1.前言Openstack计算服务通过...Openstack计算服务可以在标准硬件上进行横向扩展,可以下载镜像并开启虚拟机实例。 Openstack计算服务包含如下几部分,每部分都对应一个组件: nova-api接收并响应终端用户的计算服务A

CentOS7单节点部署OpenStack-Pike(使用kolla-ansible)

修改主机名 安装docker 配置国内镜像源 重启Docker服务 检查镜像服务是否正常 安装和配置Kolla-Ansible 安装依赖 安装ansible 安装kolla-ansible 配置单节点清单文件(目前只有一个节点) 生成随机密码文件 修改...

openstack平台的计算节点部署

计算节点扩展部署文档 ­  —— by 冯冰艳 1. 配置网络 如果使用单网卡,则按照如下方式配置:(/etc/sysconfig/network-scrips/ifcfg-eth0)。 注:如果是单网卡,需要将对应的网卡接口设置为“混合模式”...

OpenStack 云主机镜像制作

文章目录目录镜像支持功能手动制作启动虚拟机环境配置虚拟机环境创建 Glance 镜像使用 OpenStack 环境制作DIB 制作将 OpenStack 云主机制作成镜像 镜像支持功能 支持密码注入功能(注:通过 nova boot --admin-pass...

OpenStack

OpenStack是一个免费开放源代码的云计算平台,用户可以将其部署成为一个基础设施即服务(Iaas)的解决方案。OpenStack不是一个单一的项目,而是由许多相关的项目组成,包括Nova、Swift、Keystone、Horizon等。这些...

openstack创建云主机流程

当访问Dashboard的时候,会显示一个登录页面,Dashboard会告诉你,想使用Openstack创建云主机?那你得先把你的账号密码交给我,我去Keystone上验证你的身份之后才能让你登录。 Keystone接收到前端表单传过来的域,...

Packstack单节点一键部署openstack-Train版

#记录一台单节点物理服务器使用PackStack部署OpenStack-Train版的操作 戴尔R720 系统:centos7.8.2003 cpu型号: E5-2670v2 2C8核32线程 内存 32G 网络环境: eth0 192.168.100.106 物理外网 eth1 172.16.0.106 ...

部署单节点OpenStack

一.OpenStack详述 OpenStack简介 OpenStack是一个是一个开源的云计算管理平台项目,是一系列软件开源项目的组合。通过命令或者基于Web的可视化控制面板来管理IaaS云端资源池(服务器、存储和网络)。它2010年由...

OpenStack Train版部署

文章目录1.... Openstack环境准备3.... nova7.1 安装nova计算服务(controller控制节点192.168.0.10)7.2 安装nova计算服务(computel01计算节点 192.168.0.20)7.3 在控制节点上进行验证nova服务8. neutron8.1 安...

OpenStack双节点部署-M环境部署三 ——基础服务

OpenStack-M环境部署三——基本配置上传镜像配置主机映射配置yum源Controller节点安装FTP服务安装Openstack包安装数据库安装并配置消息服务器和Memcached安装Memcached一、Yum源配置问题二、ntp时间同步失败三、...

openstack-nova-compute.service 计算节点服务无法启动

部署OpenStack Mitaka版时,计算节点openstack-nova-compute.service 服务一直夯着无法启动,libvirtd 服务启动正常: [[email protected] ~]$ systemctl status openstack-nova-compute.service ● openstack-nova-...

CentOS7.3部署OpenStack-Ocata版本手记(计算节点) - 未完待续

一、环境准备 1. 网络环境 节点名称 IP 域名 ... 控制节点 ... 计算节点 192.168.159.35 node2.example.local 2. NTP服务 NTP服务器:192.168.159.254 admin.example.local NTP

在部署openstack R版时,在compute节点启动openstack-nova-compute.service服务出现错误 求助

在部署openstack R版时,在compute节点启动openstack-nova-compute.service服务出现错误,以下是日志: [[email protected] log]# tail -f /var/log/nova/nova-compute.log 2019-02-15 18:16:36.281 14519 ERROR nova ...

随便推点

推荐文章

热门文章

相关标签