警告

NOTICE: THIS DOCUMENTATION SITE HAS BEEN SUPERSEDED.

For the current documentation site goto: http://docs.cloudstack.apache.org

使用主机

添加主机

添加主机能为来宾VMs提供更多的性能。更多需求与说明请参阅 “添加主机”

主机的维护计划与维护模式

你可以使一台主机进入维护模式。当激活维护模式时,这台主机将不会接纳新的来宾VMs,同时上面的VMs会无缝地迁移到其他非维护模式的主机上。这个迁移使用在线迁移技术并且不会中断用户的操作。

vCenter与维护模式

要使vCenter主机进入维护模式,vCenter和CloudStack上都必须进行此操作。CloudStack和vCenter有各自的维护模式,他们需要紧密合作。

  1. 在CloudStack中,将主机进入”维护计划”模式。这个操作不会调用vCenter的维护模式,但是会将VMs迁离该主机。

    当CloudStack维护模式启用后,主机首先会进入准备维护状态。在这个阶段它不能运行新的来宾VMs。然后所有的VMs将会被迁离该主机。主机使用在线迁移来迁移VMs。这种方式能够使来宾VMs在迁移到其他主机的过程中不会中断用户的操作。

  2. 等”准备好维护”指示灯出现在UI中。

  3. 现在使用vCenter通过必要的步骤将主机进入维护模式。在此期间,主机不会运行新的VM。

  4. 当维护任务完成之后,按以下操作将主机退出维护模式:

    1. 首先通过vCenter退出vCenter维护模式。

      这么做是为了主机能够准备好以便CloudStack恢复它。

    2. 然后通过CloudStack的管理员UI来取消CloudStack维护模式

      当主机恢复正常,被迁移走的VMs可能需要手工迁移回来并且也能在主机上添加新的VMs了。

XenServer和维护模式

对于XenServer,你能够通过使用XenCenter中的维护模式功能将一台服务器临时的离线。当你使一台服务器进入维护模式,所有运行的VMs都会自动的迁移到同一个池中的其他主机上。如果此服务器是池master主机,那么此池会选举一个新的master主机。当一台服务器在维护模式下时,你不能在上面创建或启动任何VMs。

使一台服务器进入维护模式:

  1. 在资源面板,选择服务器,然后按下列步骤进行操作:
    • 右击,然后在弹出的快捷菜单中点击进入维护模式。
    • 在服务器菜单,点击进入维护模式。
  2. 点击进入维护模式。

当所有运行当中的VMs成功的迁离该主机后,在资源面板中会显示服务器的状态。

使服务器退出维护模式:

  1. 在资源面板,选择服务器,然后按下列步骤进行操作:
    • 右击,然后在弹出的快捷菜单中点击退出维护模式。
    • 在服务器菜单,点击提出维护模式。
  2. 点击退出维护模式。

禁用和启用Zones,Pods和Clusters

你可以启用或禁用一个zone,pod或者cluster而不用永久的从云中移除他们。这对于维护或者当云中一部分架构的可靠性有问题的时候很有用。禁用状态下的zone,pod或cluster不会接受新的分配,除非其状态变为启用。当一个zone,pod或cluster是初次添加到云中的,默认的情况下它是禁用的。

要禁用和启用一个zone,pod或者cluster:

  1. 使用管理员权限的账号登录到CloudStack
  2. 在左侧导航栏中,点击基础架构
  3. 点击区域中的查看更多。
  4. 如果你要禁用或启用一个zone,请在列表里找到zone的名称,然后点击启用/禁用按钮。button to enable or disable zone, pod, or cluster.
  5. 如果你要禁用或启用一个pod或者cluster,点击包含该pod或cluster的zone名称。
  6. 点击计算这个标签。
  7. 在示意图中的Pods或者Clusters节点,点击查看所有。
  8. 点击列表中的pod或者cluster名称。
  9. 点击启用/禁用按钮。button to enable or disable zone, pod, or cluster.

移除主机

主机在需要的时候可以被移除。这个过程取决于主机所使用的hypervisor类型。

移除XenServer和KVM主机

cluster中的主机只有进入维护模式才能被移除。这么做是为了确保其上所有的VMs被迁移至其他主机。要从云中移除一个主机:

  1. 将主机进入维护模式。

    请参考`“主机的维护计划与维护模式” <#scheduled-maintenance-and-maintenance-mode-for-hosts>`_.

  2. 对于KVM,停止cloud-agent服务。

  3. 使用UI选项来移除主机。

    然后你可以关掉主机,重用它的IP地址,重新安装系统,等等。

移除vSphere主机

要移除此类型的主机,首先按照 `“主机的维护计划与维护模式” <#scheduled-maintenance-and-maintenance-mode-for-hosts>`_中的描述将其进入维护模式。然后使用CloudStack来移除主机。使用CloudStack移除主机时,CloudStack不会直接操作主机。但是,主机可能仍然存留在vCenter群集中。

重新安装主机

你可以在将主机进入维护模式并移除它之后重新安装系统。如果主机是宕机状态而不能进入维护模式,在重装它之前仍然能被移除。

在主机上维护Hypervisors

当主机上运行了hypervisor软件,请确保安装了供应商提供的所有修补程序。请通过供应商跟踪虚拟化平台的补丁发布情况,一旦发布,请尽快打上补丁。CloudStack不会跟踪或通知您所需要的虚拟化平台补丁。您的主机及时打上最新虚拟化平台补丁是非常重要的。虚拟化平台厂商很可能会拒绝支持未打最新补丁的系统。

注解

缺乏最新补丁更新可能会导致数据和虚拟机丢失。

(XenServer)更多信息,请参考`CloudStack知识库中高度推荐的XenServer修补程序 <http://docs.cloudstack.org/Knowledge_Base/Possible_VM_corruption_if_XenServer_Hotfix_is_not_Applied/Highly_Recommended_Hotfixes_for_XenServer_5.6_SP2>`_.

更改主机密码

数据库中的XenServer主机,KVM主机或者vShpere主机密码可能会被变更。注意群集中的所有节点密码必须一致。

用户名和密码要更改一台主机的密码:

  1. 让群集中所有的主机状态保持一致。

  2. 更改群集中所有主机的密码。此刻主机上的密码与CloudStack已知的密码不一致。两个密码不一致的话会导致群集上的操作失败。

  3. if the password in the database is encrypted, it is (likely) necessary to encrypt the new password using the database key before adding it to the database.

    java -classpath /usr/share/cloudstack-common/lib/jasypt-1.9.0.jar \
    org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI \
    encrypt.sh input="newrootpassword" \
    password="databasekey" \
    verbose=false
    
  4. 获取群集中你更改了密码的主机ID列表。你必须访问数据库来获取这些ID。为每个你要更改密码的主机名(或者vSphere群集) “h”,执行:

    mysql> SELECT id FROM cloud.host WHERE name like '%h%';
    
  5. This should return a single ID. Record the set of such IDs for these hosts. Now retrieve the host_details row id for the host

    mysql> SELECT * FROM cloud.host_details WHERE name='password' AND host_id={previous step ID};
    
  6. Update the passwords for the host in the database. In this example, we change the passwords for hosts with host IDs 5 and 12 and host_details IDs 8 and 22 to “password”.

    mysql> UPDATE cloud.host_details SET value='password' WHERE id=8 OR id=22;
    

超配和服务方案限制

(支持XenServer、KVM和VMware)

CPU和内存(RAM)超配直接影响每个群集中主机上可以运行的VMs数量。这样可以帮助优化资源的使用。依靠增加超配比率,能使使资源更充分的被利用。如果比率设为1,那么表示没有使用超配。

管理员也可以在cpu.overprovisioning.factor和mem.overprovisioning.factor这两个全局配置变量中设置全局默认超配比率。默认的值是1:默认情况下超配是关闭的。

超配比率是由CloudStack的容量计算器动态调整的。比如:

容量=2GB 超配系数=2 超配后容量=4GB

按照这个配置,假设你部署了3个VMs,每个VM 1GB:

已使用=3GB 空闲=1GB

管理员可以在每个群集中指定一个内存超配比率,也可以同时指定CPU和内存超配比率。

在任何已有的云中,hypervisor、存储和硬件配置影响每个主机上VMs最佳数量。同一个云中的每个群集的这些配置可能都不同。单一的全局超配设置不能为云中所有的群集提供最佳效果。它只能作为一个基线。无论CloudStack使用哪种算法来放置一个VM,每个群集都提供了细颗粒度的设置以提供更好的资源效果。

超配设置和专用资源(对一个账号分配一个特定的群集)一起使用时能对不同用户有效的提供的不同服务级别。比如,一个账号购买了比较高级别的服务,那么分配给他一个超配比率为1的专用群集,购买低级别服务的账号分配一个比率为2的群集。

当一个新主机被添加到群集中,CloudStack假设配置了超配的群集中的主机能够提供CPU和RAM的超配能力。这个要靠管理员来决定主机是否真的能够提供设置的超配级别。

XenServer和KVM中超配的局限性

  • 在XenServer中,由于这个hypervisor的限制,超配系数不能超过4。
  • KVM hypervisor不能动态的管理分配给VMs的内存。CloudStack设置VM能够使用的内存最小和最大量。Hypervisor基于存储器争用技术在设定范围内调整内存。

存储超配的要求

为了让超配能够正常工作需要几个前提条件。此特性取决于OS类型,hypervisor功能和特定的脚本。管理员负责确认这些条件都符合。

Balloon驱动

所有VMs中都安装了balloon驱动。Hypervisor靠balloon驱动与VM通讯以释放内存和让内存变得可用。

XenServer

Balloon驱动是Xen pv或者PVHVM驱动的一部分。Linux kernels 2.6.36和以上版本中包含了Xen pvhvm驱动。

VMware

Balloon驱动是VMware tools的一部分。在一台超配群集中部署的所有的VMs都应该安装VMware tools。

KVM

所有VMs都需要支持virtio驱动。Linux kernel versions 2.6.25和更高版本中已经安装了这些驱动。管理员必须在virtio的配置文件中配置CONFIG_VIRTIO_BALLOON=y。

Hypervisor功能

Hypervisor必须能够使用内存ballooning。

XenServer

Hypervisor必须启用了DMC(动态内存控制)功能。只有XenServer高级版以及更高版本拥有这个功能。

VMware、KVM

默认支持内存ballooning。

设置存储超配系数

管理员有两种方法来设置CPU和RAM超配系数。第一,当新的群集被创建完成的时候全局配置中的cpu.overprovisioning.factor和mem.overprovisioning.factor将生效。第二,对于已存在的群集可以直接修改系数。

只有在变更之后部署VMs,设置才会生效。如果想让变更之前部署的VMs也能继承新的超配比率,你必须重启VMs。当此操作完成之后,CloudStack会重新计算或者调整已使用的资源,并且基于新的超配比率预留出容量,以保证CloudStack正确的掌握了剩余容量的情况。

注解

如果新的可用容量不足以满足新的VMs需求,那么当重新计算容量的过程中不去部署新的VMs是比较安全的。等新的已用/可用容量完全可用时,确认这空间对于你想创建的VMs足够用。

在已存在的群集中更改超配系数:

  1. 使用管理员登录到CloudStack管理界面。

  2. 在左侧导航栏中,点击基础架构

  3. 在群集页面,点击查看所有。

  4. 选择你要操作的群集,点击编辑按钮。

  5. 在CPU overcommit ratio和RAM overcommit ratio区域里填入你希望的超配系数。这里的初始值是从全局配置设置里继承而来的。

    注解

    在XenServer中,由于这个hypervisor的限制,超配系数不能超过4。

服务方案限制和超配

服务方案限制(比如1GHz,1 core)是受到core数严格限制的。比如,一个使用1 core服务方案的用户只能用 1core,无论这个主机多空闲。

GHz的服务方案限制只存在于CPU资源的争用中。比如,假设用户在一个有2GHz core的主机上创建了一个1 GHz的服务方案,并且该用户是这个主机上唯一一个用户。那么该用户有2 GHz可用性能。当多个用户尝试使用CPU,则由权重系数来调度CPU资源。这个权重基于服务方案中的时钟速度。用户分配到的CPU GHz与服务方案中一致。比如,用户从一个2GHz服务方案中创建的VM分配到的CPU是从1 GHz方案中分配到的2倍。CloudStack不能提供内存的超配。

VLAN供应

CloudStack能在主机上自动创建和销毁桥接至VLAN的网络接口。一般来说,管理员不需要介入此处理过程。

CloudStack根据hypervisor类型的不同,管理VLANs的方式也不同。对于XenServer或者KVM来说,只在使用VLANs的主机上创建VLANs,并且当所有使用VLANs的来宾虚机被销毁或者移动至其他主机的时候,这些VLANs就会被销毁。

vSphere上的VLANs是在群集中的所有主机上配置的,不管主机上有没有使用VLAN的来宾虚机在运行。这样允许管理员在vCenter中不需在目标主机上创建VLAN就可以执行在线迁移和其他功能。此外,当主机不再需要的时候VLANs也不会被移除。

你能够使用由不同的拥有二层网络结构的物理网络提供同样的VLANs,比如交换机。比如,在对高级zone中部署物理网络A和B的时候,你可以指定VLAN范围为500-1000。如果你的VLANs用尽了,这个功能允许你在不同的物理网卡上设置追加一个二层物理网络并且使用同样的VLANs设置。另一个优点是你可以在不同的物理网卡上为不同的客户使用同样的IPs设置,每个都有自己的路由器和来宾网络。

VLAN分配示例

公共和来宾流量要求使用VLAN,下面是一个VLAN分配的示例:

VLAN IDs 流量类型 范围
小于500 管理流量。 出于管理目的而预留的。CloudStack,hypervisors和系统虚机能访问它。
500-599 承载公共流量。 CloudStack账户。
600-799 承载来宾流量 CloudStack 账户。 从这个池中选择账户特定的VLAN。
800-899 承载来宾流量 CloudStack 账户。CloudStack管理员为账户指定特定的VLAN。
900-999 承载来宾流量 CloudStack 账户。可作为项目、域或所有账户的作用域。
大于1000 保留为将来使用  

添加不连续的VLAN范围

CloudStack能让你灵活的给你的网络添加不连续的VLAN范围。在创建一个zone的时候,管理员要么更新一个已存在的VLAN范围,要么添加多个不连续的VLAN范围。你同样可以使用UpdatephysicalNetwork API来扩展VLAN范围。

  1. 使用管理员或者终端用户账号登录CloudStack UI。

  2. 确保VLAN范围没有被使用。

  3. 在左边的导航,选择基础架构。

  4. 在Zones上,点击查看更多,然后点击你要进行操作的zone。

  5. 点击物理网络。

  6. 在图中的来宾节点上,点击配置

  7. 点击编辑|edit-icon.png|。

    现在VLAN范围区域是可编辑的了。

  8. 指定VLAN范围的起始和结束用逗号隔开。

    指定所有你想使用的VLANs,如果你添加新的范围到已有列表里,那么没有指定的VLANs将被移除。

  9. 点击应用

给隔离的网络指定VLAN。

CloudStack能够让你控制VLAN分配至隔离网络。作为一个Root管理员,当一个网络被创建后,你能为其分配一个VLAN ID,这个网络只能是共享网络。

同样被支持—当网络转换为运行状态是,VLAN是随机地通过物理网络的VNET范围分配给网络。当网络作为网络垃圾回收过程的一部分而关闭时,VLAN会被回收到VNET池。当网络再次启用的时候VLAN还能被其重用,或者其他网络使用。在每个新启用的网络中,都有一个新的VLAN被分配。

只有Root管理员能够分配VLANs,因为常规的用户和域管理员并不清楚物理网络拓扑。他们也不能查看哪个VLAN被分配给网络。

要把VLANs分配给隔离的网络,

  1. 使用下列指定的步骤创建一个网络方案:

    • 来宾网络类型:选择隔离的。
    • 指定VLAN:选择一个选项。

    更多信息,请参考CloudStack安装指导。

  2. 使用这个网络方案,创建一个网络。

    你可以创建一个VPC层或者一个隔离网络。

  3. 当你创建网络的时候指定VLAN。

    当VLAN被指定后,CIDR和网关就被分配给这个网络了,并且它的状态也变成Setup了。在这个状态下,网络不会被回收。

注解

一旦VLAN被分配给一个网络的话,你就不能更改它。VLAN将伴随着网络的整个生命周期。

Out-of-band Management

CloudStack provides Root admins the ability to configure and use supported out-of-band management interface (e.g. IPMI, iLO, DRAC, etc.) on a physical host to manage host power operations such as on, off, reset etc. By default, IPMI 2.0 baseboard controller are supported out of the box with IPMITOOL out-of-band management driver in CloudStack that uses ipmitool for performing IPMI 2.0 management operations.

Following are some global settings that control various aspects of this feature.

Global setting Default values Description
outofbandmanagement.action.timeout 60 The out of band management action timeout in seconds, configurable per cluster
outofbandmanagement.ipmitool.interface lanplus The out of band management IpmiTool driver interface to use. Valid values are: lan, lanplus etc
outofbandmanagement.ipmitool.path /usr/bin/ipmitool The out of band management ipmitool path used by the IpmiTool driver
outofbandmanagement.ipmitool.retries 1 The out of band management IpmiTool driver retries option -R
outofbandmanagement.sync.poolsize 50 The out of band management background sync thread pool size 50

A change in outofbandmanagement.sync.poolsize settings requires restarting of management server(s) as the thread pool and a background (power state) sync thread are configured during load time when CloudStack management server starts. Rest of the global settings can be changed without requiring restarting of management server(s).

The outofbandmanagement.sync.poolsize is the maximum number of ipmitool background power state scanners that can run at a time. Based on the maximum number of hosts you’ve, you can increase/decrease the value depending on how much stress your management server host can endure. It will take atmost number of total out-of-band-management enabled hosts in a round * outofbandmanagement.action.timeout / outofbandmanagement.sync.poolsize seconds to complete a background power-state sync scan in a single round.

In order to use this feature, the Root admin needs to first configure out-of-band management for a host using either the UI or the configureOutOfBandManagement API. Next, the Root admin needs to enable it. The feature can be enabled or disabled across a zone or a cluster or a host,

Once out-of-band management is configured and enabled for a host (and provided not disabled at zone or cluster level), Root admins would be able to issue power management actions such as on, off, reset, cycle, soft and status.

If a host is in maintenance mode, Root admins are still allowed to perform power management actions but in the UI a warning is displayed.

Security

Starting 4.11, CloudStack has an inbuilt certicate authority (CA) framework and a default ‘root’ CA provider which acts as a self-signed CA. The CA framework participates in certificate issuance, renewal, revocation, and propagation of certificates during setup of a host. This framework is primary used to secure communications between CloudStack management server(s), the KVM/LXC/SSVM/CPVM agent(s) and peer management server(s).

Following are some global settings that control various aspects of this feature.

Global setting Description
ca.framework.provider.plugin The configured CA provider plugin
ca.framework.cert.keysize The key size used for certificate generation
ca.framework.cert.signature.algorithm The certificate signature algorithm
ca.framework.cert.validity.period Certificate validity in days
ca.framework.cert.automatic.renewal Whether to auto-renew expiring certificate on hosts
ca.framework.background.task.delay The delay between each CA background task round in seconds
ca.framework.cert.expiry.alert.period The number of days to check and alert expiring certificates
ca.plugin.root.private.key (hidden/encrypted in database) Auto-generated CA private key
ca.plugin.root.public.key (hidden/encrypted in database) CA public key
ca.plugin.root.ca.certificate (hidden/encrypted in database) CA certificate
ca.plugin.root.issuer.dn The CA issue distinguished name used by the root CA provider
ca.plugin.root.auth.strictness Setting to enforce two-way SSL authentication and trust validation
ca.plugin.root.allow.expired.cert Setting to allow clients with expired certificates

A change in ca.framework.background.task.delay settings requires restarting of management server(s) as the thread pool and a background tasks are configured only when CloudStack management server(s) start.

After upgrade to CloudStack 4.11+, the CA framework will by default use the root CA provider. This CA provider will auto-generate its private/public keys and CA certificate on first boot post-upgrade. For freshly installed environments, the ca.plugin.root.auth.strictness setting will be true to enforce two-way SSL authentication and trust validation between client and server components, however, it will be false on upgraded environments to be backward compatible with legacy behaviour of trusting all clients and servers, and one-way SSL authentication. Upgraded/existing environments can use the provisionCertificate API to renew/setup certificates for already connected agents/hosts, and once all the agents/hosts are secured they may enforce authentication and validation strictness by setting ca.plugin.root.auth.strictness to true and restarting the management server(s).

Server Address Usage

Historically, when multiple management servers are used a tcp-LB is used on port 8250 (default) of the management servers and the VIP/LB-IP is used as the host setting to be used by various CloudStack agents such as the KVM, CPVM, SSVM agents, who connect to the host on port 8250. However, starting CloudStack 4.11+ the host setting can accept comma separated list of management server IPs to which new CloudStack hosts/agents will get a shuffled list of the same to which they can cycle reconnections in a round-robin way.

Securing Process

Agents while making connections/reconnections to management server will only validate server certificate and be able to present client certificate (issued to them) when cloud.jks is accessible to them. On older hosts that are setup prior to this feature the keystore won’t be available, however, they can still connect to management server(s) if ca.plugin.root.auth.strictness is set to false. Management server(s) will check and setup their own cloud.jks keystore on startup, this keystore will be used for connecting to peer management server(s).

When a new host is being setup, such as adding a KVM host or starting a systemvm host, the CA framework kicks in and uses ssh to execute keystore-setup to generate a new keystore file cloud.jks.new, save a random passphrase of the keystore in the agent’s properties file and a CSR cloud.csr file. The CSR is then used to issue certificate for that agent/host and ssh is used to execute keystore-cert-import to import the issued certificate along with the CA certificate(s), the keystore is that renamed as cloud.jks replacing an previous keystore in-use. During this process, keys and certificates files are also stored in cloud.key, cloud.crt, cloud.ca.crt in the agent’s configuration directory.

When hosts are added out-of-band, for example a KVM host that is setup first outside of CloudStack and added to a cluster, the keystore file will not be available however the keystore and security could be setup by using keystore utility scripts manually. The keystore-setup can be ran first to generate a keystore and a CSR, then CloudStack CA can be used to issue certificate by providing the CSR to the issueCertificate API, and finally issued certificate and CA certificate(s) can be imported to the keystore using keystore-cert-import script.

Following lists the usage of these scripts, when using these script use full paths, use the final keystore filename as cloud.jks, and the certificate/key content need to be encoded and provided such that newlines are replace with ^ and space are replaced with ~:

keystore-setup <properties file> <keystore file> <passphrase> <validity> <csr file>

keystore-cert-import <properties file> <keystore file> <mode: ssh|agent> <cert file> <cert content> <ca-cert file> <ca-cert content> <private-key file> <private key content:optional>

Starting 4.11.1, a KVM host is considered secured when it has its keystore and certificates setup for both the agent and libvirtd process. A secured host will only allow and initiate TLS enabled live VM migration. This requires libvirtd to listen on default port 16514, and the port to be allowed in the firewall rules. Certificate renewal (using the provisionCertificate API) will restart both the libvirtd process and agent after deploying new certificates.