主存储¶
在配置群集时,按提示输入主存储的信息。选择NFS作为存储类型,并在如下区域中输入相应的值:
- 名称 - 使用 ‘Primary1’
- 服务器 - 使用的IP地址为 172.16.10.2
- 路径 - 使用之前定义的 /primary
This is the Apache CloudStack installation guide, for the Documentation home, the administrator guide or the Release-Notes please see:
注解
In this guide we first go through some design and architectural choices to build your cloud. Then we dive into a single node quick start guide to give you a feel for the installation process. The source installation steps are given in the follow-on section for people who want to build their own packages. Otherwise you can use the general installation which makes use of community maintained package repositories. The rest of the guide goes through the configuration of the data-center and the setup of the network, storage and hypervisors.
部署CloudStack的具体架构会因规模及用途的不同而变化。这一章节会包含一些典型的部署构架:用于测试和试验的小型架构,以及用于生产环境的大型全冗余架构。
这个图演示了CloudStack在小型部署时的网络结构。
这个图演示了CloudStack在大规模部署时的网络结构。
在前面章节中,提及了大规模冗余部署,存储的数据流量过大可能使得管理网络过载。部署时可选择将存储网络分离出来。存储协议如iSCSI,对网络延迟非常敏感。独立的存储网络能够使其不受来宾网络流量波动的影响。
CloudStack管理服务器可以部署一个或多个前端服务器并连接单一的MySQL数据库。可视需求使用一对硬件负载均衡对Web请求进行分流。另一备份管理节点可使用远端站点的MySQL复制数据以增加灾难恢复能力。
系统管理人员必须决定如下事项:
运用CloudStack的区域技术可以很容易的将其扩散为多站点模式。下图就显示了一个多站点部署的示例
在数据中心1内有主管理节点和区域1。MySQL数据库实时复制到数据中心2内的辅助管理节点中。
这个图展示了使用独立存储网络的设计。每一个物理服务器有四块网卡,其中两块连接到提供点级别的交换机,而另外两块网卡连接到用于存储网络的交换机。
有两种方式配置存储网络:
此图展示了网卡绑定与多路径IO(MPIO)之间的区别,网卡绑定的配置仅涉及一个网段,MPIO涉及两个独立的网段。
CloudStack支持多种流行的Hypervisor,你可以在所有的主机上使用一种,也可以使用不同的Hypervisor,但在同一个群集内的主机必须使用相同的Hypervisor。
你可能已经安装并运行了特定的hypervisor节点,在这种情况下,你的Hypervisor选择已经确定了。如果还处于初步规划阶段,那么就需要决定那种Hypervisor能切合你的需求。各种Hypervisor的利弊讨论不在本文档之列。但无论如何,CloudStack可以支持每种Hypervisor的那些功能的详细信息还是能够帮到你的。下面的表格就提供了这些信息:
功能特点 | XenServer | vSphere | KVM - RHEL | LXC | HyperV | 裸设备 |
---|---|---|---|---|---|---|
网络限速 | 是 | 是 | 否 | 否 | ? | 无 |
在区域内用于基本网络模式的安全组 | 是 | 否 | 是 | 是 | ? | 否 |
iSCSI | 是 | 是 | 是 | 是 | 是 | 无 |
光纤通道 | 是 | 是 | 是 | 是 | 是 | 无 |
本地磁盘 | 是 | 是 | 是 | 是 | 是 | 是 |
高可用 | 是 | 是(原生) | 是 | ? | 是 | 无 |
本地磁盘快照 | 是 | 是 | 是 | ? | ? | 无 |
用本地盘作为数据磁盘 | 是 | 否 | 是 | 是 | 是 | 无 |
工作负载均衡 | 否 | DRS-分布式资源调度 | 否 | 否 | ? | 无 |
手工在主机之间进行虚拟机的热迁移 | 是 | 是 | 是 | ? | 是 | 无 |
使用本地链路与虚拟路由器(VR)直接通讯来保护管理网络的IP流量 | 是 | 否 | 是 | 是 | ? | 无 |
The following table shows storage options and parameters for different hypervisors.
Primary Storage Type | XenServer | vSphere | KVM - RHEL | LXC | HyperV |
---|---|---|---|---|---|
Format for Disks, Templates, and Snapshots | VHD | VMDK | QCOW2 | VHD | |
iSCSI support | CLVM | VMFS | Yes via Shared Mountpoint | Yes via Shared Mountpoint | 否 |
Fiber Channel support | Yes, Via existing SR | VMFS | Yes via Shared Mountpoint | Yes via Shared Mountpoint | 否 |
NFS support | 是 | 是 | 是 | 是 | 否 |
Local storage support | 是 | 是 | 是 | 是 | 是 |
Storage over-provisioning | NFS | NFS and iSCSI | NFS | 否 | |
SMB/CIFS | 否 | 否 | 否 | 否 | 是 |
XenServer uses a clustered LVM system to store VM images on iSCSI and Fiber Channel volumes and does not support over-provisioning in the hypervisor. The storage server itself, however, can support thin-provisioning. As a result the CloudStack can still support storage over-provisioning by running on thin-provisioned storage volumes.
KVM supports “Shared Mountpoint” storage. A shared mountpoint is a file system path local to each server in a given cluster. The path must be the same across all Hosts in the cluster, for example /mnt/primary1. This shared mountpoint is assumed to be a clustered filesystem such as OCFS2. In this case the CloudStack does not attempt to mount or unmount the storage as is done with NFS. The CloudStack requires that the administrator insure that the storage is available
With NFS storage, CloudStack manages the overprovisioning. In this case the global configuration parameter storage.overprovisioning.factor controls the degree of overprovisioning. This is independent of hypervisor type.
Local storage is an option for primary storage for vSphere, XenServer, and KVM. When the local disk option is enabled, a local disk storage pool is automatically created on each host. To use local storage for the System Virtual Machines (such as the Virtual Router), set system.vm.use.local.storage to true in global configuration.
CloudStack supports multiple primary storage pools in a Cluster. For example, you could provision 2 NFS servers in primary storage. Or you could provision 1 iSCSI LUN initially and then add a second iSCSI LUN when the first approaches capacity.
部署云计算服务是一项挑战。这需要在很多不同的技术之间做出选择,CLOUDSTACK以其配置灵活性可以使用很多种方法将不同的技术进行整合和配置。这个章节包含了一些在云计算部署中的建议及需求。
这些内容应该被视为建议而不是绝对性的。然而,我们鼓励想要部署云计算的朋友们,除了这些建议内容之外,最好从CLOUDSTACK的项目邮件列表中获取更多建议指南性内容。
警告
缺乏最新补丁更新可能会导致数据和虚拟机丢失。
确保安装了所有系统补丁供应商提供的所有系统补丁。请随时关注供应商的技术支持渠道,一旦发布补丁,请尽快打上补丁。CloudStack不会跟踪或提醒你安装这些程序。安装最新的补丁对主机至关重要。虚拟化供应商可能不会对过期的系统提供技术支持。
构建基础架构即服务(IaaS)云是一个很复杂的工作,它定义了过多的选项,甚至新接触云平台的管理员都很容易混乱。此篇操作手册的目的就是为减少安装CloudStack时所发生的问题并提供最直接的帮助。
This runbook will focus on building a CloudStack cloud using KVM on CentOS 6.5 with NFS storage on a flat layer-2 network utilizing layer-3 network isolation (aka Security Groups), and doing it all on a single piece of hardware.
KVM或Kernel-based Virtual Machine是一种基于LInux内核的虚拟化技术。KVM支持本地虚拟化,主机的CPU处理器需支持硬件虚拟化扩展。
安全组起到类似分布式防火墙的作用,它可以对一组虚拟机进行访问控制。
完成此操作手册你需要如下条件:
首先,需要先准备要Cloudstack的安装环境,以下将详细描述准备步骤。
Using the CentOS 6.5 x86_64 minimal install ISO, you’ll need to install CentOS 6 on your hardware. The defaults will generally be acceptable for this installation.
当安装完成后,需要以root身份通过SSH连接新安装的主机,注意不要以root账户登录生产环境,请在完成安装和配置后关闭远程登录。
默认情况下新安装的机器并未启用网络,您需要根据实际环境进行配置。由于网络中不存在DHCP服务器,您需要手工配置网络接口。为了实现快速简化安装的目标,这里假定主机上只有eth0一个网络接口。
使用root用户登录本地控制台。检查文件 /etc/sysconfig/network-scripts/ifcfg-eth0,默认情况,其内容如下所示:
DEVICE="eth0"
HWADDR="52:54:00:B9:A6:C0"
NM_CONTROLLED="yes"
ONBOOT="no"
但是根据以上配置您无法连接到网络,对于Cloudstack也同样不适合;您需修改配置文件,指定IP地址,网络掩码等信息,如下例所示:
注解
注意,不要在你的配置中使用示例中的Hardware地址(也叫MAC地址)。该地址为网络接口所特有的,请保留你配置文件中已经提供的HWADDR字段。
DEVICE=eth0
HWADDR=52:54:00:B9:A6:C0
NM_CONTROLLED=no
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.16.10.2
NETMASK=255.255.255.0
GATEWAY=172.16.10.1
DNS1=8.8.8.8
DNS2=8.8.4.4
注解
IP Addressing - Throughout this document we are assuming that you will have a /24 network for your CloudStack implementation. This can be any RFC 1918 network. However, we are assuming that you will match the machine address that we are using. Thus we may use 172.16.10.2 and because you might be using the 192.168.55.0/24 network you would use 192.168.55.2
配置文件准备完毕后,需要运行命令启动网络。
# chkconfig network on
# service network start
Cloudstack要求正确设置主机名,如果安装时您接受了默认选项,主机名为localhost.localdomain,输入如下命令可以进行验证
# hostname --fqdn
在此处将返回:
localhost
为了纠正这个问题,需设置主机名,通过编辑/etc/hosts 文件,将其更改为类似如下内容:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.10.2 srvr1.cloud.priv
更改配置文件后,重启网络服务:
# service network restart
通过hostname –fqdn命令重新检查主机名,并确认返回了正确的FQDN
当前的CloudStack需要将SELinux设置为permissive才能正常工作,您需要改变当前配置,同时将该配置持久化,使其在主机重启后仍然生效。
在系统运行状态下将SELinux配置为permissive需执行如下命令:
# setenforce 0
为确保其持久生效需更改配置文件/etc/selinux/config,设置为permissive,如下例所示:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
为了同步云平台中主机的时间,需要配置NTP,但NTP默认没有安装。因此需要先安装NTP,然后进行配置。通过以下命令进行安装:
# yum -y install ntp
实际上默认配置项即可满足的需求,仅需启用NTP并设置为开机启动,如下所示:
# chkconfig ntpd on
# service ntpd start
配置主机使用CloudStack软件库。
注解
Apache CloudStack官方发布源代码。因此没有可用的“官方”安装文件。完整的安装指南介绍了如何获取源代码,以及制作RPM包和yum软件库。本指南尽可能简化这些操作,所以直接使用社区提供的yum软件库。
添加CloudStack软件仓库,创建/etc/yum.repos.d/cloudstack.repo文件,并添加如下信息。
[cloudstack]
name=cloudstack
baseurl=http://cloudstack.apt-get.eu/centos/6/4.8/
enabled=1
gpgcheck=0
本文档将配置的环境使用NFS做为主存储和辅助存储,需配置两个NFS共享目录,在此之前需先安装nfs-utils:
# yum -y install nfs-utils
接下来需配置NFS提供两个不同的挂载点。通过编辑/etc/exports文件即可简单实现。确保这个文件中包含下面内容:
/secondary *(rw,async,no_root_squash,no_subtree_check)
/primary *(rw,async,no_root_squash,no_subtree_check)
注意配置文件中指定了系统中两个并不存在的目录,下面需要创建这些目录并设置合适的权限,对应的命令如下所示:
# mkdir /primary
# mkdir /secondary
CentOS 6.x 版本默认使用NFSv4,NFSv4要求所有客户端的域设置匹配,这里以设置cloud.priv为例,请确保文件/etc/idmapd.conf中的域设置没有被注释掉,并设置为以下内容:
在/etc/sysconfig/nfs文件中取消如下选项的注释:
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020
接下来还需配置防火墙策略,允许NFS客户端访问。编辑文件/etc/sysconfig/iptables
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 111 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 111 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 2049 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 32803 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 32769 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 892 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 892 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 875 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 875 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 662 -j ACCEPT
-A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 662 -j ACCEPT
通过以下命令重新启动iptables服务:
# service iptables restart
最后需要配置NFS服务为开机自启动,执行如下命令:
# service rpcbind start
# service nfs start
# chkconfig rpcbind on
# chkconfig nfs on
接下来进行CloudStack管理节点和相关工具的安装。
首先安装MySQL,并对它进行配置,以确保CloudStack运行正常。
运行如下命令安装:
# yum -y install mysql-server
MySQL安装完成后,需更改其配置文件/etc/my.cnf。在[mysqld]下添加下列参数:
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'
正确配置MySQL后,启动它并配置为开机自启动:
# service mysqld start
# chkconfig mysqld on
现在将要开始安装管理服务器。执行以下命令:
# yum -y install cloudstack-management
在程序执行完毕后,需初始化数据库,通过如下命令和选项完成:
# cloudstack-setup-databases cloud:password@localhost --deploy-as=root
当该过程结束后,您应该可以看到类似信息:”CloudStack has successfully initialized the database.”。
数据库创建后,最后一步是配置管理服务器,执行如下命令:
# cloudstack-setup-management
If the servlet container is Tomcat7 the argument –tomcat7 must be used.
CloudStack通过一系列系统虚拟机提供功能,如访问虚拟机控制台,如提供各类网络服务,以及管理辅助存储的中的各类资源。该步骤会获取系统虚拟机模板,用于云平台引导后系统虚拟机的部署。
然后需要下载系统虚拟机模板,并把这些模板部署于刚才创建的辅助存储中;管理服务器包含一个脚本可以正确的操作这些系统虚拟机模板:
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-kvm.qcow2.bz2 \
-h kvm -F
以上是管理服务器的安装和配置过程;在配置CloudStack之前,仍需配置hypervisor。
本文档使用KVM作为hypervisor,下文将回顾最如何配置hypervisor主机,其中大部分配置工作已在配置管理节点时完成;接下来描述如何安装agent。您可以应用相同的步骤添加额外的KVM节点到CloudStack环境中。
本文档描述的环境使用管理服务器同时作为计算节点,这意味着很多先决步骤已经在搭建管理服务器时完成;但为了清晰起见,仍然列出相关步骤:
你不需要在管理节点上执行这些操作,当然,如果您需要添加额外的主机以上步骤仍然需要执行。
KVM中我们有两部分需要进行配置, libvirt和QEMU.
CloudStack使用libvirt管理虚拟机。因此正确的配置libvirt至关重要。Libvirt属于cloudstack-agent的依赖组件,应提前安装好。
为了实现动态迁移,libvirt需要监听使用非加密的TCP连接。还需要关闭libvirts尝试使用组播DNS进行广播。这些都是在 /etc/libvirt/libvirtd.conf文件中进行配置。
设置下列参数:
listen_tls = 0
listen_tcp = 1
tcp_port = "16059"
auth_tcp = "none"
mdns_adv = 0
仅仅在libvirtd.conf中启用”listen_tcp”还不够,我们还必须修改/etc/sysconfig/libvirtd中的参数:
取消如下行的注释:
#LIBVIRTD_ARGS="--listen"
重启libvirt服务
# service libvirtd restart
# lsmod | grep kvm
kvm_intel 55496 0
kvm 337772 1 kvm_intel
以上内容是针对KVM的安装和配置,下面将介绍如何使用CloudStack用户界面配置云平台。
如上文所述,该手册所描述的环境将使用安全组提供网络隔离,这意味着您的安装环境仅需要一个扁平的二层网络,同样意味着较为简单的配置和快速的安装。
要访问CloudStack的WEB界面,仅需在浏览器访问 http://172.16.10.2:8080/client ,使用默认用户’admin’和密码’password’来登录。第一次登录可以看到欢迎界面,提供两个选项设置CloudStack。请选择继续执行基本配置安装。
此时您会看到提示,要求为admin用户更改密码,请更新密码后继续。
区域是Cloudstack中最大的组织单位,下面将要讲述如何创建,此时屏幕中显示的是区域添加页面,这里需要您提供5部分信。
注解
CloudStack分为内部和公共DNS。内部DNS只负责解析内部主机名,比如NFS服务器的DNS名称。公共DNS为虚拟机提供公共IP地址解析。你可以指定同一个DNS服务器,但如果这样做,你必须确保内部和公共IP地址都能路由到该DNS服务器。在我们的案例中对内部资源不使用DNS名称,因此这里将其设置为与外部DNS一致用以简化安装,从而不必为此再安装一台DNS服务器。
到这里我们已经添加了一个区域,下一步会显示添加提供点所需信息:
添加区域后,仅需再为配置群集提供如下信息。
此时向导会提示您为集群添加第一台主机,需提供如下信息:
在配置群集时,按提示输入主存储的信息。选择NFS作为存储类型,并在如下区域中输入相应的值:
如果添加的是一个新的区域,您需提供辅助存储相关信息 - 如下所示:
现在,点击启动开始配置云-完成安装所需的时间取决于你的网络速度。
到这里,你的Apache CloudStack云就已经安装完成了。
CloudStack官方总是以源代码形式发布。你可以找到 “方便的二进制文件”, 这些源都是规范的发布版本。在本节将包括获取和编译发行版源代码,使用Maven、创建Debian或rpm软件包来进行部署。
请注意,直接从源代码构建和部署一个IaaS通常不是最有效的方式。然而,我们仍将介绍这种方法,就像构建RPMs或Debian软件包来部署CloudStack一样。
The instructions here are likely version-specific. That is, the method for building from source for the 4.7.x series is different from the 4.2.x series.
如果你正在使用一个非发行版的CloudStack,请查阅该版本主目录下的INSTALL.md文件。
下载CloudStack最新发行版,可以在 Apache CloudStack 项目下载页面:.
之前的版本同样可以通过archive.apache.org获得。请参阅下载页面上的存档版本的更多信息。
你会注意到在’最新发行版’下方有几个链接。一个链接以 tar.bz2
文件结尾,以及PGP/GPG签名,MD5和ShA512文件。
tar.bz2
文件包含使用Bzip2压缩的源代码。.asc
file is a detached cryptographic signature that can be
used to help verify the authenticity of the release..md5
file is an MD5 hash of the release to aid in verify the
validity of the release download..sha
file is a SHA512 hash of the release to aid in verify
the validity of the release download.有很多机制可以检查下载的发行版的真实性和有效性。
为了实现GPG签名验证,你需要下载 密钥 文件。
下一步需要导入这些密钥,你可以运行如下命令:
$ wget http://www.apache.org/dist/cloudstack/KEYS
$ gpg --import KEYS
CloudStack项目提供了发行版的分离GPG签名。运行如下命令检查签名:
$ gpg --verify apache-cloudstack-4.8.0-src.tar.bz2.asc
如果签名是有效的,你会看到一行包含“Good signature”的信息。
除了加密签名,CloudStack还提供了MD5校验和,用于验证下载的发行版。您可以通过执行下面的命令验证这个哈希值:
$ gpg --print-md MD5 apache-cloudstack-4.8.0-src.tar.bz2 | diff - apache-cloudstack-4.8.0-src.tar.bz2.md5
如果成功完成,你应该看不到任何输出。如果有任何输出,则说明你本地生成的哈希值与服务器上获取的是不同的。
除了MD5校验和,CloudStack还提供了SHA512加密哈希,用于验证下载的发行版。您可以通过执行下面的命令验证这个哈希值:
$ gpg --print-md SHA512 apache-cloudstack-4.8.0-src.tar.bz2 | diff - apache-cloudstack-4.8.0-src.tar.bz2.sha
如果命令成功完成,你应该看不到任何输出。如果有任何输出,则说明你本地生成的哈希值与服务器上获取的不同。
编译CloudStack所需的先决条件很多,本文假定在Linux系统上编译,使用RPMs或DEBs包管理。
如下是编译CloudStack的最低需求:
提取CloudStack发行版源代码相对简单,使用如下命令:
$ tar -jxvf apache-cloudstack-4.8.0-src.tar.bz2
你现在可以进入该目录:
$ cd ./apache-cloudstack-4.8.0-src
In addition to the bootstrap dependencies, you’ll also need to install several other dependencies. Note that we recommend using Maven 3.
$ sudo apt-get update
$ sudo apt-get install python-software-properties
$ sudo apt-get update
$ sudo apt-get install ant debhelper openjdk-7-jdk tomcat6 libws-commons-util-java genisoimage python-mysqldb libcommons-codec-java libcommons-httpclient-java liblog4j1.2-java maven
虽然我们做了一些定义,并且可能已经安装了引导的前提条件,但仍有一些在编译时需要解决的先决条件。CloudStack使用Maven进行依赖性解析。您可以通过运行以下命令,来解决编译CloudStack时的依赖性:
$ mvn -P deps
现在我们已经解决了依赖关系,可以使用如下命令编译CloudStack和创建DEB包:
$ dpkg-buildpackage -uc -us
该命令将创建如下debian软件包。应该有如下这些内容:
cloudstack-common-4.8.0.amd64.deb
cloudstack-management-4.8.0.amd64.deb
cloudstack-agent-4.8.0.amd64.deb
cloudstack-usage-4.8.0.amd64.deb
cloudstack-awsapi-4.8.0.amd64.deb
cloudstack-cli-4.8.0.amd64.deb
cloudstack-docs-4.8.0.amd64.deb
软件包创建完成后,你需要将软件包拷贝至可以提供HTTP服务的系统上。创建用于存放软件包的目录,并使用 dpkg-scanpackages
命令创建包含归档结构信息的 Packages.gz
文件。在系统中添加这个仓库源,最后使用该APT安装软件包。
第一步是确保你已经安装了 dpkg-dev 软件。一般在使用 debhelper 程序之前就已经安装了。如果你是在其他系统中生成的 Packages.gz
文件,请确保它已经被安装。
$ sudo apt-get install dpkg-dev
下一步是将DEB文件复制到提供HTTP服务的目录中。在示例中,我们使用 ``/var/www/cloudstack/repo``作为示例 ,你也可以更改为更适合你的目录。
$ sudo mkdir -p /var/www/cloudstack/repo/binary
$ sudo cp *.deb /var/www/cloudstack/repo/binary
$ cd /var/www/cloudstack/repo/binary
$ sudo sh -c 'dpkg-scanpackages . /dev/null | tee Packages | gzip -9 > Packages.gz'
注解
你可以忽略缺少覆盖文件的警告信息。
现在你应该可以通过HTTP访问 binary
目录中所有的DEB安装包和 Packages.gz
文件。(在进行下一步前,你需要使用 wget
或 curl
命令测试。)
现在,我们已经创建了仓库,然后配置你的服务器来使用APT仓库源。你可以在 /etc/apt/sources.list.d
目录中添加仓库文件。使用你喜欢的编辑器来创建``/etc/apt/sources.list.d/cloudstack.list`` 文件并加入类似如下信息:
deb http://server.url/cloudstack/repo/binary ./
现在,您已经准备好软件仓库,然后更新以下,使得APT知道从哪里找到CloudStack的软件包。
$ sudo apt-get update
现在可以翻到在Ubuntu上安装CloudStack的一章去了。
正如先前 `“编译Apache CloudStack的先决条件 <#prerequisites-for-building-apache-cloudstack>`_所说,在编译CloudStack之前需要安装一些先决条件。这里假设你使用的是64位的CentOS或Red Hat Enterprise Linux.
# yum groupinstall "Development Tools"
# yum install java-1.7.0-openjdk-devel.x86_64 genisoimage mysql mysql-server ws-commons-util MySQL-python tomcat6 createrepo
Next, you’ll need to install build-time dependencies for CloudStack with Maven. We’re using Maven 3, so you’ll want to grab Maven 3.0.5 (Binary tar.gz) and uncompress it in your home directory (or whatever location you prefer):
$ cd ~
$ tar zxvf apache-maven-3.0.5-bin.tar.gz
$ export PATH=~/apache-maven-3.0.5/bin:$PATH
Maven还需要知道Java程序路径,和JAVA_HOME环境变量输出的设置:
$ export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk.x86_64
验证Maven是否被正确安装:
$ mvn --version
如果想确保环境变量将在注销或重启后仍保留。一定要更新 ~/.bashrc
中的PATH和JAVA_HOME 变量。
编译CloudStack的RPM包相当简单。假设你已经下载了源码并解压压缩文件到一个本地目录中,你可以在几分钟之内完成编译。
注解
打包方式的变化。如果你之前创建过CloudStack软件包,你会意识到自从该项目开始使用Apache Maven,这个步骤发生了很大变化。请一定要密切关注本节中的步骤。
Now that we have the prerequisites and source, you will cd to the packaging/ directory.
$ cd packaging/
使用 package.sh
脚本生成RPM包:
$ ./package.sh -d centos6
这会需要一些时间,生成的软件包会在 dist/rpmbuild/RPMS/x86_64/
目录中。
你应该看到目录中的RPM包:
cloudstack-agent-4.8.0.el6.x86_64.rpm
cloudstack-awsapi-4.8.0.el6.x86_64.rpm
cloudstack-cli-4.8.0.el6.x86_64.rpm
cloudstack-common-4.8.0.el6.x86_64.rpm
cloudstack-docs-4.8.0.el6.x86_64.rpm
cloudstack-management-4.8.0.el6.x86_64.rpm
cloudstack-usage-4.8.0.el6.x86_64.rpm
RPMs是一个有用的包装格式 - 通过网络上YUM仓库来使用是非常简单的。下一步是使用这些软件包创建YUM仓库:
$ mkdir -p ~/tmp/repo
$ cd ../..
$ cp dist/rpmbuild/RPMS/x86_64/*rpm ~/tmp/repo/
$ createrepo ~/tmp/repo
~/tmp/repo
中的文件和目录现在可以上传到WEB服务器中作为YUM仓库。
现在你的yum仓库中拥有了RPM包和元数据,我们为需要安装CloudStack的机器创建一个名为``/etc/yum.repos.d/cloudstack.repo``的文件,内容如下:
[apache-cloudstack]
name=Apache CloudStack
baseurl=http://webserver.tld/path/to/repo
enabled=1
gpgcheck=0
完成这一步,您可以轻松地在整个网络中的机器上安装CloudStack。
如果你需要支持VMware,NetAPP,F5,NetScaler,SRX或其他非开源软件(nonoss)插件。你需要下载一些独立的组件并遵循从源代码构建稍微不同的过程。
警告
因为许可的问题,一些CloudStack支持的插件不能与CloudStack一起发行。一些原因是,所需要的一些库或JAR文件都有专用的许可。另外一些是因为所需要第三方产品库的许可证不能与Apache的许可相兼容,见`针对第三方产品的Apache许可指南 <http://www.apache.org/legal/resolved.html#category-x>`_.
为了编译NON-OSS插件,你需要安装必要的JAR在``deps`` 目录中。
由于这些模块需要的依赖项不能和CloudStack一起发行,你需要自行下载。最新的依赖项都列在wiki页面中:*如何编译CloudStack*
你可能还需要下载`vhd-util <http://download.cloud.com.s3.amazonaws.com/tools/vhd-util>`_, 也是由于授权问题而被移除。 复制vhd-util到该目录: scripts/vm/hypervisor/xenserver/
.
一旦你复制过来所有的依赖项,你就可以开始使用 noredist
选项编译CloudStack了。
$ mvn clean
$ mvn install -Dnoredist
noredist
配置文件,你可以使用 “从源码编译RPM包” 或 “编译DEB包” 指令打包。For those who have already gone through a design phase and planned a more sophisticated deployment, or those who are ready to start scaling up a trial installation. With the following procedures, you can start using the more powerful features of CloudStack, such as advanced VLAN networking, high availability, additional network elements such as load balancers and firewalls, and support for multiple hypervisors including Citrix XenServer, KVM, and VMware vSphere.
For anything more than a simple trial installation, you will need guidance for a variety of configuration choices. It is strongly recommended that you read the following:
The machines that will run the Management Server and MySQL database must meet the following requirements. The same machines can also be used to provide primary and secondary storage, such as via localdisk or NFS. The Management Server may be placed on a virtual machine.
The host is where the cloud services run in the form of guest virtual machines. Each host is one machine that meets the following requirements:
Hosts have additional requirements depending on the hypervisor. See the requirements listed at the top of the Installation section for your chosen hypervisor:
警告
Be sure you fulfill the additional hypervisor requirements and installation steps provided in this Guide. Hypervisor hosts must be properly prepared to work with CloudStack. For example, the requirements for XenServer are listed under Citrix XenServer Installation.
CloudStack is only distributed from source from the official mirrors. However, members of the CloudStack community may build convenience binaries so that users can install Apache CloudStack without needing to build from source.
If you didn’t follow the steps to build your own packages from source in the sections for “Building RPMs from Source” or “Building DEB packages” you may find pre-built DEB and RPM packages for your convenience linked from the downloads page.
注解
These repositories contain both the Management Server and KVM Hypervisor packages.
This section describes installing the Management Server. There are two slightly different installation flows, depending on how many Management Server nodes will be in your cloud:
In either case, each machine must meet the system requirements described in Minimum System Requirements.
警告
For the sake of security, be sure the public Internet can not access port 8096 or port 8250 on the Management Server.
The procedure for installing the Management Server is:
The OS must be prepared to host the Management Server using the following steps. These steps must be performed on each Management Server node.
Log in to your OS as root.
Check for a fully qualified hostname.
hostname --fqdn
This should return a fully qualified hostname such as “management1.lab.example.org”. If it does not, edit /etc/hosts so that it does.
Make sure that the machine can reach the Internet.
ping www.cloudstack.org
Turn on NTP for time synchronization.
注解
NTP is required to synchronize the clocks of the servers in your cloud.
Install NTP.
yum install ntp
sudo apt-get install openntpd
Repeat all of these steps on every host where the Management Server will be installed.
The first step in installation, whether you are installing the Management Server on one host or many, is to install the software on a single node.
注解
If you are planning to install the Management Server on multiple nodes for high availability, do not proceed to the additional nodes yet. That step will come later.
The CloudStack Management server can be installed using either RPM or DEB packages. These packages will depend on everything you need to run the Management server.
CloudStack is only distributed from source from the official mirrors. However, members of the CloudStack community may build convenience binaries so that users can install Apache CloudStack without needing to build from source.
If you didn’t follow the steps to build your own packages from source in the sections for “Building RPMs from Source” or “Building DEB packages” you may find pre-built DEB and RPM packages for your convenience linked from the downloads page.
注解
These repositories contain both the Management Server and KVM Hypervisor packages.
There is a RPM package repository for CloudStack so you can easily install on RHEL based platforms.
If you’re using an RPM-based system, you’ll want to add the Yum repository so that you can install CloudStack with Yum.
Yum repository information is found under /etc/yum.repos.d
. You’ll
see several .repo
files in this directory, each one denoting a
specific repository.
To add the CloudStack repository, create
/etc/yum.repos.d/cloudstack.repo
and insert the following
information.
[cloudstack]
name=cloudstack
baseurl=http://cloudstack.apt-get.eu/centos/6/4.8/
enabled=1
gpgcheck=0
Now you should be able to install CloudStack using Yum.
You can add a DEB package repository to your apt sources with the following commands. Please note that only packages for Ubuntu 12.04 LTS (precise) and Ubuntu 14.04 (trusty) are being built at this time.
Use your preferred editor and open (or create)
/etc/apt/sources.list.d/cloudstack.list
. Add the community provided
repository to the file:
deb http://cloudstack.apt-get.eu/ubuntu precise 4.8
We now have to add the public key to the trusted keys.
sudo wget -O - http://cloudstack.apt-get.eu/release.asc|apt-key add -
Now update your local apt cache.
sudo apt-get update
Your DEB package repository should now be configured and ready for use.
yum install cloudstack-management
sudo apt-get install cloudstack-management
This procedure is required only for installations where XenServer is installed on the hypervisor hosts.
Before setting up the Management Server, download
vhd-util from
http://download.cloud.com.s3.amazonaws.com/tools/vhd-util.
and copy it into /usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver
of the Management Server.
The CloudStack management server uses a MySQL database server to store its data. When you are installing the management server on a single node, you can install the MySQL server locally. For an installation that has multiple management server nodes, we assume the MySQL database also runs on a separate node.
CloudStack has been tested with MySQL 5.1 and 5.5. These versions are included in RHEL/CentOS and Ubuntu.
This section describes how to install MySQL on the same machine with the Management Server. This technique is intended for a simple deployment that has a single Management Server node. If you have a multi-node Management Server deployment, you will typically use a separate node for MySQL. See Install the Database on a Separate Node.
Install MySQL from the package repository of your distribution:
yum install mysql-server
sudo apt-get install mysql-server
Open the MySQL configuration file. The configuration file is
/etc/my.cnf
or /etc/mysql/my.cnf
, depending on your OS.
Insert the following lines in the [mysqld]
section.
You can put these lines below the datadir line. The max_connections parameter should be set to 350 multiplied by the number of Management Servers you are deploying. This example assumes one Management Server.
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'
注解
You can also create a file /etc/mysql/conf.d/cloudstack.cnf
and add these directives there. Don’t forget to add [mysqld]
on the
first line of the file.
Start or restart MySQL to put the new configuration into effect.
On RHEL/CentOS, MySQL doesn’t automatically start after installation. Start it manually.
service mysqld start
On Ubuntu, restart MySQL.
sudo service mysql restart
(CentOS and RHEL only; not required on Ubuntu)
警告
On RHEL and CentOS, MySQL does not set a root password by default. It is very strongly recommended that you set a root password as a security precaution.
Run the following command to secure your installation. You can answer “Y” to all questions.
mysql_secure_installation
CloudStack can be blocked by security mechanisms, such as SELinux. Disable SELinux to ensure + that the Agent has all the required permissions.
Configure SELinux (RHEL and CentOS):
Check whether SELinux is installed on your machine. If not, you can skip this section.
In RHEL or CentOS, SELinux is installed and enabled by default. You can verify this with:
rpm -qa | grep selinux
Set the SELINUX variable in /etc/selinux/config
to
“permissive”. This ensures that the permissive setting will be
maintained after a system reboot.
In RHEL or CentOS:
vi /etc/selinux/config
Change the following line
SELINUX=enforcing
to this:
SELINUX=permissive
Set SELinux to permissive starting immediately, without requiring a system reboot.
setenforce permissive
Set up the database. The following command creates the “cloud” user on the database.
cloudstack-setup-databases cloud:<dbpassword>@localhost \
--deploy-as=root:<password> \
-e <encryption_type> \
-m <management_server_key> \
-k <database_key> \
-i <management_server_ip>
When this script is finished, you should see a message like “Successfully initialized the database.”
注解
If the script is unable to connect to the MySQL database, check the
“localhost” loopback address in /etc/hosts
. It should be pointing to
the IPv4 loopback address “127.0.0.1” and not the IPv6 loopback address
::1
. Alternatively, reconfigure MySQL to bind to the IPv6 loopback
interface.
If you are running the KVM hypervisor on the same machine with the Management Server, edit /etc/sudoers and add the following line:
Defaults:cloud !requiretty
Now that the database is set up, you can finish configuring the OS for the Management Server. This command will set up iptables, sudoers, and start the Management Server.
cloudstack-setup-management
You should get the output message “CloudStack Management Server setup is done.” If the servlet container is Tomcat7 the argument –tomcat7 must be used.
This section describes how to install MySQL on a standalone machine, separate from the Management Server. This technique is intended for a deployment that includes several Management Server nodes. If you have a single-node Management Server deployment, you will typically use the same node for MySQL. See “Install the Database on the Management Server Node”.
注解
The management server doesn’t require a specific distribution for the MySQL node. You can use a distribution or Operating System of your choice. Using the same distribution as the management server is recommended, but not required. See “Management Server, Database, and Storage System Requirements”.
Install MySQL from the package repository from your distribution:
yum install mysql-server
sudo apt-get install mysql-server
Edit the MySQL configuration (/etc/my.cnf or /etc/mysql/my.cnf, depending on your OS) and insert the following lines in the [mysqld] section. You can put these lines below the datadir line. The max_connections parameter should be set to 350 multiplied by the number of Management Servers you are deploying. This example assumes two Management Servers.
注解
On Ubuntu, you can also create /etc/mysql/conf.d/cloudstack.cnf file and add these directives there. Don’t forget to add [mysqld] on the first line of the file.
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=700
log-bin=mysql-bin
binlog-format = 'ROW'
bind-address = 0.0.0.0
Start or restart MySQL to put the new configuration into effect.
On RHEL/CentOS, MySQL doesn’t automatically start after installation. Start it manually.
service mysqld start
On Ubuntu, restart MySQL.
sudo service mysql restart
(CentOS and RHEL only; not required on Ubuntu)
警告
On RHEL and CentOS, MySQL does not set a root password by default. It is very strongly recommended that you set a root password as a security precaution. Run the following command to secure your installation. You can answer “Y” to all questions except “Disallow root login remotely?”. Remote root login is required to set up the databases.
mysql_secure_installation
If a firewall is present on the system, open TCP port 3306 so external MySQL connections can be established.
On Ubuntu, UFW is the default firewall. Open the port with this command:
ufw allow mysql
On RHEL/CentOS:
Edit the /etc/sysconfig/iptables file and add the following line at the beginning of the INPUT chain.
-A INPUT -p tcp --dport 3306 -j ACCEPT
Now reload the iptables rules.
service iptables restart
Return to the root shell on your first Management Server.
Set up the database. The following command creates the cloud user on the database.
cloudstack-setup-databases cloud:<dbpassword>@<ip address mysql server> \
--deploy-as=root:<password> \
-e <encryption_type> \
-m <management_server_key> \
-k <database_key> \
-i <management_server_ip>
When this script is finished, you should see a message like “Successfully initialized the database.”
Now that the database is set up, you can finish configuring the OS for the Management Server. This command will set up iptables, sudoers, and start the Management Server.
cloudstack-setup-management
You should get the output message “CloudStack Management Server setup is done.”
For your second and subsequent Management Servers, you will install the Management Server software, connect it to the database, and set up the OS for the Management Server.
Perform the steps in “Prepare the Operating System” and “Building RPMs from Source” or “Building DEB packages” as appropriate.
This step is required only for installations where XenServer is installed on the hypervisor hosts.
Download vhd-util from vhd-util
Copy vhd-util to
/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver
.
Ensure that necessary services are started and set to start on boot.
service rpcbind start
service nfs start
chkconfig nfs on
chkconfig rpcbind on
Configure the database client. Note the absence of the –deploy-as argument in this case. (For more details about the arguments to this command, see Install the Database on a Separate Node.)
cloudstack-setup-databases cloud:dbpassword@dbhost \
-e encryption_type \
-m management_server_key \
-k database_key \
-i management_server_ip
Configure the OS and start the Management Server:
cloudstack-setup-management
The Management Server on this node should now be running. If the servlet container is Tomcat7 the argument –tomcat7 must be used.
Repeat these steps on each additional Management Server.
Be sure to configure a load balancer for the Management Servers. See “Management Server Load Balancing”.
Secondary storage must be seeded with a template that is used for CloudStack system VMs.
注解
When copying and pasting a command, be sure the command has pasted as a single line before executing. Some document viewers may introduce unwanted line breaks in copied text.
On the Management Server, run one or more of the following
cloud-install-sys-tmplt
commands to retrieve and decompress the
system VM template. Run the command for each hypervisor type that you
expect end users to run in this Zone.
If your secondary storage mount point is not named /mnt/secondary
,
substitute your own mount point name.
If you set the CloudStack database encryption type to “web” when you
set up the database, you must now add the parameter -s
<management-server-secret-key>
. See About Password and Key Encryption.
This process will require approximately 5 GB of free space on the local file system and up to 30 minutes each time it runs.
For Hyper-V
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /mnt/secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-hyperv.vhd.zip \
-h hyperv \
-s <optional-management-server-secret-key> \
-F
For XenServer:
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /mnt/secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-xen.vhd.bz2 \
-h xenserver \
-s <optional-management-server-secret-key> \
-F
For vSphere:
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /mnt/secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-vmware.ova \
-h vmware \
-s <optional-management-server-secret-key> \
-F
For KVM:
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /mnt/secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-kvm.qcow2.bz2 \
-h kvm \
-s <optional-management-server-secret-key> \
-F
For LXC:
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /mnt/secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-kvm.qcow2.bz2 \
-h lxc \
-s <optional-management-server-secret-key> \
-F
For OVM3:
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
-m /mnt/secondary \
-u http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-ovm.raw.bz2 \
-h ovm3 \
-s <optional-management-server-secret-key> \
-F
If you are using a separate NFS server, perform this step. If you are using the Management Server as the NFS server, you MUST NOT perform this step.
When the script has finished, unmount secondary storage and remove the created directory.
umount /mnt/secondary
rmdir /mnt/secondary
Repeat these steps for each secondary storage server.
Congratulations! You have now installed CloudStack Management Server and the database it uses to persist system data.
What should you do next?
这一章节的内容将会告诉你如何增加地域,区域,提供点,集群,主机,存储和网络。如果你不熟悉这些概念,可以参阅: *云基础设施的概念*.
当管理节点服务器安装结束并正常运行之后,你可以开始将计算资源池纳入其管理范围。关于CloudStack云计算系统是如何组织构架的,请参阅:“Cloud Infrastructure Overview”.
准备云基础架构,或是进行扩展时,请遵从如下步骤:
当你完成这些步骤以后, 你将部署如下的一个基本结构:
在部署云的过程中将云资源按地域组织起来是是一个可选的步骤。关于地域的描述,可以参阅 “关于地域”.
如果你没有执行任何操作来定义地域, 那么云环境中所有的资源域都会组织到一个默认的地域里. 这个地域的ID是1。当然,你可以通过CloudStack的WEB UI来编辑此默认地域的名称和URL网址。
通过下面的步骤来添加除默认地域外的第二个地域.
每一个地域都有专属的CloudStack实例。因此,当你要部署一个新的地域时,首先要做的就是在一个或多个节点上安装管理节点服务器。在按照安装指南安装此节点的数据库时,需要在命令行上加上参数 -r <region_id>
。默认的地域的region ID为1,故而第一个新增地域的region ID应该为2.
# cloudstack-setup-databases cloud:<dbpassword>@localhost --deploy-as=root:<password> -e <encryption_type> -m <management_server_key> -k <database_key> -r <region_id>
在安装过程结束后, 管理服务器应该是运行状态. 请确保管理服务器安装完成并正确运行.
现在,开始在 CloudStack内加入一个新的地域。
现在,执行一次相同的操作,在地域2中加入默认地域1.
将帐号,用户,域信息数据表从地域1的数据库拷贝到地域2数据库中。
接下来的操作,你需要确保已设置好MYSQL数据库的root用户密码,这也是CloudStack推荐的操作。
首先,运行这个命令拷贝数据库的内容:
# mysqldump -u root -p<mysql_password> -h <region1_db_host> cloud account user domain > region1.sql
然后,运行这条命令将数据放入地域2的MYSQL数据库:
# mysql -u root -p<mysql_password> -h <region2_db_host> cloud < region1.sql
删除项目帐户. 在地域2的数据库中运行如下命令:
# mysql> delete from account where type = 5;
设置默认区域为空白(NULL):
# mysql> update account set default_zone_id = null;
重新启动地域2中的管理节点服务。
增加第三个或是更多地域的操作与增加第二个地域的操作类似,但是,你必须重复这几个特定的操作步骤:
在每个额外的地域中安装CloudStack管理节点,并在安装数据库时为其设置不同的地域ID(region ID)。
cloudstack-setup-databases cloud:<dbpassword>@localhost --deploy-as=root:<password> -e <encryption_type> -m <management_server_key> -k <database_key> -r <region_id>
一旦新地域的CloudStack管理服务器处于运行状态,在CloudStack WEB UI中使用添加地域按钮增加新的地域。以下以新增地域3作为示例:
在新的地域里,也同样增加所有的已存在的域域,例如,如果新地域是第三个CLOUDSTACK地域,刚需要其WEB UI里增加前两个地域信息:
将帐号,用户,域信息数据表从已存在的地域的数据库拷贝到新的地域里。
接下来的操作,你需要确保已设置好MYSQL数据库的root用户密码,这也是CloudStack推荐的操作。
首先,运行这个命令拷贝数据库的内容:
# mysqldump -u root -p<mysql_password> -h <region1_db_host> cloud account user domain > region1.sql
然后,运行这个命令将数据库的内容放到新的地域数据库当中去(如地域3):
# mysql -u root -p<mysql_password> -h <region3_db_host> cloud < region1.sql
在地域3上运行这些命令,以便删除项目管理帐号:
mysql> delete from account where type = 5;
设置默认区域为空白(NULL):
mysql> update account set default_zone_id = null;
在新地域里重启CLOUDSTACK管理节点的服务。
登陆到CLOUDSTACK的WEB UI,点击区域导航栏,选择你想删除的地域,然后,删除。例如,如果你想删除地域3:
当你要增加一个新的区域时,你会被提示需要同时配置物理网络以前第一个机柜提供点,集群,宿主机,主存储,二级存储。
当你选择了基本区域之后,你需要输入以下细节信息,才能进入下一步。
名称. 为这个区域命名
DNS 1 和 2. 这些DNS是提供给区域里的客户虚拟机使用的。这些DNS服务器IP访问是通过随后添加的公网进行的。此区域的公网IP地址必须能够路由到这些DNS服务器。
内部 DNS 1 和内部 DNS 2. 区域内的系统虚拟机会用到这些DNS服务器(系统虚拟机是CLOUDSTACK本身会用到的虚拟机如虚拟路由器-VR,控制台代理虚拟机-CPVM,二级存储虚拟机-SSVM),这些系统虚拟机通过管理网络访问这个DNS服务器。为机柜提供点配置的私有IP地址必须能路由到这些内部DNS服务器。
**Hypervisor.**(在version 3.0.1介绍过) 需要为区域内的第一个集群选择一种hypervisor。当你完成添加区域的配置之后,也可以为另外的集群配置不同的hypervisor。
网络方案。 你需要客户虚拟机可用的网络方案及服务
网络方案 | 描述 |
---|---|
DefaultSharedNetworkOfferingWithSGService | 如果你希望通过安全组来隔离客户虚拟机流量,选择这个选项。(参看通过安全组隔离虚拟机这一章节。) |
DefaultSharedNetworkOffering | 如果你需要安全组,选择这个选项。 |
DefaultSharedNetscalerEIPandELBNetworkOffering | 如果,你在CLOUDSTACK内安装了Citrix NetScaler应用,并且你需要Elastic IP和Elastic Load Balancing这些功能的话,选择这个选项。EIP 和ELB技术在安全组启用的情况下,可以提供1:1的NAT映射和负载均衡功能。 |
网络域 (可选) 如果你想为客户虚机网络定义一个域名,在此处输入后缀名。
公有区域. 一个公有区域可以被所有用户使用。而非公有区域会有一个指定的域名,只有指定域名中的用户才可以在那个区域里创建客户虚拟机。
选择在物理网络里需要承载的流量类型。
流量类型分为管理流量,公网流量,来宾客户流量,和存储流量。关于这些流量的更多信息,可以点击相关图标得到一些帮助。这个屏幕显示的是已分配好的流量类型。如果要继续增加,可以拖动相关流量类型到网络里,当然,也可以将网络更改成你认为合适的名字。
为物理网络上承载的每一种CLOUDSTACK网络流量类型赋予一个标签。这些标签必须与你已在宿主机上设置的(网桥)标签名一致。如果要编辑标签,点击流量类型上的编辑按钮,在弹出的对话框中输入相应名称,然后再点击OK即可。
这些流量类型标签只是定义了区域内的第一个集群的hypervisor。对于其它hypervisor,则这个标签可以在区域创建完成之后配置。
点击下一步
(只针对NetScaler) 如果你选择的网络方案是针对NetScaler的,则还要一个额外的选项需要填写。在填写了关于NetScaler的细节信息之后,点击下一步继续。
(只针对NetScaler) 设置公网的IP范围。此IP范围用作启用了EIP和ELB技术的网络方案的NAT映射。输入这些细节信息,点击增加。如果有必要,你可以重复输入多个公网IP范围。当这一切完成之后,点击下一步继续。
在一个新的区域,CLOUSTACK总是会为你添加第一个机柜提供点。当然,在区域设置完成之后,你可以添加理多的机柜提供点。关于机柜提供点的详细,参看此URL:“About Pods”.
开始配置第一个机柜提供点,输入以下这些信息,然后点击下一步继续。
为客户来宾配置网络,提供好如下信息,然后点击下一步。
在一个新的机柜提供点里,CLOUDSTACK会为你加第一个群集。当然,你也可以以后再添加其它的群集。如果想多了解群集,你可以参看群集的相关章节。
配置第一个群集,输入以下这些信息,然后点击下一步。
在一个新的群集里,CLOUDSTACK会添加第一个宿主机。当然,之后你可以添加更多的宿主机。关于宿主机的概念,可以参看About Hosts的章节。
注解
当你往CLOUDSTACK里新增一个hypervisor宿主机时,此宿主机上一定不能有虚拟机在运行(全新的宿主机)。
当你在配置宿主机之后,你需要在宿主机上安装hypervisor软件。你也需要事先了解CLOUDSTACK所能支持的hypervisor种类及版本,以及是否需要额外的配置信息。关于这些配置的详细信息,参看:
配置第一个宿主机,输入以下信息,然后点击下一步:
在一个新的群集里,CLOUDSTACK会添加第一个主存储。当然,你也可以在随后添加更多的主存储。关于主存储的细节,可以参看相关章节:Primary Storage
配置第一个主存储,输入以下信息,然后点击下一步:
当你选择高级区域以后,你需要提供以下信息,然后点击下一步。
选择在物理网络里需要承载的流量类型。
The traffic types are management, public, guest, and storage traffic. For more information about the types, roll over the icons to display their tool tips, or see “Advanced Zone Network Traffic Types”. This screenstarts out with one network already configured. If you have multiple physical networks, you need to add more. Drag and drop traffic types onto a greyed-out network and it will become active. You can move the traffic icons from one network to another; for example, if the default traffic types shown for Network 1 do not match your actual setup, you can move them down. You can also change the network names if desired.
(在3.0.1版本中介绍过)为每一种不同的物理网络分配不同的网络流量标签。这些标签必须和你在hypervisor主机中定义的标签一致。更改标签名,可以在每一个物理网络里点击相应的流量标签的编辑按钮,一个对话框会跳出来,输入合适的标签之后,点击下一步。
这些流量类型标签只是定义了区域内的第一个集群的hypervisor。对于其它hypervisor,则这个标签可以在区域创建完成之后配置。
(只针对VMWARE)如果你的环境中有Nexus分布式虚拟交换机(dvSwitch),则必须为每一种物理网络上的流量类型的标签指定为相应的局域网端口配置名称(Ethernet port profile names).关于Nexus dvSwitch更多信息,可以查看安装指南的相关章节。如果你的环境中有VMware的分布式虚拟交换机(dvSwitch),,则必须为每一种物理网络上的流量类型的标签指定为相应的虚拟交换机名称(Switch name)。关于这方面的更多信息,参看安装指南当中的关于VMware Datacenter的相关章节。
点击下一步
配置公网IP地址范围,输入以下细节,然后点击添加。如果需要,你可以重复此过程以便添加更多的公网IP地址。当这一切完成之后,点击下一步。
在一个新的区域,CLOUSTACK总是会为你添加第一个机柜提供点。当然,在区域设置完成之后,你可以添加理多的机柜提供点。关于机柜提供点的详细,参看此URL:“About Pods”.
开始配置第一个机柜提供点,输入以下这些信息,然后点击下一步继续。
定义每个物理网络上的客户流量的VLAN ID范围(参看 VLAN 分配示例 ),然后点击下一步。
在一个新的机柜提供点,CLOUDSTACK会添加第一个群集。当然,随后你可以添加更多的群集。关于什么是群集,参阅 “关于群集”.
配置第一个群集,输入以下这些信息,然后点击下一步。
在一个新的群集,CLOUDSTACK会添加好第一个宿主机,随后,你也可以自行添加更多的宿主机。关于什么是宿主机,参阅 “关于主机”.
注解
当你开始部署CLOUDSTACK时,hypervisor宿主机必须不能有已在运行的虚拟机。
当你在配置宿主机之后,你需要在宿主机上安装hypervisor软件。你也需要事先了解CLOUDSTACK所能支持的hypervisor种类及版本,以及是否需要额外的配置信息。关于这些配置的详细信息,参看:
配置第一个宿主机,输入以下信息,然后点击下一步:
在一个新的群集,CLOUDSTACK会添加好第一台主存储服务器,随后,你也可以自行添加更多的存储服务器。关于什么是主存储服务器,参阅 “关于主存储”.
配置第一个主存储,输入以下信息,然后点击下一步:
名称 存储设备的名称
协议 对于XenServer,选择NFS, iSCSI, 或 PreSetup.对于KVM,选择NFS, SharedMountPoint,CLVM, 或RBD.对于VSPHERE,选择VMFS(iSCSI 或FiberChannel)或NFS。本栏的其它选择依你选项不同而不同。
NFS |
|
iSCSI |
|
preSetup |
|
SharedMountPoint |
|
VMFS |
|
在区域的群集中当,主存储的标签都必须是唯一的。比如,如果你在A群集当中提供的主存储的标签为T1和T2,那么,你在同一个区域的另一个群集提供的主存储标签也必须为T1和T2。
在一个新的区域里,CLOUDSTACK会添加第一个二级存储。关于什么是二级存储,请参阅 “关于辅助存储”。
当你在填写这些信息时,你需要准备好二级存储的NFS共享,并且安装好CLOUDSTACK最新的系统虚拟机模板。更多信息,可以查看Adding Secondary Storage :
点击启动
当你添加一个区域时,CLOUDSTACK会添加第一个机柜提供点。用本章节的办法,你可以随时添加更多的机柜提供点。
你需要告诉CLOUDSTACK它所能管理的宿主机。宿主机存在于群集内,所以,在为云里添加主机之后,必须先至少存在一个群集。
这些步骤确保你已在宿主机上安装好hypervisor,并且已登陆CLOUDSTACK的WEB UI。
对于VSPHERE的主机管理是结合VCENTER和CLOUDSTACK WEB UUI管理界面一起完成的。CLOUDSTACK需要所有的主机都在同一个群集里,但群集可能只是由一个主机构成。作为一个管理员,你必须决定到底是使用一个主机一个群集还是多个主机一个群集。多个主机一个群集,可以实现CLOUDSTACK的一些高级功能,如热迁移等。当然,此群集需要有NFS或ISCSI等这个共享存储支持。
对于VSPHERRE服务器,我们推荐的方案是先在VCENTER里建好群集,然后将整个群集加入到CLOUDSTACK群集中。这个群集需要以下条件:
在CLOUDSTACK中添加一个VSHPERE群集:
在VCENTER里新建一个群集。请参看VCENTER的相关操作指地完成这一。在VCENTER里建立群集的大致过程如下:
登陆到UI界面。
在左右的导航栏里,点击基础架构。在区域里,点击查看全部。然后点击你想增加群集所在的区域。
点击计算标签。在机柜提供点栏里点击查看全部。选择你想添加群集的机柜提供点。
点击查看群集。
点击增加群集。
在Hypervisor里,选择VMware。
提供界面要求的如下信息。这些信息的值可以参考VCENTER中对应的值。
群集名称:输入你在VCENTER中创建的群集名称。比如:”cloud.cluster.2.2.1”
vCenter用户名:输入CLOUDSTACK连接到VCENTER所用的用户名。这个用户名必须要有所有的管理权限。
CPU超配比率: 输入此群集的CPU超配比率。这个比率值决定了群集内每台虚拟机的CPU耗用比率。增加这个数据,则能使用更多的资源。如果不设置此值的话,默认值为1,这就表示没有使用超配。
RAM超配比率:输入RAM的超配比率。这个比率值决定了群集内每台虚拟机的MEM耗用比率。增加这个数据,则能使用更多的资源。如果不设置此值的话,默认值为1,这就表示没有使用超配。
vCenter主机: VCENTER的主机的IP地址或主机名。
vCenter密码: 输入上面用户的密码。
vCenter Datacenter:输入此群集拥有的vCenter Datacenter名称,比如:”cloud.dc.VM”.
重用公共网络流量:启用这个选项,则可以在区域的范围内重用公共网络流量。
公共流量vSwitch类型: 这个选项只有在你启用了Override Public Traffic之后才会显示出来,你可以选择一种合适的虚拟交换机。如果vmware.use.dvswitch这个全局参数设置为true,则默认选项为VMware vNetwork Distributed Virtual Switch.
如果你启用了Nexus dvSwitch,下面关于dvSwitch的数据也需要设置:
重用客户机流量:如果选中此项,则会在全区域范围内重用客户机流量。
Guest Traffic vSwitch Type:只有当the Override Guest Traffic选项启用后才会出现。为此选择一种合适的虚拟交换机类型。
如果全局参数vmware.use.dvswitch为true,则默认的选项为VMware vNetwork Distributed Virtual Switch。
如果你启用了Nexus dvSwitch,下面关于dvSwitch的数据也需要设置:
当群集建好之后,会有稍稍的迟延之后,才会有UI里显示出来。
当你在添加一个新的宿主机之后,你必须先在宿主机上安装一种hypervisor。CLOUDSTACK是可以管理多种hypervisor的。
CLOUDSTACK安装指南提供了如何安装配置各种hypervisor的步骤。你可以参考相关章节找到你所使用的hypervisor的安装指南,以及为了加入CLOUDSTACK而需要的额外的配置步骤。
警告
确保你已按CLOUDSTACK的要求,安装并设置好了hypervisor。
现在,可以添加hypervisor主机到CLOUDSTACK了。具体的添加技巧和过程取决于使选用的hypervisor类型。
XenServer和KVM可以在任何时间被加入CLOUDSTACK群集。
警告
确保 hypervisor在加入CLOUDSTACK前没有运行任何虚拟机。
配置需求:
硬件方面的需求,请参看CLOUDSTACK安装指南中关于你具体安装的hypervisor的要求。
如果使用了网卡绑定,管理员必须和群集中其它主机一样连接网线到这个新的主机
对于要加入群集的其它主机,运行下面的命令就会将主机加入XenServer计算池内。
# xe pool-join master-address=[master IP] master-username=root master-password=[your password]
注解
当复制和粘贴命令时,请确保没有多余的换行符,因为一些文档查看器可能会在复制时加上换行符。
当所有主机都加入XenServer计算池后,运行cloud-setup-bond脚本。这个脚本将会完成配置工作,并且在群集的新主机里设置相关的绑定。
将管理服务器中/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/cloud-setup-bonding.sh拷贝到master主机中并确认该脚本可执行。
运行脚本:
# ./cloud-setup-bonding.sh
如果使用了共享挂载存储,则管理员要确保群集里所有新机方和其它主机一样有相同的存储挂载点。
确保新主机和群集内其它主机有一个的网络设置(客户机,内网,外网网络)。
如果在CLOUDSTACK中使用了OpenVswitch网桥,则在操作前,需要将KVM计算主机上的agent.properties文件的network.bridge.type参数设置为openvswitch。
If you’re using a non-root user to add a KVM host, please add the user to sudoers file:
cloudstack ALL=NOPASSWD: /usr/bin/cloudstack-setup-agent defaults:cloudstack !requiretty
如果你还没有这么作,就需要在主机上安装hypervisor软件。你需要知道CLOUDSTACK支持哪些hypervisor,以及主机上还需要哪个特别的配置。可以参看CLOUDSTACK安装指南的相关章节,找到具体的安装信息。
作为管理员登录到CloudStack用户界面。
在左边的导航栏里,点击区域基础架构。在区域里,点击查看全部。然后在相应的区域里添加主机。
点击计算标签。在群集节点里,点击查看全部。
在相应的群集里添加主机。
点击查看主机。(此处主机即可此翻译文档中宿主机的同一概念。)
点击添加主机
提供主机的如下信息。
在主机添加好之后,可能会有稍稍的延迟才会有WEB UI界面中显示出来。
在其它宿主机上复杂此操作过程。
对于vSphere主机,我们推荐先在VCENTER里建好群集,然后将整个群集加入CLOUDSTACK。关于如何在VCENTER里添加群集,可以参看VSPHERE的相关内容章节。
硬件要求:
当添加主存储时,存在以下这些限制:
当你添加一个新的区域时,主存储作为操作过程的一个步骤已建好。以后,你也可以随时添加主存储。当在添加新的群集或是添加新的主机时都可以添加主存储。
警告
如果提前准备好了主存储,请确认主存储目录里没有任何数据(比如空的SAN卷或NFS共享目录)。将主存储加入CLOUDSTACK时,会清除主存储里的一切数据。
登陆CloudStack用户界面。(参阅 “Log In to the UI”)。
在左侧导航栏中,点击基础架构,在区域中,点击 查看更多,然后点击你所需要添加主存储的区域名称。
点击计算这个标签。
在结构图的主存储节点上,点击 查看全部。
点击 添加主存储
提供弹出对话框中所需要的信息。依据你所选协议的不同,所需的信息会有所不同。
在区域的群集中当,主存储的标签都必须是唯一的。比如,如果你在A群集当中提供的主存储的标签为T1和T2,那么,你在同一个区域的另一个群集提供的主存储标签也必须为T1和T2。
点击确定。
注解
Primary storage that is based on a custom plug-in (ex. SolidFire) must be added through the CloudStack API (described later in this section). There is no support at this time through the CloudStack UI to add this type of primary storage (although most of its features are available through the CloudStack UI).
注解
SolidFire存储插件是CloudStack标准安装的一部分,不需要另做其他准备工作。
基于SolidFire插件添加的主存储能够使CloudStack提供较好的QoS保证。
When used with Compute or Disk Offerings, an administrator is able to build an environment in which a root or data disk that a user creates leads to the dynamic creation of a SolidFire volume, which has guaranteed performance. Such a SolidFire volume is associated with one (and only ever one) CloudStack volume, so performance of the CloudStack volume does not vary depending on how heavily other tenants are using the system.
创建存储池的API已经被扩展到支持插件式存储供应商。下面给出了当向基于SolidFire插件的CloudStack添加存储时可使用的参数列表。
url参数有时是唯一的,他的值可以包含额外的键值对。
url=【键值对下面有详细说明(值由url编码,例如,’=’编码后为‘%3D’】
当你创建一个新的区域时,第一个二级存储作为创建的一部分 。为了添加更多的服务器,你可以随时添加二级存储服务器到已创建的区域中。
警告
确保二级存储服务器上没有存储任何数据。添加服务器到CloudStack时,会损坏服务器上原有已存的数据
To prepare for the zone-based Secondary Staging Store, you should have created and mounted an NFS share during Management Server installation. See Prepare NFS Shares.
如果你正在使用Hyper-V主机,确保你已经创建了一个SMB共享目录。
确保你在安装管理节点时,准备了系统虚拟机模板,参见 “准备系统虚拟机模板”.
以根管理员身份登录CloudStack界面。
在左侧导航栏中,点击基础架构
在二级存储中,点击 查看全部。
点击添加二级存储。
填写以下内容:
名称–需要给二级存储一个描述性名称。
提供者。选择S3,Swift,NFS或者CIFS。此时会出现需要填写的相关内容。根据提供者的不同,需要的内容会有所不同。要了解更多,可参考提供者文档(如S3或Swift网站)。NFS可用于区域存储,其他的可用于地域存储。对 Hyper-V,选择 SMB/CIFS。
警告
地域中不支持多类二级存储共存。每一个地域只能使用NFS,S3或Swift其中的一种。
创建NFS二级暂存区,必须要勾选此项。
警告
即使UI允许你不勾选此项,也不要这样做。此项以及下面的三项内容是必须要填写的。即使二级存储提供商使用了Swift或S3,在每个区域中NFS暂存区仍是需要的。
区域,即二级暂存区所在的区域。
SMB Username:仅当选择了SMB/CIFS时可用。此账户针对SMB拥有必要的权限。用户必须是Hyper-V管理组的成员。
SMB Password:仅当选择了SMB/CIFS时可用。此密码与账户关联。
SMB Domain:仅当选择了SMB/CIFS时可用。是SMB共享目录活动哉的一部分。
NFS服务器。二级暂存区的区域名称。
路径。二级暂存区所在区域的路径
每一个区域至少有一个NFS存储区。每个区域允许存在多个NFS服务器。按以下步骤为区域添加一个二级暂存区
在所有配置完成后,CloudStack会执行初始化。根据网络速度的不同,可能会需要30分钟或更多的时间。当初始化完成后,管理员控制面板会出现在CloudStack的界面中。
确保系统已经准备完成。在左侧导航栏中,选择 模板 ,点击CentOS 5.5 (64bit) no Gui (KVM) template,查看其状态是否为 下载完成。在状态没有变成下载完成前,不要继续操作。
点击实例标签,筛选我的实例。
点击添加实例,并完成向导指示的步骤。
为了使用虚拟机,点击通讯视图按钮以启动一个通讯窗口.
关于使用虚拟机的更多信息,包括如何允许进入虚拟机的网络流量,开始,停止,删除虚拟机以及从一个主机上迁移虚拟,参看管理员手册中的使用虚拟部分。
恭喜!你已经完了CloudStack的安装。
如果决定扩展你的部署,可以增加更多的主机,主存储,区域,资源池以及集群。
CloudStack提供了各类设置,可以用来限制某性配置功能,打开或关闭云中的某些功能。一旦你的管理服务器运行后,你可能需要设置一些参数,依赖于你打开了哪些参数。也可以在全局设置中使用默认值,他们都会在云中全部起作用,除非在低级别配置时配置有错误。你也可以设置局部参数,在账户,区域,集群,主存储级别时,允许覆盖全局配置参数
每一个CloudStack的功能文档,都会引导你到应用参数名,下表给出了一些更有用的参数。
值域 | 值 |
---|---|
management.network.cidr | CIDR描述了管理存在的CIDR。在使用vSphere部署时,此项必须设置。推荐其他部署时也同样设置。例如:192.168.3.0/24 |
xen.setup.multipath | 对于XenServer节点,此 是/否 变量指示CloudStack允许XenServer主机的iSCSI的多路径。默认值为否。如果希望CloudStack允许多路径,请置为是。如果值为是,基于NFS部署的XenServer主机允许多路径。当然这不会影响NFS的操作并且没有任何危害。 |
secstorage.allowed.internal.sites | 这用来保护内部网络避免通过使用模板下载功能暴力尝试下载文件。可以用逗号分隔多个CIDR。如果需要网址来匹配CIDR,二级存储虚拟机会使用私有网络来获取网址。其他网址则会通过公共接口。建议将其设成1或2个内部用来保存模板的地址,如:192.168.1.66/32 |
use.local.storage | 用来决定CloudStack是否使用主机本地的存储存放数据盘,模板,快照。CloudStack默认不使用本地存储。如果你想使用本地存储时可设置为是,并且你也知道选择本地存储的可信赖以及随时读取的功能。 |
host | 这是管理服务器的IP地址。如果你部署了多台管理服务器,你应该在这里输入一个内网可以访问到的负载均衡IP地址。 |
default.page.size | 通过CloudStack API命令返回每页中显示条目的最大值。在云级别中适用此限制,不同的云之间会有所不同。通过使用page和pagesize参数调用特定的API,将其修改为较小的值。要了解更多,请参阅开发指南。默认值:500 |
ha.tag | 这个标签标示一个在全云中使用的特定主机,作为专用高可用性主机。被标示的主机仅用作使能的高可用性虚拟机,他们在其他主机失败时启动。例如,在向云中添加一个新主机时可以标明主机的标签为ha.tag,将其设为高可用性主机。 |
vmware.vcenter.session.timeout | 通过使用这个参数来决定虚拟中心连接的失效时间。默认值是20分钟。增大此值,以避免在VMware部署中的错误,因为VMware的操作可能会需要超过20分钟的时间。 |
通过以下几步来设定全局配置参数。在整个CloudStack的部署过程,默认值会起作用。
使用以下几步来设置本地配置参数,包括账号,区域,集群或主存储。这些值会覆盖全局配置值。
以下全局配置参数更加精细。以下列出的参数有三个不同的范围,账户,集群和区域。
值域 | 值域 | 值 |
---|---|---|
账户 | remote.access.vpn.client.iprange | 应当给远程访问vpn的客户分配一个ip范围。范围中的第一个ip被vpn 服务器所使用。 |
账户 | allow.public.user.templates | 如果值为否,用户将不能创建公共模板。 |
账户 | use.system.public.ips | 如果值为是,并且如果账户有一个或多个专用的公用ip范围,在账户专用的IP用完以后,可以从系统池中获取ip. |
账户 | use.system.guest.vlans | 如果值为是,并且如果账户有一个或多个专用的客户VLAN范围,在账户专用的VLAN用完后,可从系统池中获取VLAN。 |
集群 | cluster.storage.allocated.capacity.notificationthreshold | 百分比,其值从0到1,分配存储的利用率超过设定值,系统将会发送警告 |
集群 | cluster.storage.capacity.notificationthreshold | 百分比,其值从0到1,可用存储的比率超过设定值,系统将会发送警告 |
集群 | cluster.cpu.allocated.capacity.notificationthreshold | 百分比,其值从0到1,cpu的使用率超过设定值,系统将会发送警告 |
集群 | cluster.memory.allocated.capacity.notificationthreshold | 百分比,其值从0到1,内存的使用率超过设定值,系统将会发送警告 |
集群 | cluster.cpu.allocated.capacity.disablethreshold | 百分比,其值从0到1,cpu的使用率超过设定值后,分配器将关闭进一步的使用。设定相应通知限值要低于此值,以便能够被提前通知到。 |
集群 | cluster.memory.allocated.capacity.disablethreshold | 百分比,其值从0到1,内存的使用率超过设定值后,分配器将关闭进一步的使用。设定相应通知限值要低于此值,以便能够被提前通知到。 |
集群 | cpu.overprovisioning.factor | 用来进行cpu过度提供计算。可利用的cpu是实际cpu容量与cpu过度提供因子的乘积。 |
集群 | mem.overprovisioning.factor | 用来进行内存过度提供计算。 |
集群 | vmware.reserve.cpu | 当未过载使用时说明是否预留cpu。防止cpu过载,cpu总是有预留的。 |
集群 | vmware.reserve.mem | 当未过载使用时说明是否预留内存。防止内存过载,内存总是有预留的。 |
区域 | pool.storage.allocated.capacity.disablethreshold | 百分比,其值从0到1,已分配存储的使用率超过设定值后,分配器将关闭存储池,因为可用于分配的存储要小于限值。 |
区域 | pool.storage.capacity.disablethreshold | 百分比,其值从0到1,已分配存储的使用率超过设定值后,分配器将关闭存储池,因为可用于分配的存储要小于限值。 |
区域 | storage.overprovisioning.factor | 用来进行存储过载计算,可利用的存储是实际存储容量与存储过载因子的乘积。 |
区域 | network.throttling.rate | 在网络中允许的默认每秒传输数据容量,单位MB |
区域 | guest.domain.suffix | 在具有路由的虚拟网络中的虚拟机的默认域名 |
区域 | router.template.xen | XenServer的默认路由模板名称 |
区域 | router.template.kvm | kvm的默认路由模板名称 |
区域 | router.template.vmware | VMware的默认路由模板名称 |
区域 | enable.dynamic.scale.vm | 打开或关闭动态规模虚拟机 |
区域 | use.external.dns | 忽略内部DNS,使用外部DNS1和DNS2 |
区域 | blacklisted.routes | 黑名单中的路由不能用于虚拟机的私有网关来创建静态路由 |
如果你想使用 Hyper-V hypervisor来运行虚拟机,请在你的云环境中安装Hyper-V。本章节指导不会复制Hyper-V安装文档中的内容。它提供了让Hyper-V与CloudStack协同工作的一些特有的步骤。
为了能顺利地安装,在安装之前请收集以下信息:
Hyper-V Requiremen ts | 值 | 描述 |
---|---|---|
服务器角色 | Hyper-V | After the Windows Server 2012 R2 installation, ensure that Hyper-V is selected from Server Roles. For more information, see Installing Hyper-V. |
共享位置 | New folders in the /Share director y | 确保为主存储和辅助存储创建了文件夹。SMB共享和主机应该在同一个域内。 If you are using Windows SMB share, the location of the file share for the Hyper-V deployment will be the new folder created in the \Shares on the selected volume. You can create sub-folders for both PRODUCT Primary and Secondary storage within the share location. When you select the profile for the file shares, ensure that you select SMB Share -Applications. This creates the file shares with settings appropriate for Hyper-V. |
域和主机 | 主机都应该加入AD域。 | |
Hyper-V用户 | 完全控制权限 | SMB文件共享有完全控制权限 |
虚拟交换机 | If you are using Hyper-V 2012 R2, manually create an external virtual switch before adding the host to PRODUCT. If the Hyper-V host is added to the Hyper-V manager, select the host, then click Virtual Switch Manager, then New Virtual Switch. In the External Network, select the desired NIC adapter and click Apply. 如果使用Windows 2012 R2,虚拟交换机会自动创建。 |
|
虚拟交换机名称 | Take a note of the name of the virtual switch. You need to specify that when configuring PRODUCT physical network labels. | |
Hyper-V 域用户 |
|
|
迁移 | Migratio n | 启用迁移。 |
迁移 | Delegati on | 如果想使用在线迁移,请启用指派。请在使用在线迁移的主机上启用下列服务:CIFS和Microsoft Virtual System Migration Service。 |
迁移 | Kerberos | 为在线迁移启用Kerberos。 |
拨号访问网络权限 | 允许访问 | 允许拨号连接访问 |
Hyper-V代理帮助CloudStack操作Hyper-V主机。代理与管理服务器通讯并控制主机上的所有实例。为了让主机与CloudStack之间成功的进行交互,每个Hyper-V主机必须安装Hyper-V代理。Hyper-V代理作为Windows的系统服务运行。按照下里的步骤在每台主机上安装Agent。
CloudStack管理服务器使用HTTPS与Hyper-V代理通讯。为了使管理服务器与主机之间能够使用加密通讯,请在8250端口上绑定自签名证书。
注解
代理的安装程序会自动执行这个操作。在代理的安装过程中可以不选择该选项,它可以在步骤1中手动操作。
为8250端口创建并添加一个自签名证书:
创建一个自签名证书:
# New-SelfSignedCertificate -DnsName apachecloudstack -CertStoreLocation Cert:\LocalMachine\My
该命令创建一个自签名证书并将添加到 LocalMachine\My
证书区域。
将创建好的证书绑定到https通信的8250端口:
netsh http add sslcert ipport=0.0.0.0:8250 certhash=<thumbprint> appid="{727beb1c-6e7c-49b2-8fbd-f03dbe481b08}"
Thumbprint是你创建证书的指纹。
按照 `编辑 CloudStack Hyper-V 代理 <https://cwiki.apache.org/confluence/display/CLOUDSTACK/Creating+Hyperv+Agent+Installer>`__编译CloudStack代理程序。
以管理员权限运行安装。
在对话框中输入Hyper-V管理员凭证。
当代理安装完成之后,代理已经作为系统服务启动了。
需要先对主机连线以及网卡绑定哪种流量做出规划。默认情况下,CloudStack将正在被使用的设备作为默认路由。
如果你使用Hyper-V 2012 R2,在将主机添加到CloudStack中之前,请手动创建一个外部网络虚拟交换机。如果Hyper-V管理器已经添加了Hyper-V主机,选择该主机,然后点击虚拟交换机管理器,新建虚拟交换机。在外部网络,选择所需的网卡然后点击应用。
如果使用Windows 2012 R2,虚拟交换机会自动创建。
CloudStack允许管理员使用SMB共享作为主存储和辅助存储。
创建一个使用SMB v3协议的SMB存储
更多信息,请参考 部署基于SMB的Hyper-V.
同样可以使用Windows创建并发布SMB共享。在Windows Server 2012 R2安装完成之后,在服务器角色中选择安装文件和存储服务以便创建SMB文件共享。更多信息,请参考 通过使用服务器管理器 (SM) 创建 SMB 文件共享系统。
在AD域中添加SMB共享。
SMB共享和通过CloudStack管理的主机必须在同一个域内。管理服务器可以使用域用户凭证访问存储。
在CloudStack中添加存储时,请确保提供的域和凭证是正确的。确保用户可以通过管理服务器访问存储。
KVM包含在多种基于Linux的操作系统中。尽管不作要求,但是我们推荐以下发行版:
KVM hypervisors主要要求在于libvirt和Qemu版本。不管您使用何种Linux版本,请确保满足以下要求:
CloudStack中的默认使用Linux本身的桥接(bridge模块)方式实现。也可选择在CloudStack中使用OpenVswitch,具体要求如下:
此外,硬件要求如下:
如果你想使用 KVM hypervisor来运行虚拟机,请在你的云环境中安装KVM主机。本章节不会复述KVM的安装文档。它提供了KVM主机与CloudStack协同工作所要准备特有的步骤。
警告
在我们开始之前,请确保所有的主机都安装了最新的更新包。
警告
不建议在主机中运行与CloudStack无关的服务。
安装KVM主机的过程:
主机的操作系统必须为运行CloudStack Agent和KVM实例做些准备。
使用root用户登录操作系统。
检查FQN完全合格/限定主机名。
$ hostname --fqdn
该命令会返回完全合格/限定主机名,例如”kvm1.lab.example.org”。如果没有,请编辑 /etc/hosts。
确保机器可以连接到互联网.
$ ping www.cloudstack.org
启用NTP服务以确保时间同步.
注解
NTP服务用来同步云中的服务器时间。时间不同步会带来意想不到的问题。
安装NTP
$ yum install ntp
$ apt-get install openntpd
在所有主机中重复上述步骤。
CloudStack使用Agent来管理KVM实例。Agent与管理服务器通讯并控制主机上所有的虚拟机。
首先我们安装Agent:
在RHEL/CentOS上:
$ yum install cloudstack-agent
在Ubuntu上:
$ apt-get install cloudstack-agent
现在主机已经为加入群集做好准备。后面的章节有介绍,请参阅 添加一个宿主机。强烈建议在添加主机之前阅读此部分内容。
If you’re using a non-root user to add the KVM host, please add the user to sudoers file:
cloudstack ALL=NOPASSWD: /usr/bin/cloudstack-setup-agent
defaults:cloudstack !requiretty
此外,CloudStack Agent允许主机管理员控制KVM实例中的CPU型号。默认情况下,KVM实例的CPU型号为只有少数CPU特性且版本为xxx的QEMU Virtual CPU。指定CPU型号有几个原因:
For the most part it will be sufficient for the host administrator to specify the guest CPU config in the per-host configuration file (/etc/cloudstack/agent/agent.properties). This will be achieved by introducing following configuration parameters:
guest.cpu.mode=custom|host-model|host-passthrough
guest.cpu.model=from /usr/share/libvirt/cpu_map.xml(only valid when guest.cpu.mode=custom)
guest.cpu.features=vmx ept aes smx mmx ht (space separated list of cpu flags to apply)
更改CPU型号有三个选择:
这里有一些示例:
custom
guest.cpu.mode=custom
guest.cpu.model=SandyBridge
host-model
guest.cpu.mode=host-model
host-passthrough
guest.cpu.mode=host-passthrough
guest.cpu.features=vmx
注解
host-passthrough may lead to migration failure,if you have this problem, you should use host-model or custom. guest.cpu.features will force cpu features as a required policy so make sure to put only those features that are provided by the host CPU.
CloudStack使用libvirt管理虚拟机。因此正确地配置libvirt至关重要。CloudStack-agent依赖于Libvirt,应提前安装完毕。
为了实现动态迁移libvirt需要监听不可靠的TCP连接。还要关闭libvirts尝试使用组播DNS进行广播。这些都可以在 /etc/libvirt/libvirtd.conf文件中进行配置。
设定下列参数:
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
auth_tcp = "none"
mdns_adv = 0
除了在libvirtd.conf中打开”listen_tcp”以外,我们还必须修改/etc/sysconfig/libvirtd中的参数:
在RHEL或者CentOS中修改 /etc/sysconfig/libvirtd
:
取消如下行的注释:
#LIBVIRTD_ARGS="--listen"
在Ubuntu中:修改 /etc/default/libvirt-bin
在下列行添加 “-l”
libvirtd_opts="-d"
如下所示:
libvirtd_opts="-d -l"
重启libvirt服务
在RHEL/CentOS上:
$ service libvirtd restart
在Ubuntu上:
$ service libvirt-bin restart
CloudStack的会被例如AppArmor和SELinux的安全机制阻止。必须关闭安全机制并确保 Agent具有所必需的权限。
配置SELinux(RHEL和CentOS):
检查你的机器是否安装了SELinux。如果没有,请跳过此部分。
在RHEL或者CentOS中,SELinux是默认安装并启动的。你可以使用如下命令验证:
$ rpm -qa | grep selinux
在 /etc/selinux/config
中设置SELINUX变量值为 “permissive”。这样能确保对SELinux的设置在系统重启之后依然生效。
在RHEL/CentOS上:
$ vi /etc/selinux/config
查找如下行
SELINUX=enforcing
修改为
SELINUX=permissive
然后使SELinux立即运行于permissive模式,无需重新启动系统。
$ setenforce permissive
配置AppArmor(Ubuntu)
检查你的机器中是否安装了AppArmor。如果没有,请跳过此部分。
Ubuntu中默认安装并启动AppArmor。使用如下命令验证:
$ dpkg --list 'apparmor'
在AppArmor配置文件中禁用libvirt
$ ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
$ ln -s /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper /etc/apparmor.d/disable/
$ apparmor_parser -R /etc/apparmor.d/usr.sbin.libvirtd
$ apparmor_parser -R /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper
警告
本章节非常重要,请务必彻底理解。
注解
本章节详细介绍了如何使用Linux自带的软件配置桥接网络。如果要使用OpenVswitch,请看下一章节。
为了转发流量到实例,至少需要两个桥接网络: public 和 private。
By default these bridges are called cloudbr0 and cloudbr1, but you do have to make sure they are available on each hypervisor.
最重要的因素是所有hypervisors上的配置要保持一致。
配置网络有很多方法。在基本网络模式中你应该拥有2个 (V)LAN,一个用于管理网络,一个用于公共网络。
假设hypervisor中的网卡(eth0)有3个VLAN标签:
在VLAN 100 中,配置Hypervisor的IP为 192.168.42.11/24,网关为192.168.42.1
注解
Hypervisor与管理服务器不需要在同一个子网!
配置方式取决于发行版类型,下面给出RHEL/CentOS和Ubuntu的配置示例。
注解
本章节的目标是配置两个名为 ‘cloudbr0’和’cloudbr1’的桥接网络。这仅仅是指导性的,实际情况还要取决于你的网络布局。
网络桥接所需的软件在安装libvirt时就已被安装,继续配置网络。
首先配置eth0:
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
确保内容如下所示:
DEVICE=eth0
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
现在配置3个VLAN接口:
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0.100
DEVICE=eth0.100
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
IPADDR=192.168.42.11
GATEWAY=192.168.42.1
NETMASK=255.255.255.0
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0.200
DEVICE=eth0.200
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
BRIDGE=cloudbr0
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0.300
DEVICE=eth0.300
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
BRIDGE=cloudbr1
配置VLAN接口以便能够附加桥接网络。
$ vi /etc/sysconfig/network-scripts/ifcfg-cloudbr0
现在只配置一个没有IP的桥接。
DEVICE=cloudbr0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
IPV6INIT=no
IPV6_AUTOCONF=no
DELAY=5
STP=yes
同样建立cloudbr1
$ vi /etc/sysconfig/network-scripts/ifcfg-cloudbr1
DEVICE=cloudbr1
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
IPV6INIT=no
IPV6_AUTOCONF=no
DELAY=5
STP=yes
配置完成之后重启网络,通过重启检查一切是否正常。
警告
在发生配置错误和网络故障的时,请确保可以能通过其他方式例如IPMI或ILO连接到服务器。
在安装libvirt时所需的其他软件也会被安装,所以只需配置网络即可。
$ vi /etc/network/interfaces
如下所示修改接口文件:
auto lo
iface lo inet loopback
# The primary network interface
auto eth0.100
iface eth0.100 inet static
address 192.168.42.11
netmask 255.255.255.240
gateway 192.168.42.1
dns-nameservers 8.8.8.8 8.8.4.4
dns-domain lab.example.org
# Public network
auto cloudbr0
iface cloudbr0 inet manual
bridge_ports eth0.200
bridge_fd 5
bridge_stp off
bridge_maxwait 1
# Private network
auto cloudbr1
iface cloudbr1 inet manual
bridge_ports eth0.300
bridge_fd 5
bridge_stp off
bridge_maxwait 1
配置完成之后重启网络,通过重启检查一切是否正常。
警告
在发生配置错误和网络故障的时,请确保可以能通过其他方式例如IPMI或ILO连接到服务器。
警告
本章节非常重要,请务必彻底理解。
为了转发流量到实例,至少需要两个桥接网络: public 和 private。
By default these bridges are called cloudbr0 and cloudbr1, but you do have to make sure they are available on each hypervisor.
最重要的因素是所有hypervisors上的配置要保持一致。
将系统自带的网络桥接模块加入黑名单,确保该模块不会与openvswitch模块冲突。请参阅你所使用发行版的modprobe文档并找到黑名单。确保该模块不会在重启时自动加载或在下一操作步骤之前卸载该桥接模块。
以下网络配置依赖ifup-ovs和ifdown-ovs脚本,安装openvswitch后会提供该脚本。安装路径为位/etc/sysconfig/network-scripts/。
配置网络有很多方法。在基本网络模式中你应该拥有2个 (V)LAN,一个用于管理网络,一个用于公共网络。
假设hypervisor中的网卡(eth0)有3个VLAN标签:
在VLAN 100 中,配置Hypervisor的IP为 192.168.42.11/24,网关为192.168.42.1
注解
Hypervisor与管理服务器不需要在同一个子网!
如何配置这些文件取决于你使用的发行版本,在下面的内容中会提供RHEL/CentOS下的示例。
注解
本章节的目标是设置三个名为’mgmt0’, ‘cloudbr0’和’cloudbr1’ 桥接网络。这仅仅是指导性的,实际情况还要取决于你的网络状况。
使用ovs-vsctl命令创建基于OpenVswitch的网络接口。该命令将配置此接口并将信息保存在OpenVswitch数据库中。
首先我们创建一个连接至eth0接口的主桥接。然后我们创建三个虚拟桥接,每个桥接都连接指定的VLAN。
# ovs-vsctl add-br cloudbr
# ovs-vsctl add-port cloudbr eth0
# ovs-vsctl set port cloudbr trunks=100,200,300
# ovs-vsctl add-br mgmt0 cloudbr 100
# ovs-vsctl add-br cloudbr0 cloudbr 200
# ovs-vsctl add-br cloudbr1 cloudbr 300
所需的安装包在安装openvswitch和libvirt的时就已经安装,继续配置网络。
首先配置eth0:
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
确保内容如下所示:
DEVICE=eth0
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
必须将基础桥接配置为trunk模式。
$ vi /etc/sysconfig/network-scripts/ifcfg-cloudbr
DEVICE=cloudbr
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
DEVICETYPE=ovs
TYPE=OVSBridge
现在对三个VLAN桥接进行配置:
$ vi /etc/sysconfig/network-scripts/ifcfg-mgmt0
DEVICE=mgmt0
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=static
DEVICETYPE=ovs
TYPE=OVSBridge
IPADDR=192.168.42.11
GATEWAY=192.168.42.1
NETMASK=255.255.255.0
$ vi /etc/sysconfig/network-scripts/ifcfg-cloudbr0
DEVICE=cloudbr0
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
DEVICETYPE=ovs
TYPE=OVSBridge
$ vi /etc/sysconfig/network-scripts/ifcfg-cloudbr1
DEVICE=cloudbr1
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=OVSBridge
DEVICETYPE=ovs
配置完成之后重启网络,通过重启检查一切是否正常。
警告
在发生配置错误和网络故障的时,请确保可以能通过其他方式例如IPMI或ILO连接到服务器。
hypervisor之间和hypervisor与管理服务器之间要能够通讯。
为了达到这个目的,我们需要开通以下TCP端口(如果使用防火墙):
如何打开这些端口取决于你使用的发行版本。在RHEL/CentOS 及Ubuntu中的示例如下。
RHEL 及 CentOS使用iptables作为防火墙,执行以下iptables命令来开启端口:
$ iptables -I INPUT -p tcp -m tcp --dport 22 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 1798 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 16509 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 5900:6100 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 49152:49216 -j ACCEPT
这些iptables配置并不会持久保存,重启之后将会消失,我们必须手动保存这些配置。
$ iptables-save > /etc/sysconfig/iptables
Ubuntu中的默认防火墙是UFW(Uncomplicated FireWall),使用Python围绕iptables进行包装。
要打开所需端口,请执行以下命令:
$ ufw allow proto tcp from any to any port 22
$ ufw allow proto tcp from any to any port 1798
$ ufw allow proto tcp from any to any port 16509
$ ufw allow proto tcp from any to any port 5900:6100
$ ufw allow proto tcp from any to any port 49152:49216
注解
默认情况下,Ubuntu中并未启用UFW。在关闭情况下执行这些命令并不能启用防火墙。
LXC要求Linux kernel 2.6.24开始引入的 cgroups功能。尽管不需要运行所有的发行版,但是建议下列的版本:
LXC hypervisor 要求libvirt和Qemu的版本。无论使用哪种Linux发行版,请确保满足以下要求:
CloudStack中的默认使用Linux本身的桥接(bridge模块)方式实现。也可选择在CloudStack中使用OpenVswitch,具体要求如下:
此外,硬件要求如下:
LXC没有任何本地系统VMs,而KVM需要运行系统VMs。意思为主机需要同时支持LXC和KVM。因此,大部分的安装和配置跟KVM的安装一样。本章节不会复述KVM的安装。这里我们只会给出使KVM与CloudStack协同工作的一些特有的步骤。
警告
在我们开始之前,请确保所有的主机都安装了最新的更新包。
警告
不建议在主机中运行与CloudStack无关的服务。
安装LXC主机步骤:
主机的操作系统必须为运行CloudStack Agent和KVM实例做些准备。
使用root用户登录操作系统。
检查FQN完全合格/限定主机名。
$ hostname --fqdn
该命令会返回完全合格/限定主机名,例如”kvm1.lab.example.org”。如果没有,请编辑 /etc/hosts。
确保机器可以连接到互联网.
$ ping www.cloudstack.org
启用NTP服务以确保时间同步.
注解
NTP服务用来同步云中的服务器时间。时间不同步会带来意想不到的问题。
安装NTP
$ yum install ntp
$ apt-get install openntpd
在所有主机中重复上述步骤。
CloudStack使用代理管理LXC实例。管理服务器与代理通信并控制主机中所有实例。
首先我们安装Agent:
在RHEL/CentOS上:
$ yum install cloudstack-agent
在Ubuntu上:
$ apt-get install cloudstack-agent
接下来更新代理配置。在 /etc/cloudstack/agent/agent.properties
中配置
设置代理运行在LXC模式下:
hypervisor.type=lxc
可选项:如果想使用直连网络(代替默认的桥接网络),配置如下行:
libvirt.vif.driver=com.cloud.hypervisor.kvm.resource.DirectVifDriver
network.direct.source.mode=private
network.direct.device=eth0
现在主机已经为加入群集做好准备。后面的章节有介绍,请参阅 添加一个宿主机。强烈建议在添加主机之前阅读此部分内容。
CloudStack使用libvirt管理虚拟机。因此正确地配置libvirt至关重要。CloudStack-agent依赖于Libvirt,应提前安装完毕。
为了实现动态迁移libvirt需要监听不可靠的TCP连接。还要关闭libvirts尝试使用组播DNS进行广播。这些都可以在 /etc/libvirt/libvirtd.conf文件中进行配置。
设定下列参数:
listen_tls = 0
listen_tcp = 1
tcp_port = "16509"
auth_tcp = "none"
mdns_adv = 0
除了在libvirtd.conf中打开”listen_tcp”以外,我们还必须修改/etc/sysconfig/libvirtd中的参数:
在RHEL或者CentOS中修改 /etc/sysconfig/libvirtd
:
取消如下行的注释:
#LIBVIRTD_ARGS="--listen"
在Ubuntu中:修改 /etc/default/libvirt-bin
在下列行添加 “-l”
libvirtd_opts="-d"
如下所示:
libvirtd_opts="-d -l"
为了VNC控制台正常工作,必须确保该参数绑定在0.0.0.0上。通过编辑 ``/etc/libvirt/qemu.conf``实现。
请确保这个参数配置为:
vnc_listen = "0.0.0.0"
重启libvirt服务
在RHEL/CentOS上:
$ service libvirtd restart
在Ubuntu上:
$ service libvirt-bin restart
CloudStack的会被例如AppArmor和SELinux的安全机制阻止。必须关闭安全机制并确保 Agent具有所必需的权限。
配置SELinux(RHEL和CentOS):
检查你的机器是否安装了SELinux。如果没有,请跳过此部分。
在RHEL或者CentOS中,SELinux是默认安装并启动的。你可以使用如下命令验证:
$ rpm -qa | grep selinux
在 /etc/selinux/config
中设置SELINUX变量值为 “permissive”。这样能确保对SELinux的设置在系统重启之后依然生效。
在RHEL/CentOS上:
$ vi /etc/selinux/config
查找如下行
SELINUX=enforcing
修改为
SELINUX=permissive
然后使SELinux立即运行于permissive模式,无需重新启动系统。
$ setenforce permissive
配置AppArmor(Ubuntu)
检查你的机器中是否安装了AppArmor。如果没有,请跳过此部分。
Ubuntu中默认安装并启动AppArmor。使用如下命令验证:
$ dpkg --list 'apparmor'
在AppArmor配置文件中禁用libvirt
$ ln -s /etc/apparmor.d/usr.sbin.libvirtd /etc/apparmor.d/disable/
$ ln -s /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper /etc/apparmor.d/disable/
$ apparmor_parser -R /etc/apparmor.d/usr.sbin.libvirtd
$ apparmor_parser -R /etc/apparmor.d/usr.lib.libvirt.virt-aa-helper
警告
本章节非常重要,请务必彻底理解。
注解
本章节详细介绍了如何使用Linux自带的软件配置桥接网络。如果要使用OpenVswitch,请看下一章节。
为了转发流量到实例,至少需要两个桥接网络: public 和 private。
By default these bridges are called cloudbr0 and cloudbr1, but you do have to make sure they are available on each hypervisor.
最重要的因素是所有hypervisors上的配置要保持一致。
配置网络有很多方法。在基本网络模式中你应该拥有2个 (V)LAN,一个用于管理网络,一个用于公共网络。
假设hypervisor中的网卡(eth0)有3个VLAN标签:
在VLAN 100 中,配置Hypervisor的IP为 192.168.42.11/24,网关为192.168.42.1
注解
Hypervisor与管理服务器不需要在同一个子网!
配置方式取决于发行版类型,下面给出RHEL/CentOS和Ubuntu的配置示例。
注解
本章节的目标是配置两个名为 ‘cloudbr0’和’cloudbr1’的桥接网络。这仅仅是指导性的,实际情况还要取决于你的网络布局。
网络桥接所需的软件在安装libvirt时就已被安装,继续配置网络。
首先配置eth0:
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0
确保内容如下所示:
DEVICE=eth0
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
现在配置3个VLAN接口:
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0.100
DEVICE=eth0.100
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
IPADDR=192.168.42.11
GATEWAY=192.168.42.1
NETMASK=255.255.255.0
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0.200
DEVICE=eth0.200
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
BRIDGE=cloudbr0
$ vi /etc/sysconfig/network-scripts/ifcfg-eth0.300
DEVICE=eth0.300
HWADDR=00:04:xx:xx:xx:xx
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=none
TYPE=Ethernet
VLAN=yes
BRIDGE=cloudbr1
配置VLAN接口以便能够附加桥接网络。
$ vi /etc/sysconfig/network-scripts/ifcfg-cloudbr0
现在只配置一个没有IP的桥接。
DEVICE=cloudbr0
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
IPV6INIT=no
IPV6_AUTOCONF=no
DELAY=5
STP=yes
同样建立cloudbr1
$ vi /etc/sysconfig/network-scripts/ifcfg-cloudbr1
DEVICE=cloudbr1
TYPE=Bridge
ONBOOT=yes
BOOTPROTO=none
IPV6INIT=no
IPV6_AUTOCONF=no
DELAY=5
STP=yes
配置完成之后重启网络,通过重启检查一切是否正常。
警告
在发生配置错误和网络故障的时,请确保可以能通过其他方式例如IPMI或ILO连接到服务器。
在安装libvirt时所需的其他软件也会被安装,所以只需配置网络即可。
$ vi /etc/network/interfaces
如下所示修改接口文件:
auto lo
iface lo inet loopback
# The primary network interface
auto eth0.100
iface eth0.100 inet static
address 192.168.42.11
netmask 255.255.255.240
gateway 192.168.42.1
dns-nameservers 8.8.8.8 8.8.4.4
dns-domain lab.example.org
# Public network
auto cloudbr0
iface cloudbr0 inet manual
bridge_ports eth0.200
bridge_fd 5
bridge_stp off
bridge_maxwait 1
# Private network
auto cloudbr1
iface cloudbr1 inet manual
bridge_ports eth0.300
bridge_fd 5
bridge_stp off
bridge_maxwait 1
配置完成之后重启网络,通过重启检查一切是否正常。
警告
在发生配置错误和网络故障的时,请确保可以能通过其他方式例如IPMI或ILO连接到服务器。
hypervisor之间和hypervisor与管理服务器之间要能够通讯。
为了达到这个目的,我们需要开通以下TCP端口(如果使用防火墙):
如何打开这些端口取决于你使用的发行版本。在RHEL/CentOS 及Ubuntu中的示例如下。
RHEL 及 CentOS使用iptables作为防火墙,执行以下iptables命令来开启端口:
$ iptables -I INPUT -p tcp -m tcp --dport 22 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 1798 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 16509 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 5900:6100 -j ACCEPT
$ iptables -I INPUT -p tcp -m tcp --dport 49152:49216 -j ACCEPT
这些iptables配置并不会持久保存,重启之后将会消失,我们必须手动保存这些配置。
$ iptables-save > /etc/sysconfig/iptables
Ubuntu中的默认防火墙是UFW(Uncomplicated FireWall),使用Python围绕iptables进行包装。
要打开所需端口,请执行以下命令:
$ ufw allow proto tcp from any to any port 22
$ ufw allow proto tcp from any to any port 1798
$ ufw allow proto tcp from any to any port 16509
$ ufw allow proto tcp from any to any port 5900:6100
$ ufw allow proto tcp from any to any port 49152:49216
注解
默认情况下,Ubuntu中并未启用UFW。在关闭情况下执行这些命令并不能启用防火墙。
如果计划使用VMware vSphere平台运行虚拟机,请在云中安装vSphere主机。
vSphere and vCenter, versions 4.1, 5.0, 5.1 or 5.5.
建议使用vSphere标准版。但是VMware用户需要考虑vSphere授权对CPU的限制。请参考 http://www.vmware.com/files/pdf/vsphere_pricing.pdf 并与销售代表讨论。
建议使用vCenter标准版。
请确保安装了hypervisor供应商发布的所有补丁程序。随时关注供应商支持信息,一旦发布补丁就立即安装。CloudStack不会跟踪或提醒你安装这些补丁。安装最新的补丁程序对主机至关重要。hypervisor供应商可能不会对过期的系统提供技术支持。
警告
安装一切必要的补丁程序。缺乏最新补丁程序可能会导致数据和虚拟机丢失。
更多信息,请参考 “vCenter Server 和 vSphere Client 硬件要求”。
为了能顺利地安装,在安装之前请收集以下信息:
你需要关于vCenter的下列信息:
vCenter要求 | 备注 |
---|---|
vCenter用户 | 用户必须拥有管理员权限。 |
vCenter用户的密码 | 上述用户的密码。 |
vCenter数据库名称 | 数据中心名称 |
vCenter群集名称 | 群集名称 |
You will need the following information about your VLANs.
VLAN信息 | 备注 |
---|---|
ESXi VLAN | 全部ESXi hypervisors主机所在的VLAN。 |
ESXi VLAN IP地址 | ESXi VLAN的IP地址范围。每个虚拟路由器使用该范围内的一个IP。 |
ESXi VLAN网关IP | |
ESXi VLAN子网掩码 | |
管理服务器VLAN | CloudStack管理服务器所在的VLAN。 |
公共网络VLAN | 公共网络的VLAN |
公共网络VLAN的网关 | |
公共网络VLAN的子网掩码 | |
公共VLAN IP地址范围 | CloudStack使用的公共网络IP范围。CloudStack中的虚拟路由器使用这些地址,用于路由专用流量至外部网络。 |
客户使用的VLAN范围 | 连续的不可路由的VLAN范围。每个用户会分配一个VLAN。 |
如果你还没用准备好安装介质,请在VMware网站下载和购买(https://www.vmware.com/tryvmware/index.php?p=vmware-vsphere&lp=1)并按照VMware vSphere安装指南安装。
安装过程中,执行下面几个章节描述的以下配置:
要求 | 可选项 |
---|---|
ESXi主机安装 | 网卡绑定 |
配置主机的物理网络,虚拟交换机,vCenter管理网络和扩展的端口范围 | 存储多路径 |
准备iSCSI存储 | |
在vCenter中配置集群并添加主机,或不使用集群,直接在vCenter中添加主机。 |
All ESXi hosts should have CPU hardware virtualization support enabled in the BIOS. Please note hardware virtualization support is not enabled by default on most servers.
您应该准备一个vSphere主机连接的规划。将主机添加至CloudStack之前,需要合理地配置网络。要配置ESXi主机,可以先用vClient将它作为独立主机添加到vCenter。当您在vCenter的导航树中看到该主机时,点击它,选择配置页。
在主机的配置标签页中,点击”硬件/网络”链接转到上图中的网络配置页。
During the initial installation of an ESXi host a default virtual switch vSwitch0 is created. You may need to create additional vSwiches depending on your required architecture. CloudStack requires all ESXi hosts in the cloud to use consistently named virtual switches. If you change the default virtual switch name, you will need to configure one or more CloudStack configuration variables as well.
CloudStack allows you to configure three separate networks per ESXi host. CloudStack identifies these networks by the name of the vSwitch they are connected to. The networks for configuration are public (for traffic to/from the public internet), guest (for guest-guest traffic), and private (for management and usually storage traffic). You can use the default virtual switch for all three, or create one or two other vSwitches for those traffic types.
如果您想以这样的方式隔离流量,首先应按照vCenter的指南在vCenter中创建并配置虚拟交换机。请记录每种网络使用的虚拟交换机名称。您需要配置CloudStack使用这些虚拟交换机。
ESXi主机的虚拟交换机默认有56个端口。我们建议设为最大允许数4088。要设置该值,请点击虚拟交换机的“属性…”链接(注意,不是网络的属性)。
在vSwitch属性对话框中,选择vSwitch,点击“编辑”,您将看到以下对话框:
在该对话框中,您可以修改端口数量。修改完后,为使配置生效,需要重启ESXi主机。
在vSwith属性对话框中,您可以看到一个vCenter管理网络。CloudStack的管理网络也使用该网络。CloudStack要求正确配置vCenter的管理网络。在对话框中点击管理网络,然后点击编辑。
请确保配置以下设置:
如果ESXi主机具有多个VMKernel端口,并且ESXi没有使用默认的“Management Network”作为管理网络名称,您必须按照以下指南配置管理网络端口组,以便CloudStack可以发现管理网络。
(仅适用于VMware vSphere 4.x)
为使控制台代理可以和主机一起工作,您需要扩展主机的防火墙端口范围。这是为了使控制台代理可以访问VMware的VM。为扩展端口范围,请登录到每台主机的VMware ESX服务控制台,然后执行以下命令:
esxcfg-firewall -o 59000-60000,tcp,in,vncextras
esxcfg-firewall -o 59000-60000,tcp,out,vncextras
vSphere主机的网卡绑定可以按照vSphere安装指南完成。
CloudStack支持在VMware vSphere环境中使用Cisco Nexus 1000v dvSwitch (分布式虚拟交换机)。本章节能帮助你配置vSphere群集使用Nexus 1000v虚拟交换机。关于创建vSphere群集的更多信息,请参考 “VMware vSphere安装和配置”
Cisco Nexus 1000V虚拟交换机是一个内置软件程序的虚拟机。它能跨越多个运行VMware ESXi 4.0或更高版本的主机部署。Nexus虚拟交换机包括两个组件:Virtual Supervisor Module (VSM)和 Virtual Ethernet Module (VEM)。VSM是一个管理交换机的虚拟设备。它单独控制多个VEM。VSM安装在每台VMware ESXi服务器当中提供包转发功能。它为每个虚拟机提供单独的交换机接口。VSM-VEM架构与物理交换机的管理机制(单独或者高可用模式)和多线卡架构类似。
Nexus 1000v交换机使用vEthernet端口配置文件为虚拟机提供简单的网络。它有两种类型的端口配置文件:Ethernet端口配置文件和vEthernet端口配置文件。Ethernet端口配置文件应用到物理上联端口-ESXi服务器上面的物理网卡的端口。vEthernet端口配置文件关联到ESXi服务器上运行的虚拟机的虚拟网卡。端口配置文件可以帮助网络管理员快速的为其他虚机定义同样的网络策略。VSM创建的Ethernet端口策略在vCenter服务器上显示为端口组。
本章节探讨了在CloudStack中使用Nexus虚拟交换机的先决条件与指南。在配置Nexus虚拟交换机之前,请确保你的系统符合下列条件:
要顺利配置 Nexus 1000v交换机,请在开始之前收集下列信息:
需要vCenter以下信息:
Nexus vSwitch要求 | 值 | 备注 |
---|---|---|
vCenter IP | vCenter IP地址 | |
HTTPS端口号 | 443 | 默认配置使用443端口;如果需要,可以更改为其他端口。 |
vCenter用户ID | 拥有管理员权限的vCenter用户。在CloudStack中配置虚拟交换时需要提供vCenter用户ID。 | |
vCenter 密码 | 上述vCenter用户的密码。在CloudStack中配置虚拟交换机时需要提供vCenter用户密码。 |
打开CloudStack管理界面,请在Nexus dvSwitchde 详情标签页中的Nexus 配置网络界面指定下列信息:
Control Port Group VLAN ID The VLAN ID of the Control Port Group. The control VLAN is used for communication between the VSM and the VEMs.
Management Port Group VLAN ID The VLAN ID of the Management Port Group. The management VLAN corresponds to the mgmt0 interface that is used to establish and maintain the connection between the VSM and VMware vCenter Server.
Packet Port Group VLAN ID The VLAN ID of the Packet Port Group. The packet VLAN forwards relevant data packets from the VEMs to the VSM.
注解
用于控制,数据和管理端口组可以在同一VLAN。
更多信息,请参考 Cisco Nexus 1000V 入门指南.
你需要下列的VSM配置参数:
Admin Name and Password The admin name and password to connect to the VSM appliance. You must specify these credentials while configuring Nexus virtual switch.
Management IP Address This is the IP address of the VSM appliance. This is the IP address you specify in the virtual switch IP Address field while configuting Nexus virtual switch.
SSL Should be set to Enable.Always enable SSL. SSH is usually enabled by default during the VSM installation. However, check whether the SSH connection to the VSM is working, without which CloudStack failes to connect to the VSM.
关于创建端口配置文件的更多信息,请参考 Cisco Nexus 1000V 端口配置指南。
分配ESXi主机上的对应每个物理网络的网卡适配器到端口配置文件。在vCenter群集中的每个ESXi主机上,观察分配到每个端口配置文件的物理网络并记下配置文件的名字。在创建zone期间,当你配置物理网络的时候,这个映射信息能帮助你。这些Ethernet端口配置文件的名字就是随后你在配置zone的时候,配置物理网络时所要输入的不同流量对应的VMware流量标签。配置物理网络所需的更多信息,请参考 “Configuring a vSphere Cluster with Nexus 1000v Virtual Switch”。
决定CloudStack所使用的公共VLAN,系统VLAN和来宾VLAN。确保你添加他们到端口配置文件数据库。对应每个物理网络,为端口配置文件添加VLAN范围。在VSM命令提示符下,运行 switchport trunk allowed vlan<range>命令为端口配置文件添加VLAN范围。
例如:
switchport trunk allowed vlan 1,140-147,196-203
在这个示例下,添加的VLANs是1,140-147和196-203
你同样在该交换机中添加所有的公共和管理VLANs或VLAN范围。这个范围是你在区域中指定的VLAN范围。
注解
在你运行vlan命令之前,确保Nexus 1000v虚拟交换机中启用了配置模式。
例如:
如果你想在交换机中使用VLAN 200,运行下面的命令:
vlan 200
如果你想在交换机中使用VLAN范围1350-1750,请运行下面的命令:
vlan 1350-1750
参考特定产品版本的Cisco Nexus 1000V 命令参考。
为了使CloudStack启用部署Nexus,你必须在CloudStack UI中全局设置页面设置vmware.use.nexus.vswitch参数为true。只有这个参数设置为 “true”并且重启了管理服务器,你才可以看见Nexus虚拟交换机的相关页面,CloudStack在AddTrafficTypeCmd, UpdateTrafficTypeCmd和 AddClusterCmd API的调用中会忽略Nexus虚拟交换机的指定参数。
除非CloudStack全局配置中的”vmware.use.nexus.vswitch”设置为”true”,否则CloudStack会默认使用VMware标准vSwitch。在本版本中,CloudStack不支持在标准vSwitch和Nexus 1000v虚拟交换机的混合环境中配置虚拟网络。只能支持单一的标准vSwitch或Nexus 1000v虚拟交换机部署。
可以在创建区域时,通过添加必要的资源用于配置Nexus dvSwitch。
区域创建完成后,如果你想在区域中创建其他同样使用Nexus 1000v虚拟交换机的群集时,使用添加群集选项。关于创建群集的更多信息,请参见 “添加群集: vSphere”。
在所有的情况下,配置Nexus虚拟交换机时必须指定下列参数:
参数 | 描述 |
---|---|
群集名称 | 输入在vCenter中创建的群集名称。比如,”cloud.cluster”。 |
vCenter 主机 | 输入已经部署了Nexus虚拟交换机的vCenter主机名或IP。 |
vCenter用户名 | 输入CloudStack连接到vCenter所使用的用户名。这个用户必须拥有所有管理员权限。 |
vCenter 密码 | 输入上面用户的密码。 |
vCenter数据中心 | 输入群集所属的vCenter数据中心名称。比如, “cloud.dc.VM”。 |
Nexus dvSwitch IP 地址 | Nexus 1000v虚拟交换机VSM组件的IP地址。 |
Nexus dvSwitch 用户名 | 连接至VSM appliance的admin名称。 |
Nexus dvSwitch 密码 | 上面指定的admin用户所对应的密码。 |
在使用了Nexus虚拟交换机的vCenter数据中心中,确认你在对应的群集中删除了所有的主机。
使用管理员登录到CloudStack管理界面。
在左侧导航栏中,选择基础架构。
在基础架构页面,点击群集中的查看所有。
选择你想要移除虚拟交换机的群集。
在dvSwitch标签页中,点击虚拟交换机的名字。
在详细页面中,点击删除Nexus dvSwitch的图标。
在确认对话框中点击确定。
CloudStack支持在VMware vSphere环境中为虚拟网络配置VMware vNetwork分布式交换机(VDS)。本章节能帮助你在CloudStack中配置VMware VDS。每个vCenter服务器实例最多支持128 VDS实例,每个VDS实例最多可以管理500台VMware服务器。
在VMware vCenter服务器中的VMware VDS聚合主机层面虚拟交换机 。各个主机层面的虚拟交换机被抽象处理成一个在数据中心层面上横跨多个主机的大型 VDS,通过一个集中的接口,使用集中配置、管理、监控你的整个数据中心。实际上,VDS可以看作是数据中心层面中一个整体的虚拟交换机,通过VMware vCenter服务器管理数据中心中大量的主机网络。在虚拟机跨多个主机移动时保持其网络运行时状态,支持嵌入式监控和集中式防火墙服务。VDS能与标准虚拟交换机和 Nexus 1000V虚拟交换机一起部署或者独立部署。
为了顺利的配置VMware VDS,在开始之前,请牢记添加到数据中心中的VDS名称:
如下需要使用VDS名称:
在创建zone的过程中配置公共网络和来宾网络时,在编辑流量标签对话框中配置交换机名称。
在创建zone的过程中配置来宾网络和公共网络流量类型时,请确保你选择了VMware vNetwork Distributed Virtual Switch。
当添加一个启用了VDS的VMware群集时,则显示公共网络流量vSwitch类型区域。
当在zone中更新交换机类型时,流量标签所使用的交换机名称。
在最后一种情况下流量标签格式是[[“Name of vSwitch/dvSwitch/EthernetPortProfile”][,”VLAN ID”[,”vSwitch Type”]]]
流量标签可以使用如下值:
填写如下区域:
vCenter中 虚拟/分布式 虚拟交换机的名称。
默认值取决于虚拟交换机的类型:
vSwitch0:如果虚拟交换机的类型是VMware vNetwork标准虚拟交换机。
dvSwitch0:如果虚拟交换机类型为VMware vNetwork分布式虚拟交换机
epp0:如果虚拟交换机类型为Cisco Nexus 1000v分布式虚拟交换机
任何适用于这个流量的 VLAN ID
此时,该区域仅用于公共网络流量。来宾网络区域会被忽略并且留空。默认为空字符即假设特定流量类型不填加VLAN标签。
虚拟交换机类型。指定字符串。
合理且有效的值为vmwaredvs, vmwaresvs, nexusdvs。
vmwaresvs:表示VMware vNetwork 标准虚拟交换机
vmwaredvs:表示VMware vNetwork分布式虚拟交换机
nexusdvs:代表Cisco Nexus 1000v分布式虚拟交换机。
如果什么都没指定(留空),基于全局参数指定的值,区域层面默认使用虚拟交换机。
以下为全局配置参数:
vmware.use.dvswitch:设置为true则是在CloudStack部署时启用任意种类(VMware DVS和Cisco Nexus 1000v) 分布式交换机。如果设置为false,则CloudStack部署时使用的的虚拟交换机是标准虚拟交换机。
vmware.use.nexus.vswitch:如果vmware.use.dvswitch设置为false,则忽略该参数。设置为true则是部署CloudStack时启用Cisco Nexus 1000v分布式交换机。
在部署CloudStack时启用VDS,请在CloudStack管理界面中的全局设置页面中设置vmware.use.dvswitch parameter为true并重启管理服务器。只有启用了vmware.use.dvswitch参数,你才能在管理界面中指定VDS,并且CloudStack会忽略你指定的VDS-specific参数。另外,如果vmware.use.dvswitch参数的值为true且vmware.use.nexus.dvswitch参数的值为false,那么CloudStack中虚拟网络架构使用VDS。另外一个定义VDS配置的全局参数是vmware.ports.per.dvportgroup。它表示在VMware环境里每个VMware dvPortGroup中默认端口数量。默认是256。这个数值直接关系到你创建的来宾网络的数量。
CloudStack支持混合部署分布式虚拟交换机、标准虚拟交换机和Nexus 1000v虚拟交换机的虚拟网络。
在创建区域时需要添加必要的资源才能配置VDS。
另外在群集层面,使用添加群集选项,可以在已经存在并启用VDS的区域中创建附加群集。更多信息请参阅 “添加群集: vSphere”.
在所有情况下,配置VDS时必须指定下列参数:
参数描述 | |
---|---|
群集名称 | 输入在vCenter中创建的群集名称。比如,”cloudcluster”。 |
vCenter 主机 | 输入已经部署VMware VDS的vCenter主机名称或者IP地址。 |
vCenter用户名 | 输入CloudStack连接到vCenter所使用的用户名。这个用户必须拥有所有管理员权限。 |
vCenter 密码 | 输入上面用户的密码。 |
vCenter数据中心 | 输入群集所属的vCenter数据中心名称。比如,”clouddcVM”。 |
替代公共流量 | 启用该选项时,整个区域中群集的公共流量将被替代。 |
公共流量虚拟交换机类型 | 在启用替代公共流量时该选项才会显示。选择VMware vNetwork Distributed Virtual Switch。如果全局设置中vmware.use.dvswitch参数为true,则默认选项为VMware vNetwork Distributed Virtual Switch。 |
公共流量虚拟交换机名称 | 用于公共流量的虚拟交换机名称。 |
替代来宾流量 | 启用该选项时,整个区域中群集的来宾流量将被替代。 |
来宾流量虚拟交换机类型 | 在启用替代来宾流量时该选项才会显示。选择VMware vNetwork Distributed Virtual Switch。如果全局设置中vmware.use.dvswitch参数为true,则默认选项为VMware vNetwork Distributed Virtual Switch。 |
来宾流量虚拟交换机名称 | 用于宾流量的虚拟交换机名称。 |
使用iSCSI需要在vCenter中做一些准备工作。您必须添加iSCSI目标并创建iSCSI数据存储。
如果使用NFS,请跳过本章节。
在vCenter中,点击主机/集群的配置,点击存储适配器。您将看到:
选择iSCSI软件适配器并点击属性。
点击配置…按钮。
勾选启用以便启用启动器。
点击 确定 保存。
现在您应该创建一个VMFS数据存储。请按照以下步骤:
该过程只需要在集群中的一台主机上执行,不需要在所有主机上执行。
vSphere的存储多路径可以根据vSphere的安装文档配置。
使用vCenter创建集群,向其中添加期望的主机。随后您可以将整个集群加入到Cloudstack中。(参考 “添加群集: vSphere”)。
在CloudStack中断开与VMware vSphere 群集的连接。应断开足够长的时间以便在主机上安装补丁程序。
使用admin账户登录CloudStack管理界面。
请参考 “登录用户界面”。
导航至VMware群集,点击操作-取消管理。
查看群集状态直到显示未受管理。
在集群中每个ESXi主机上执行以下操作:
重新连接该集群到CloudStack:
使用admin账户登录CloudStack管理界面。
导航到VMware群集,点击操作-管理。
查看状态以确保所有的主机都恢复正常。所有主机都恢复正常可能需要几分钟时间。
或者,确认主机状态在数据库中得到正确同步和更新。
如果你想用Citrix XenServer作为hypervisor运行虚拟机,安装XenServer 6.0或XenServer 6.0.2版本。你需要按照以下步骤来完成初次安装。如果你想从之前的旧版本升级,请参阅 升级XenServer版本。
主机必须通过下列任一版本的兼容性认证。请查看Citrix硬件兼容性指导: http://hcl.xensource.com
- XenServer 5.6 SP2
- XenServer 6.0
- XenServer 6.0.2
- XenServer 6.1.0
- XenServer 6.2.0
- XenServer 6.5.0
如果你想使用以前装的某台主机,你必须重新安装Citrix XenServer.
必须支持HVM(Intel-VT或者AMD-V)
确保安装了所有系统补丁供应商提供的所有系统补丁。请随时关注供应商的技术支持渠道,一旦发布补丁,请尽快打上补丁。CloudStack不会跟踪或提醒你安装这些程序。安装最新的补丁对主机至关重要。虚拟化供应商可能不会对过期的系统提供技术支持。
集群中的主机必须是相同架构。CPU的型号、数量和功能参数必须相同。
必须支持HVM(BIOS中要打开Intel-VT或者AMD-V)
64位x86 CPU(多核性能更佳)
硬件虚拟化支持
4GB 内存
36GB本地磁盘空间
至少一块网卡
静态分配的IP
在部署CloudStack时,Hypervisor主机不能运行任何虚拟机
警告
The lack of up-to-date hotfixes can lead to data corruption and lost VMs.
From https://www.citrix.com/English/ss/downloads/, download the appropriate version of XenServer for your CloudStack version (see “System Requirements for XenServer Hosts”). Install it using the Citrix XenServer Installation Guide.
较旧版本的XenServer:
下载最新版本的XenServer不需要使用Citrix账户。如果你要下载旧版本的XenServer,你需要注册一个账户。
配置XenServer dom0占用更大的内存可以使XenServer运行更多的虚拟机。我们建议修改为2940MB。如何来做这些更改,请看 http://support.citrix.com/article/CTX126531。这篇文档是针对XenServer 5.6的,但同样适用于XenServer6.0。
CloudStack中同一群集下的所有XenServer主机必须拥有同样的用户名和密码。
主机必须配置NTP。同一提供点中的所有主机时间必须相同。
安装NTP.
# yum install ntp
编辑NTP配置文件指定NTP服务器。
# vi /etc/ntp.conf
在文件中添加一行或多行你想使用的服务器地址. 例如:
server 0.xenserver.pool.ntp.org
server 1.xenserver.pool.ntp.org
server 2.xenserver.pool.ntp.org
server 3.xenserver.pool.ntp.org
重启NTP客户端。
# service ntpd restart
确保机器重启之后NTP会自动启动。
# chkconfig ntpd on
(可选)
要在XenServer上启用安全组、弹性负载均衡和弹性IP,请下载安装CloudStack XenServer支持包(CSP)。安装完XenServer之后,在每台XenServer主机上执行下列步骤。
For XenServer 6.1:
CSP functionality is already present in XenServer 6.1
Run the below command
xe-switch-network-backend bridge
update sysctl.conf with the following
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-arptables = 1
$ sysctl -p /etc/sysctl.conf
For XenServer 6.0.2, 6.0, 5.6 SP2:
请从下列链接之一下载CSP至XenServer主机:
适用于XenServer 6.0.2:
http://download.cloud.com/releases/3.0.1/XS-6.0.2/xenserver-cloud-supp.tgz
适用于XenServer 5.6 SP2:
http://download.cloud.com/releases/2.2.0/xenserver-cloud-supp.tgz
适用于XenServer 6.0:
http://download.cloud.com/releases/3.0/xenserver-cloud-supp.tgz
解压文件:
# tar xf xenserver-cloud-supp.tgz
执行下列脚本:
# xe-install-supplemental-pack xenserver-cloud-supp.iso
如果XenServer主机所在的区域使用的是基本网络模式 ,请禁用Open vSwitch (OVS):
# xe-switch-network-backend bridge
操作完成之后重启主机。
现在可以在CloudStack中添加XenServer。
CloudStack原生支持NFS,iSCSI和本地存储。如果使用其中的一种存储类型,则不需要创建XenServer存储库(“SR”)。
但是,如果你想使用其他技术的存储,如FC存储,你必须自行设置SR。请按以下步骤操作来设置SR。如果你要设置的主机存在于XenServer池中,请在master主机上执行这些操作。如果是单台节点主机,则在该XenServer主机上操作即可。
通过光纤通道将集群中的所有主机连接至光纤存储设备
重新扫描SCSI总线。使用下列命令或者在XenCenter中使用HBA rescan按钮来完成扫描。
# scsi-rescan
在所有主机上重复步骤2.
检查确保已经识别到新的SCSI磁盘。
# ls /dev/disk/by-id/scsi-360a98000503365344e6f6177615a516b -l
输出结果如下所示,指定的文件名稍许不同(scsi-<scsiID>):
lrwxrwxrwx 1 root root 9 Mar 16 13:47
/dev/disk/by-id/scsi-360a98000503365344e6f6177615a516b -> ../../sdc
在所有主机上重复步骤4
在存储服务器中,运行下列命令获取新添加SR的唯一ID标识。
# uuidgen
输出结果如下所示,指定的ID不同:
e6849e96-86c3-4f2c-8fcc-350cc711be3d
创建FC SR 。在name-label中,输入刚才获取的ID。
# xe sr-create type=lvmohba shared=true
device-config:SCSIid=360a98000503365344e6f6177615a516b
name-label="e6849e96-86c3-4f2c-8fcc-350cc711be3d"
这条命令会获取SR的ID,以下面为例(你的UUID不同):
7a143820-e893-6c6a-236e-472da6ee66bf
使用下面的命令为SR创建通俗易懂的描述, uuid参数使用使用之前命令返回的SR ID. 在名称描述中,设置任何你自己喜欢的描述。
# xe sr-param-set uuid=7a143820-e893-6c6a-236e-472da6ee66bf name-description="Fiber Channel storage repository"
记录这些值,之后在CloudStack中添加存储时会用到(查看 “添加主存储”)。在添加主存储对话框中的协议一项,选择PreSetup。在SR Name-Label中,输入之前设置的 name-label(在本示例中为e6849e96-86c3-4f2c-8fcc-350cc711be3d)。
(可选)如果想在FC SAN上启用多路径I/O,请参考SAN供应商提供的文档。
在Citrix XenServer上配置存储库时,你可以启用多路径I/O,它是通过在服务器与SAN设备之间提供冗余的物理组件实现,提供了更高的可靠性。要启用多路径,请使用 XenServer文档中提供的SAN驱动程序。从下面链接开始:
你同样可以咨询SAN提供商提供关于配置Citrix存储库多路径的建议。
记录这些值,之后在CloudStack中添加存储时将会用到(查看 “添加主存储”)。在添加主存储对话框中的协议一项,选择PreSetup。在SR Name-Label中,输入之前创建的SR名称。
如果遇到任何困难, 请通过SAN供应商团队获得支持. 如果仍然无法解决你的问题, 请联系技术支持.
XenServer安装完成后, 需要对网络做一些额外的设置。此时, 你应该对主机上的网卡及每个网络传输的流量有一个整体规划。网络连接必须满足你的规划.
如果你计划使用网卡绑定,那么所有主机上的网卡的连接必须相同。比如,如果群集中的一台主机eth0为专用绑定,那么其他主机上的eth0也必须为专用绑定。
分配给管理网络的IP必须是静态IP。它可以通过DHCP保留或者在主机上指定。
CloudStack使用XenServer上的不同网卡或绑定来配置不同流量类型。你可以在管理服务器上通过输入XenServer适配器标签来控制这些流量。CloudStack中的标签名称就是物理接口或绑定的名称。在简单的网络中,可以不填写标签。
在XenServer环境中配置网络时,必须正确的配置网络流量标签,确保CloudStack将虚拟接口绑定到正确的物理设备上。XenServer的网络标签必须与配置CloudStack的网络时指定的XenServer流量标签一致。运行以下命令来设置:
xe network-param-set uuid=<network id> name-label=<CloudStack traffic label>
CloudStack支持公共网络使用第二块网卡(或者是2块网卡绑定,在 XenServer中的网卡绑定(可选) 有描述)。如果没有使用绑定,公共网络可以使用群集中不同主机上的不同网卡。比如,公共网络可以使用节点A上的eth0和节点B上的eth1。但是,用于公共网络的名称标签在所有主机上必须一致。举个例子,我们在XenServer上设定了网络标签”cloud-public”。在安装完管理服务器之后,你必须使用( “cloud-public”)作为对应的CloudStack的网络流量标签;这个在 `”管理服务器的安装” <installation.html#management-server-installation>`_中有介绍。
如果你使用双网卡绑定作为公共网络,请参阅 XenServer中的网卡绑定(可选)。
如果你指定单网卡作为公共网络,在加入CloudStack环境之前按照下面的流程配置每个主机。
运行xe network-list,查找公共网络。通常它的名字就是public。找到之后记录UUID。可以称之为<UUID-Public>。
运行以下命令。
# xe network-param-set name-label=cloud-public uuid=<UUID-Public>
CloudStack支持在XenServer上使用多个来宾网络。在XenServer中为每个网络都被分配名称标签。例如,你可能有两个名称分别为”cloud-guest”和”cloud-guest2”的网络。在配置好管理服务器并且运行后,你必须使用这些标签将这些网络添加到CloudStack中,以便CloudStack能够识别到这些网络。
在将主机添加到CloudStack之前,请在每个新主机上执行以下操作:
运行xe network-list,找出来宾网络。并记录UUID。可以称为<UUID-Guest>。
运行下面的命令, 替换你自己的名称标签和UUID.
# xe network-param-set name-label=<cloud-guestN> uuid=<UUID-Guest>
对每个额外的来宾网络都重复这些步骤,注意每次要使用不同的名称标签和UUID。
在绑定网卡之前,你可以有选择的配置一个独立的存储网络。使用1到2个网卡,上述给出了两块网卡绑定的示例。配置一个独立的存储网络是管理的职责。
为存储网络设置一个与其他网络不同的名称标签。
让独立的存储网络工作正常,必须可以通过它的接口ping通主存储设备的IP。比如,如果eth0是管理网络的网卡,ping -I eth0 <primary storage device IP>必须是不通的。在所有的部署环境里,通过管理网络必须能ping通辅助存储设备的IP。如果辅助存储设备是在存储网络中,那么通过存储网络同样也要能ping通它。
你可以设置两个独立的存储网络。例如,使用两块独立网卡实现iSCSI多路径。当然,两个网络都需要自己的名称标签。
如果没有做绑定,管理员必须为所有主机上(主、从节点)的存储网络设置名称标签。
此处示例配置eth5访问172.16.0.0/24的存储网络。
# xe pif-list host-name-label='hostname' device=eth5
uuid(RO): ab0d3dd4-5744-8fae-9693-a022c7a3471d
device ( RO): eth5
#xe pif-reconfigure-ip DNS=172.16.3.3 gateway=172.16.0.1 IP=172.16.0.55 mode=static netmask=255.255.255.0 uuid=ab0d3dd4-5744-8fae-9693-a022c7a3471d
XenServer支持Source Level Balancing (SLB) NIC绑定。两块网卡可被绑定在一起承载公共网络、管理网络和来宾网络流量,或这些网络的组合。单独的存储网络同样可以。以下是一些配置的示例:
所有的网卡绑定都是可选的
XenServer期望群集中所有的节点都拥有相同的网络布线,以及相同的绑定。在安装完成后第一台主机将成为Master,而随后加入到群集中的其他主机都将成为Slave。Master主机上的网卡绑定设置会覆盖其他主机的网络配置。在Master和Slaver上设置网卡绑定的步骤不同,重点包括几个部分:
在将主机添加至CloudStack之前管理员必须绑定管理网络的网卡。
使用下述步骤在XenServer上创建网卡绑定。这些步骤只在群集中第一台主机上运行即可。本示例为cloud-private网络绑定了两块物理网卡(eth0和eth1)。
找到想要绑定在一起的物理网卡。
# xe pif-list host-name-label='hostname' device=eth0
# xe pif-list host-name-label='hostname' device=eth1
如上命令显示了eth0、eth1和对应的UUID。并替换你的网卡编号。上述命令返回的UUID称为slave1-UUID和slave2-UUID。
为该绑定创建一个新的网络。例如,一个名为“cloud-public”的新网络。
标签非常重要。因为CloudStack根据配置的名称查找网络。必须对云中所有主机的管理网络使用同样的名称标签(name-label)。
# xe network-create name-label=cloud-private
# xe bond-create network-uuid=[uuid of cloud-private created above]
pif-uuids=[slave1-uuid],[slave2-uuid]
现在有了可以被CloudStack识别为管理网络的网卡绑定。
可以在单独的公共网络上执行绑定。管理员可以将使用网卡绑定的公共网络与管理网络区分开。
以下步骤仅在群集的第一台主机中运行。本示例为cloud-public绑定了两块物理网卡(eth2和eth3)。
找到想要绑定在一起的物理网卡。
# xe pif-list host-name-label='hostname' device=eth2
# xe pif-list host-name-label='hostname' device=eth3
以上命令显示了eth2、eth3和对应的UUID。替换你的网卡编号。将上述命令返回的UUID称为slave1-UUID和slave2-UUID。
为网卡绑定创建一个新的网络。比如,一个名为”cloud-public”的新网络。
该标签非常重要。因为CloudStack根据配置的名称来查找网络。必须对云中所有物理主机的公共网络使用同样的名称标签(name-label)。
# xe network-create name-label=cloud-public
# xe bond-create network-uuid=[uuid of cloud-public created above]
pif-uuids=[slave1-uuid],[slave2-uuid]
现在有了被CloudStack识别为公共网络的网卡绑定。
在master主机添加了(任何)绑定网卡的基础上,可以添加其他的slave主机。对所有添加至群集的其他主机执行下面的命令。他的作用是将这些主机都加入master所在的同一个XenServer池中。
# xe pool-join master-address=[master IP] master-username=root
master-password=[your password]
所有主机添加至资源池后,运行 cloud-setup-bond脚本。此脚本将配置群集中所有主机的网卡绑定。
将管理服务器中/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/cloud-setup-bonding.sh拷贝到master主机中并确认该脚本可执行。
运行脚本:
# ./cloud-setup-bonding.sh
现在,群集内所有主机的网卡绑定都已配置正确。
本章节介绍了如何升级CloudStack环境中的XenServer。实际升级的操作在XenServer文档中有详细描述,但是在升级前后有些额外的步骤必须执行。
注解
确保硬件可以被新版本XenServer支持。
升级XenServer:
升级数据库。在管理服务器节点上:
备份数据库:
# mysqldump --user=root --databases cloud > cloud.backup.sql
# mysqldump --user=root --databases cloud_usage > cloud_usage.backup.sql
需要更改升级后的主机中虚拟机的操作系统类型。
重启管理服务和Usage服务. 只需为所有的集群做一次这样的操作。
# service cloudstack-management start
# service cloudstack-usage start
在CloudStack中断开XenServer群集连接。
登录到群集中的任意一台主机,运行下面的命令清除VLAN信息:
# . /opt/xensource/bin/cloud-clean-vlan.sh
仍旧在这台已经登录的主机中,运行下面的升级准备脚本:
# /opt/xensource/bin/cloud-prepare-upgrade.sh
故障排除:如果看到 “can’t eject CD,” 错误,请登录到虚拟机将光盘卸载,并重新运行脚本。
升级群集中所有的XenServer主机。首先升级master节点。
将该主机上的所有虚拟机动态迁移到其他主机。请参照管理指南了解动态迁移指导。
故障排除:迁移虚拟机时可能会遇到下面的错误:
[root@xenserver-qa-2-49-4 ~]# xe vm-migrate live=true host=xenserver-qa-2-49-5 vm=i-2-8-VM
You attempted an operation on a VM which requires PV drivers to be installed but the drivers were not detected.
vm: b6cf79c8-02ee-050b-922f-49583d9f1a14 (i-2-8-VM)
解决这个问题,请运行下面的命令:
# /opt/xensource/bin/make_migratable.sh b6cf79c8-02ee-050b-922f-49583d9f1a14
重启主机。
要升级更新版本的XenServer。请执行XenServer文档中的步骤。
在升级完成之后,将下列文件从管理服务器复制到这台主机,文件所在路径如下:
复制管理服务器的文件 | 复制到XenServer主机的路径 |
---|---|
/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/xenserver60/NFSSR.py | /opt/xensource/sm/NFSSR.py |
/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/setupxenserver.sh | /opt/xensource/bin/setupxenserver.sh |
/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/make_migratable.sh | /opt/xensource/bin/make_migratable.sh |
/usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/cloud-clean-vlan.sh | /opt/xensource/bin/cloud-clean-vlan.sh |
执行下列脚本:
# /opt/xensource/bin/setupxenserver.sh
故障排除:如果看到下面的错误信息,可以忽略它。
mv: cannot stat `/etc/cron.daily/logrotate`: No such file or directory
将XenServer主机连接至存储库(物理的块设备):
# for pbd in `xe pbd-list currently-attached=false| grep ^uuid | awk '{print $NF}'`; do xe pbd-plug uuid=$pbd ; done
注解
如果添加一台主机到这个XenServer资源池中,你必须将这台主机上的所有的虚机迁移到其他主机,然后将这台主机从原来的XenServer资源池中移除。
重复这些步骤,将每台主机都升级到相同的XenServer版本。
在XenServer群集中的一台主机上运行下面命令来清除主机标签:
# for host in $(xe host-list | grep ^uuid | awk '{print $NF}') ; do xe host-param-clear uuid=$host param-name=tags; done;
注解
当复制和粘贴命令时,请确保没有多余的换行符,因为一些文档查看器可能会在复制时加上换行符。
在CloudStack中重新连接XenServer群集。
当所有的主机都是运行状态后, 在集群中的一台主机上运行下列的命令:
# /opt/xensource/bin/cloud-clean-vlan.sh
正确的网络设置对于CloudStack能否成功安装至关重要。遵循本节包含的信息,指导你搭建正确的网络配置。
CloudStack提供二种网络类型:
Basic For AWS-style networking. Provides a single network where guest isolation can be provided through layer-3 means such as security groups (IP address source filtering).
Advanced For more sophisticated network topologies. This network model provides the most flexibility in defining guest networks, but requires more configuration steps than basic networking.
每个区域都有基本或高级网络。一个区域的整个生命周期中,不论是基本或高级网络。一旦在CloudStack中选择并配置区域的网络类型,就无法再修改。
下表比较了两种网络类型的功能
网络功能 | 基本网络 | 高级网络 |
---|---|---|
网络数量 | 单一网络 | 多种网络 |
防火墙类型 | 物理 | 物理和虚拟 |
负载均衡 | 物理 | 物理和虚拟 |
隔离类型 | 三层 | 二层和三层 |
VPN支持 | 否 | 是 |
端口转发 | 物理 | 物理和虚拟 |
1:1 NAT | 物理 | 物理和虚拟 |
Source NAT | 否 | 物理和虚拟 |
用户数据 | 是 | 是 |
网络监控 | 在物理路由器上:sFlow / netFlow | Hypervisor和虚拟路由器 |
DNS和DHCP | 是 | 是 |
在一个云中可能会存在二种网络类型。但无论如何,一个给定的区域必须使用基本网络或高级网络。
单一的物理网络可以被分割不同类型的网络流量。账户也可以分割来宾流量。你可以通过划分VLAN来隔离流量。如果你在物理网络中划分了VLAN,确保VLAN标签的数值在独立范围。
公共和来宾流量要求使用VLAN,下面是一个VLAN分配的示例:
VLAN IDs | 流量类型 | 范围 |
---|---|---|
小于500 | 管理流量。用于管理目的。 | CloudStack,hypervisors,系统VM可以访问。 |
500-599 | 承载公共流量。 | CloudStack账户。 |
600-799 | 承载来宾流量 | CloudStack 账户。 从这个池中选择账户特定的VLAN。 |
800-899 | 承载来宾流量 | CloudStack 账户。CloudStack管理员为账户指定特定的VLAN。 |
900-999 | 承载来宾流量 | CloudStack 账户。可作为项目、域或所有账户的作用域。 |
大于1000 | 保留为将来使用 |
本节包含了一个特定交换机型号的示例配置,作为区域级别的三层交换。它假设VLAN管理协议,例如VTP、GVRP等已经被禁用。如果你正在使用VTP或GVRP,那么你必须适当的修改示例脚本。
以下步骤显示如何配置区域级别的三层交换机Dell 62xx。这些步骤假设VLAN。201用于Pod1中未标记的私有IP线路。并且Pod1中的二层交换机已经连接到GigabitEthernet1/0/1端口。
DELL 62xx系列交换机最大支持1024个VLAN。
在VLAN数据库模式配置VLAN。
vlan database
vlan 200-999
exit
配置端口1/g1。
interface ethernet 1/g1
switchport mode general
switchport general pvid 201
switchport general allowed vlan add 201 untagged
switchport general allowed vlan add 300-999 tagged
exit
端口1/g1的配置说明:
以下步骤显示如何配置Cisco 3750作为区域级别的三层交换机。这些步骤假设VLAN 201用于Pod1中未标记的私有IP线路。并且Pod1中的二层交换机已经连接到GigabitEthernet1/0/1端口。
设置VTP为透明模式,以便我们使用超过1000的VLAN。虽然我们只用到999,但VTP透明模式并不做严格要求。
vtp mode transparent
vlan 200-999
exit
配置GigabitEthernet1/0/1。
interface GigabitEthernet1/0/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk native vlan 201
exit
端口GigabitEthernet1/g1的配置说明:
在Pod中的二层交换机提供接入层功能
本节包含了一个特定交换机型号的示例配置,作为Pod级别的二层交换机。它假设VLAN管理协议,例如VTP、GVRP等已经被禁用。如果你正在使用VTP或GVRP,那么你必须适当的修改示例脚本。
以下步骤将演示如何配置Dell 62xx作为Pod级别的二层交换机。
在VLAN数据库模式配置VLAN。
vlan database
vlan 300-999
exit
VLAN201用于Pod1中未标记的私有IP线路。并且Pod1已经连接到该二层交换机。
interface range ethernet all
switchport mode general
switchport general allowed vlan add 300-999 tagged
exit
所有的以太网端口功能配置说明:
以下步骤将演示如何配置cisco 3750作为Pod级别的二层交换机
设置VTP为透明模式,以便我们使用超过1000的VLAN。虽然我们只用到999,但VTP透明模式并不做严格要求。
vtp mode transparent
vlan 300-999
exit
配置所有的端口使用dot1q协议,并设置201为本征VLAN。
interface range GigabitEthernet 1/0/1-24
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk native vlan 201
exit
默认情况下,Cisco允许所有VLAN通过。如果本征VLAN ID不相同的2个端口连接在一起时,Cisco交换机提出控诉。这就是为什么必须指定VLAN 201为二交换机的本征VLAN。
所有部署都应该有一个防火墙保护管理服务器;查看防火墙的一般规定。 根据情况不同,一些部署也可能用到Juniper SRX防火墙作为来宾网络的默认网关; 参阅 “集成外部来宾防火墙Juniper SRX (可选)”.
硬件防火墙必需服务于两个目的:
为了达到上述目的,你必须设置固定配置的防火墙。用户被配置到云中,不需要改变防火墙规则和策略。任何支持NAT和站点到站点VPN的硬件防火墙,不论品牌,都可以使用。
注解
客户使用高级网络时才有效。
CloudStack中提供了对Juniper SRX系列防火墙的直接管理。这使得CloudStack能建立公共IP到客户虚拟机的静态NAT映射,并利用Juniper设备替代虚拟路由器提供防火墙服务。每个区域中可以有一个或多个Juniper SRX设备。这个特性是可选的。如果不提供Juniper设备集成,CloudStack会使用虚拟路由器提供这些服务。
Juniper SRX可以和任意的外部负载均衡器一起使用。外部网络元素可以部署为并排或内联结构。
CloudStack要求按照如下信息配置Juniper SRX防火墙:
注解
支持SRX软件版本为10.3或者更高。
根据供应商提供的说明书安装你的SRX设备。
分别使用两个接口连接管理和公共网络,或者,你可以使用同一个接口来连接这两个网络,但需要为公共网络设置一个VLAN。
确保在专有接口上开启了 “vlan-tagging” 。
记录公共和专用接口名称。如果你在公共接口中使用了VLAN,应该在接口名称后面添加一个”.[VLAN TAG]”。例如,如果你使用 ge-0/0/3 作为公共接口并且VLAN 标签为301。那么你的公共接口名称应为”ge-0/0/3.301”。你的专用接口应始终不添加任何标签,因为CloudStack会自动在逻辑接口上添加标签。
创建公共安全区域和专用安全区域。默认情况下,这些已经存在并分别称为”untrust” 和 “trust”。为公共区域添加公共接口和为专用区域添加专用接口。并记录下安全区域名称。
确保专用区域到公共区域的安全策略允许所有流量通过。
请注意CloudStack登录所用账户的用户名和密码符合编程规则。
确保已经开启 “ssh” 和 “xnm-clear-text” 等系统服务。
如果需要统计流量:
创建传入的防火墙过滤和传出的防火墙过滤。这些策略应该有相同的名称分别作为你的公共安全区域名称和专用安全区域名称。过滤应该设置到 “特定接口”。 例如,在这个配置中公共区域是 “untrust”,专用区域是 “trust”:
root@cloud-srx# show firewall
filter trust {
interface-specific;
}
filter untrust {
interface-specific;
}
在你的公共接口添加防火墙过滤。例如,一个示例配置(ge-0/0/3.0为公共接口,untrust为公共安全区域,trust为专用安全区域)
ge-0/0/3 {
unit 0 {
family inet {
filter {
input untrust;
output trust;
}
address 172.25.0.252/16;
}
}
}
确保SRX中的专用接口允许所有VLAN通过。
安装好CloudStack管理端后,使用管理员帐号登录CloudStack用户界面。
在左侧导航栏中,点击基础架构
点击区域中的查看更多。
选择你要设置的区域。
点击网络选项卡。
点击示意图网络服务提供程序中的配置(你可能需要向下滚动才能看到)。
点击SRX。
点击(+)按钮添加一个新的SRX,并提供如下信息:
点击确定。
点击全局设置。设置external.network.stats.interval参数,指定CloudStack从Juniper SRX收集网络使用情况的时间间隔。如果你不使用SRX统计网络使用情况,即设置为0.
Cisco虚拟网络管理中心(VNMC)为Cisco网络虚拟服务提供集中式多设备和策略管理。您可以通过整合Cisco VNMC和CloudStack使用ASA 1000v云防火墙提供防火墙和NAT服务。在开启了Cisco Nexus 1000v分布式虚拟交换机功能的CloudStack群集中。这样部署,您将可以:
CloudStack对于Cisco VNMC的支持基于开启了Cisco Nexus 1000v分布式虚拟交换机功能的VMware虚拟化管理平台。
Cisco ASA 1000v防火墙仅支持隔离的来宾网络。
Cisco ASA 1000v不支持VPC。
Cisco ASA 1000v不支持负载均衡。
当使用Cisco VNMC防火墙创建的来宾网络时,一个额外的公共IP和SNAT IP一起被获取。SNAT IP用于规则,而额外的IP用于ASA外部接口。确保这一额外的公共IP不会被释放。你可以在网络一旦处在执行状态和获取其他公共IP之前确定这个IP。这个额外的IP没有被标识为SNAT。在你的来宾网络中可以通过Cisco VNMC来查找ASA外部接口的IP地址。
使用单一网络中的公共IP地址段。不能添加不同网段的IP地址。
每个VLAN中只允许一个ASA实例。因为ASA端口不支持多VLAN的trunk模式。因此,一个来宾网络中只能有一个ASA实例。
每个区域中,只允许一个Cisco VNMC.
只支持在Inline模式下部署负载均衡器。
ASA防火墙策略适用于来宾网络中所有的公共IP地址。不同于虚拟路由器创建的防火墙规则,ASA设备创建的规则不绑定特定的公共IP地址。
使用一个支持vservice命令的Cisco Nexus 1000v分布式虚拟交换机版本。例如:nexus-1000v.4.2.1.SV1.5.2b.bin
使用Cisco VNMC在CloudStack中创建来宾网络,要求vservice命令在Nexus交换机中是可用的。
在vCenter环境中配置Cisco Nexus 1000v分布式交换机。
在Cisco Nexus 1000v 分布式虚拟交换机中创建两个(内部和外部)网络接口的端口配置文件。记录下内部端口配置,在CloudStack中添加ASA设备时需要提供。
更多配置信息,请查阅 “配置vSphere群集和Nexus 1000v 虚拟交换机”.
部署和配置Cisco VNMC。
更多信息,请查阅 安装Cisco虚拟网络管理中心 和 配置Cisco虚拟网络管理中心.
注册Cisco Nexus 1000v分布式交换机到Cisco VNMC。
更多信息,请查阅 注册Cisco Nexus 1000V 和Cisco VNMC.
在Cisco Nexus 1000v分布式交换机中创建内部和外部端口配置文件。
更多信息,请查阅 “配置vSphere群集和Nexus 1000v 虚拟交换机”.
部署Cisco ASA 1000v设备。
更多信息,请查阅 使用VNMC设置ASA 1000V.
通常情况下,你可以创建一个ASA 1000v设备池通过CloudStack来注册他们。
设置Cisco ASA 1000v设备需指定如下信息:
注册Cisco ASA 1000v到VNMC。
打开Cisco ASA 1000v实例电源后,通过ASA控制台注册VNMC。
确保满足所有的先决条件。
参阅 “先决条件”.
添加 VNMC 实例。
参阅 “添加 VNMC 实例”.
添加 ASA 1000v 实例。
创建一个网络方案,使用Cisco VNMC提供你期望的服务。
使用你刚创建的网络方案,创建一个隔离的来宾网络。
作为管理员登录到CloudStack用户界面。
在左侧导航栏中,点击基础架构
点击区域中的查看更多。
选择你要设置的区域。
点击物理网络标签卡。
点击示意图’网络服务提供程序’中的配置
你可能需要向下滚动才能看到。
点击Cisco VNMC
点击查看VNMC设备。
点击添加VNMC设备并提供如下信息:
点击确定。
作为管理员登录到CloudStack用户界面。
在左侧导航栏中,点击基础架构
点击区域中的查看更多。
选择你要设置的区域。
点击物理网络标签卡。
点击示意图’网络服务提供程序’中的配置
你可能需要向下滚动才能看到。
点击Cisco VNMC
点击查看ASA 1000v。
点击添加Cisco ASA 1000v资源并提供如下信息:
主机: ASA 1000v实例的管理地址。该IP地址用来连接ASA 1000V。
内部端口配置文件: 在Cisco Nexus1000v分布式虚拟交换机中配置内部端口。
群集: 你正在添加ASA 1000v实例所在的VMware群集。
确保在群集中启用了Cisco Nexus 1000v分布式虚拟交换机。
点击确定。
要来宾网络支持Cisco ASA 1000v,按照如下信息添加网络方案:
使用用户或管理员登录到CloudStack用户界面。
下拉选择方案,选择网络方案:
点击添加网络方案。
在对话框中,选择如下操作:
点击确定
已经创建网络方案。
您可以在做了必要的清理后重新在新的来宾网络中使用ASA 1000v设备。通常情况下,ASA 1000v is cleaned up when the logical edge firewall is cleaned up in VNMC。如果清理动作没有发生,你需要将设备恢复到出厂设置,才能在新的来宾网络中使用。作为其中的一部分,需要在设备上启用ssh并通过向VNMC注册存储SSH凭证。
打开ASA设备的命令行:
运行如下命令:
ASA1000V(config)# reload
提示您如下信息:
System config has been modified. Save? [Y]es/[N]o:"
输入N。
你会得到如下确认信息:
"Proceed with reload? [confirm]"
重启设备。
注册ASA 1000v设备到VNMC:
ASA1000V(config)# vnmc policy-agent
ASA1000V(config-vnmc-policy-agent)# registration host vnmc_ip_address
ASA1000V(config-vnmc-policy-agent)# shared-secret key where key is the shared secret for authentication of the ASA 1000V connection to the Cisco VNMC
CloudStack可以使用Citrix NetScaler或BigIP F5负载均衡器为客户提供负载平衡服务。如果未启用,CloudStack将使用虚拟路由器中的软件负载平衡。
在CloudStack管理端中安装和启用外部负载均衡:
根据供应商提供的说明书安装你的设备。
连接到承载公共流量和管理流量的网络(可以是同一个网络)。
记录IP地址、用户名、密码、公共接口名称和专用接口名称。接口名称类似 “1.1” 或 “1.2”。
确保VLAN可以通过trunk到管理网络接口。
安装好CloudStack管理端后,使用管理员帐号登录CloudStack用户界面。
在左侧导航栏中,点击基础架构
点击区域中的查看更多。
选择你要设置的区域。
点击网络选项卡。
点击示意图网络服务提供程序中的配置(你可能需要向下滚动才能看到)。
点击NetScaler或F5.
点击(+)添加按钮并提供如下信息:
对于NetScaler:
点击确定。
外部负载平衡器的安装和配置完成后,你就可以开始添加虚拟机和NAT或负载均衡规则。
CloudStack可以使用负载均衡器为多管理服务器提供一个虚拟IP。管理员负责创建管理服务器的负载均衡规则。应用程序需要跨多个持久性或stickiness的会话。下表列出了需要进行负载平衡的端口和是否有持久性要求。
即使不需要持久性,也使它是允许的。
源端口 | 目标端口 | 协议 | 持续请求 |
---|---|---|---|
80或者443 | 8080 (或者 20400 with AJP) | HTTP (或者AJP) | 是 |
8250 | 8250 | TCP | 是 |
8096 | 8096 | HTTP | 否 |
除了上面的设置,管理员还负责设置‘host’全局配置值,由管理服务器IP地址更改为负载均衡虚拟IP地址。如果‘host’值未设置为VIP的8250端口并且一台管理服务器崩溃时,用户界面依旧可用,但系统虚拟机将无法与管理服务器联系。
公共互联网必须不能访问管理服务器的8096和8250端口。
SSVM需要挂载辅助存储中的NFS共享目录。即使有一个单独的存储网络,辅助存储的流量也会通过管理网络。如果存储网络可用,主存储的流量会通过存储网络。如果你选择辅助存储也使用存储网络,你必须确保有一条从管理网络到存储网络的路由。
如果整合了外部防火墙设备,公共IP的VLAN必须通过trunk到达主机。这是支持SSVM和CPVM必须满足的。
使用高级网络,专用和公共网络必须分离子网。
管理服务器与XenServer服务器通过22(ssh)、80(http)和443(https)端口通信。
CloudStack管理服务器通过https与Hyper-V代理通信。管理服务器与Hyper-V主机之间的安全通信端口为8250。
管理服务器与KVM主机通过22(ssh)端口通信。
管理服务器与LXC主机通过22(ssh)端口通信。
为了在来宾网络中收集网络数据,CloudStack需要从网络中安装的外部网络数据收集器中提取。并通过整合CloudStack和inMon流量哨兵实现来宾网络的数据统计。
网络哨兵是一个收集网络流量使用数据的套件。CloudStack可以将流量哨兵中的信息统计到自己的使用记录中,为云基础架构的计费用户提供了依据。流量哨兵使用的流量监控协议为sFlow。路由器和交换机将生成的sFlow记录提供给流量哨兵,然后CloudStack通过查询流量哨兵的数据库来获取这些信息。
为了构建查询,CloudStack确定了当前来宾IP的查询时间间隔。这既包含新分配的IP地址,也包含之前已被分配并且在继续使用的IP地址。CloudStack查询流量哨兵,在分配的时间段内这些IP的网络统计信息。返回的数据是账户每个IP地址被分配和释放的时间戳,以便在CloudStack中为每个账户创建计费记录。当使用服务运行时便会收集这些数据
配置整合CloudStack和流量哨兵:
在网络基础设施中,安装和配置流量哨兵收集流量数据。 关于安装和配置步骤,请查阅inMon 流量哨兵文档.
在流量哨兵用户界面中,配置流量哨兵允许来宾用户使用脚本查询。CloudStack将通过执行远程查询为来宾用户的一个或多个IP和收集网络使用情况。
点击 File > Users > Access Control > Reports Query, 然后从下拉列表中选择来宾。
在CloudStack中,使用API中的addTrafficMonitor命令添加流量哨兵主机。传入的流量哨兵URL类似于protocol + host + port (可选);例如, http://10.147.28.100:8080。 关于addTrafficMonitor命令用法,请参阅API文档 API Documentation.
关于如何调用CloudStack API,请参阅 CloudStack API 开发指南。
作为管理员登录到CloudStack用户界面。
在全局设置页面中,查找如下参数进行设置:
direct.network.stats.interval: 你希望CloudStack多久收集一次流量数据。
在外部网络情况下,每个虚拟机都必须有独立的来宾IP地址。这里有两个参数你需要考虑如何在CloudStack中进行配置:在同一时刻,你希望区域中有多少VLAN和多少虚拟机在运行。
使用如下表格来确定如何在CloudStack部署时修改配置。
guest.vlan.bits | 单个区域运行虚拟机的最大值 | 区域中VLAN的最大值 |
---|---|---|
12 | 4096 | 4094 |
11 | 8192 | 2048 |
10 | 16384 | 1024 |
10 | 32768 | 512 |
基于部署的需求,选择合适的guest.vlan.bits参数值。在全局配置设置中编辑该参数,并重启管理服务。
CloudStack is designed to work with a wide variety of commodity and enterprise-rated storage systems. CloudStack can also leverage the local disks within the hypervisor hosts if supported by the selected hypervisor. Storage type support for guest virtual disks differs based on hypervisor selection.
存储类型 | XenServer | vSphere | KVM |
---|---|---|---|
NFS | 支持 | 支持 | 支持 |
iSCSI | 支持 | 通过VMFS支持 | 通过集群文件系统支持 |
Fiber Channel | 通过Pre-existing SR支持 | 支持 | 通过集群文件系统支持 |
本地磁盘 | 支持 | 支持 | 支持 |
针对KVM使用集群逻辑卷管理器(CLVM),不受CloudStack官方支持。
CloudStack is designed to work with any scalable secondary storage system. The only requirement is that the secondary storage system supports the NFS protocol. For large, multi-zone deployments, S3 compatible storage is also supported for secondary storage. This allows for secondary storage which can span an entire region, however an NFS staging area must be maintained in each zone as most hypervisors are not capable of directly mounting S3 type storage.
In a small-scale setup, a single NFS server can function as both primary and secondary storage. The NFS server must export two separate shares, one for primary storage and the other for secondary storage. This could be a VM or physical host running an NFS service on a Linux OS or a virtual software appliance. Disk and network performance are still important in a small scale setup to get a good experience when deploying, running or snapshotting VMs.
In large-scale environments primary and secondary storage typically consist of independent physical storage arrays.
Primary storage is likely to have to support mostly random read/write I/O once a template has been deployed. Secondary storage is only going to experience sustained sequential reads or writes.
In clouds which will experience a large number of users taking snapshots or deploying VMs at the same time, secondary storage performance will be important to maintain a good user experience.
It is important to start the design of your storage with the a rough profile of the workloads which it will be required to support. Care should be taken to consider the IOPS demands of your guest VMs as much as the volume of data to be stored and the bandwidth (MB/s) available at the storage interfaces.
There are many different storage types available which are generally suitable for CloudStack environments. Specific use cases should be considered when deciding the best one for your environment and financial constraints often make the ‘perfect’ storage architecture economically unrealistic.
Broadly, the architectures of the available primary storage types can be split into 3 types:
Local storage works best for pure ‘cloud-era’ workloads which rarely need to be migrated between storage pools and where HA of individual VMs is not required. As SSDs become more mainstream/affordable, local storage based VMs can now be served with the size of IOPS which previously could only be generated by large arrays with 10s of spindles. Local storage is highly scalable because as you add hosts you would add the same proportion of storage. Local Storage is relatively inefficent as it can not take advantage of linked clones or any deduplication.
Care should be taken when designing your cloud to take into consideration not only the performance of your disk arrays but also the bandwidth available to move that traffic between the switch fabric and the array interfaces.
The first thing to understand is the process of provisioning primary storage. When you create a primary storage pool for any given cluster, the CloudStack management server tells each hosts’ hypervisor to mount the NFS share or (iSCSI LUN). The storage pool will be presented within the hypervisor as a datastore (VMware), storage repository (XenServer/XCP) or a mount point (KVM), the important point is that it is the hypervisor itself that communicates with the primary storage, the CloudStack management server only communicates with the host hypervisor. Now, all hypervisors communicate with the outside world via some kind of management interface – think VMKernel port on ESXi or ‘Management Interface’ on XenServer. As the CloudStack management server needs to communicate with the hypervisor in the host, this management interface must be on the CloudStack ‘management’ or ‘private’ network. There may be other interfaces configured on your host carrying guest and public traffic to/from VMs within the hosts but the hypervisor itself doesn’t/can’t communicate over these interfaces.
Figure 1: Hypervisor communications
Separating Primary Storage traffic For those from a pure virtualisation background, the concept of creating a specific interface for storage traffic will not be new; it has long been best practice for iSCSI traffic to have a dedicated switch fabric to avoid any latency or contention issues. Sometimes in the cloud(Stack) world we forget that we are simply orchestrating processes that the hypervisors already carry out and that many ‘normal’ hypervisor configurations still apply. The logical reasoning which explains how this splitting of traffic works is as follows:
Figure 2: Subnetting of Storage Traffic
Figure 3: Hypervisor Communications with Separated Storage Traffic
Other Primary Storage Types If you are using PreSetup or SharedMountPoints to connect to IP based storage then the same principles apply; if the primary storage and ‘primary storage interface’ are in a different subnet to the ‘management subnet’ then the hypervisor will use the ‘primary storage interface’ to communicate with the primary storage.
在本节中我们将通过几个实例说明,如何设置存储并使NFS和iSCSI存储系统正常工作。
本节描述如何在一个标准的Linux系统中配置NFS输出。具体的命令取决于操作系统版本。
在存储服务器上安装RHEL/CentOS 发行版
如果根卷的大小超过2TB,创建一个小点的启动卷用于安装RHEL/CentOS,根分区保留20GB就足够了。
系统安装好以后,创建一个名为 /export的目录。可以在根分区下创建,或者挂载一个较大的磁盘卷。
如果你在一台主机上有超过16TB的存储空间, 则创建多个EXT3文件系统和多个NFS输出,单个EXT3文件系统不能超过16TB。
/export目录创建后,运行如下命令配置NFS输出。
# echo "/export <CIDR>(rw,async,no_root_squash,no_subtree_check)" >> /etc/exports
根据你的部署需求,调整如上参数。
下面是一个分隔的CIDRs的示例:
/export 192.168.1.0/24(rw,async,no_root_squash,no_subtree_check) 10.50.1.0/24(rw,async,no_root_squash,no_subtree_check)
运行下面的命令启动NFS服务。
# chkconfig nfs on
编辑/etc/sysconfig/nfs,并取消如下行的注释。
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020
编辑/etc/sysconfig/iptables,添加如下行的记录到INPUT链的开始部分。
-A INPUT -m state --state NEW -p udp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 2049 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 32803 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 32769 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -p tcp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -p udp --dport 662 -j ACCEPT
重启服务
NFS共享目录/export已经被创建
注解
当复制和粘贴命令时,请确保没有多余的换行符,因为一些文档查看器可能会在复制时加上换行符。
使用以下步骤创建基于iSCSI卷的NFS服务。这些步骤适用于RHEL/CentOS 5发行版。
安装iscsiadm。
# yum install iscsi-initiator-utils
# service iscsi start
# chkconfig --add iscsi
# chkconfig iscsi on
发现ISCSI target。
# iscsiadm -m discovery -t st -p <iSCSI Server IP address>:3260
例如:
# iscsiadm -m discovery -t st -p 172.23.10.240:3260 172.23.10.240:3260,1 iqn.2001-05.com.equallogic:0-8a0906-83bcb3401-16e0002fd0a46f3d-rhel5-test
登录
# iscsiadm -m node -T <Complete Target Name> -l -p <Group IP>:3260
例如:
# iscsiadm -m node -l -T iqn.2001-05.com.equallogic:83bcb3401-16e0002fd0a46f3d-rhel5-test -p 172.23.10.240:3260
发现SCSI磁盘,例如:
# iscsiadm -m session -P3 | grep Attached
Attached scsi disk sdb State: running
格式化磁盘为ext3类型并挂载卷。
# mkfs.ext3 /dev/sdb
# mkdir -p /export
# mount /dev/sdb /export
添加磁盘到/etc/fstab并确保在启动时能被挂载。
/dev/sdb /export ext3 _netdev 0 0
现在你可以建立/export共享目录
限制NFS输出. 强烈建议通过特定的子网和掩码限制NFS访问权限(例如”192.168.1.0/24”), 只允许规定的集群才能访问, 避免非集群成员访问并非故意的情况下删除所有数据。 且管理网络和存储网络必须能够访问;如果2个网络相同,那么一个CIDR就足够了。 如果你是单独的存储网络那么必须提供独立的CIDR或者一个足够大的CIDR可以包含它们2个。
下面是一个分隔的CIDRs的示例:
/export 192.168.1.0/24(rw,async,no_root_squash,no_subtree_check) 10.50.1.0/24(rw,async,no_root_squash,no_subtree_check)
移除async异步标记. 标志允许NFS服务器在提交并写入磁盘操作前就先返回相应,来提高性能。请在关键生产部署中移除异步标志。
除了基本的部署选项之外,接下来的几节将描述CloudStack的特性。
管理服务器配置完毕后,你可以选择安装Usage服务器。Usage服务器从系统事件中提取数据,便于对账户进行使用计费。
当存在多台管理服务器时,可以选择在它们上面安装任意数量的Usage服务器。Usage服务器会协调处理。考虑到高可用性,所以最少在两台管理服务器中安装Usage服务器。
Package repository should already being configured. Refer to Configure Package Repository
Install package cloudstack-usage
On RHEL/CentOS systems, use:
# yum install cloudstack-usage
如果是Debian/Ubuntu系统,命令为:
# apt-get install cloudstack-usage
安装成功后,使用如下命令启动Usage服务器。
# service cloudstack-usage start
Enable the service at boot
On RHEL/CentOS systems, use:
# chkconfig cloudstack-usage on
如果是Debian/Ubuntu系统,命令为:
# update-rc.d cloudstack-usage defaults
The Administration Guide discusses further configuration of the Usage Server.
CloudStack默认提供HTTP的访问方式。有许多的技术和网站选择使用SSL。因此,我们先抛下CloudStack所使用的HTTP,假设站点使用SSL是一个典型实践。
CloudStack使用Tomcat作为服务容器。由于CloudStack网站中断SSL会话,可能会开启Tomcatde的SSL访问。Tomcat的SSL配置描述请查阅: http://tomcat.apache.org/tomcat-6.0-doc/ssl-howto.html.
CloudStack支持MySQL节点间的数据库复制。这个通过标准的MySQL复制功能来实现。你这样做可能希望防止MySQL服务器或者存储损坏。MySQL复制使用master/slave的模型。master节点是直接为管理服务器所使用。slave节点为备用,接收来自master节点的所有写操作,并将它应用于本地冗余数据库。以下是实施数据库复制的步骤。
注解
创建复制并不等同于备份策略,你需要另外开发一个有别于复制的MySQL数据的备份机制。
确保这是一个全新安装且没有数据的master数据库节点。
编辑master数据库的my.cnf,在[mysqld]的datadir下增加如下部分。
log_bin=mysql-bin
server_id=1
考虑到其他的服务器,服务器id必须是唯一的。推荐的方式是将master的ID设置为1,后续的每个slave节点序号大于1,使得所有服务器编号如:1,2,3等。
重启MySQL服务。如果是RHEL/CentOS系统,命令为:
# service mysqld restart
如果是Debian/Ubuntu系统,命令为:
# service mysql restart
在master上创建一个用于复制的账户,并赋予权限。我们创建用户”cloud-repl”,密码为”password”。假设master和slave都运行在172.16.1.0/24网段。
# mysql -u root
mysql> create user 'cloud-repl'@'172.16.1.%' identified by 'password';
mysql> grant replication slave on *.* TO 'cloud-repl'@'172.16.1.%';
mysql> flush privileges;
mysql> flush tables with read lock;
离开当前正在运行的MySQL会话。
在新的shell中打开第二个MySQL会话。
检索当前数据库的位置点。
# mysql -u root
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 412 | | |
+------------------+----------+--------------+------------------+
注意你数据库实例所返回的文件及位置点。
退出该会话。
完成master安装。返回到master的第一个会话,取消锁定并退出MySQL。
mysql> unlock tables;
安装并配置slave节点。在slave服务器上,运行如下命令。
# yum install mysql-server
# chkconfig mysqld on
编辑my.cnf,在[mysqld]的datadir下增加如下部分。
server_id=2
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
重启MySQL。对于RHEL/CentOS系统,使用”mysqld”
# service mysqld restart
对于Ubuntu/Debian系统,使用”mysql.”
# service mysql restart
引导slave连接master并进行复制。使用上面步骤中得到数据来替换IP地址,密码,日志文件,以及位置点。
mysql> change master to
-> master_host='172.16.1.217',
-> master_user='cloud-repl',
-> master_password='password',
-> master_log_file='mysql-bin.000001',
-> master_log_pos=412;
在slave上启动复制功能。
mysql> start slave;
在slave上可能需要开启3306端口,就像之前在master上所做的一样。
这对复制来说不是必须的。但如果没有做,当需要进行数据库切换时,你仍然需要去做。
这将为管理服务器提供一个复制的数据库,用于实现手动故障切换。管理员将CloudStack从一个故障MySQL实例切换到另一个。当数据库失效发生时,你应该:
停止管理服务器(通过命令:service cloudstack-management stop)
将数据库的复本服务器修改为master并重启
确保数据库的副本服务器的3306端口开放给管理服务器。
更改使得管理服务器使用这个新的数据库。最简单的操作是在管理服务器的/etc/cloudstack/management/db.properties文件中写入新的数据库IP地址。
重启管理服务器:
# service cloudstack-management start
CloudStack可将AWS API调用转换为CloudStack本地调用,使得用户可以继续使用已有的AWS兼容工具。这个转换服务作为单独的web应用,就像在tomcat上的CloudStack管理服务一样,只是监听不同的端口。AWS兼容接口除了提供S3 REST API外,还提供EC2 SOAP和Query APIs。
注解
这项服务,之前是由CloudBridge独立软件实现的。现在已经完全集成到CloudStack管理服务中。
警告
The compatible interface for the EC2 Query API and the S3 API are Work In Progress. The S3 compatible API offers a way to store data on the management server file system, it is not an implementation of the S3 backend.
局限性
注解
支持更新版本的EC2 API的工作正在进行
提供AWS API兼容性的软件随CloudStack一起安装。在使用之前,你必须使能服务并操作一些安装步骤。
将全局配置参数中的每项服务设置为true。详看 *Setting Global Configuration Parameters*.
创建一组匹配亚马逊服务方案的名称。这个可以按照管理员操作手册在CloudStack界面上进行操作。
警告
除了可能使用的EC2实例类型,确保已包含亚马逊默认服务方案,m1.small。
如果按照步骤1设置了配置参数后,没有重启,那么重启管理服务器。
# service cloudstack-management restart
以下内容提供了这些步骤的细节
为了使能EC2和S3兼容服务,你需要将 enable.ec2.api *和 *enable.s3.api 的值设置为true。以使能你所需要的服务。这个可以在CloudStack的界面上的*Global Settings*或者API来实现。
下面的截图展示如何通过GUI使能这些服务。
使用CloudStack API最简单的方法是使用集成接口,这个接口可以使用无验证调用。在全局设置中将这个接口设置为8096,然后调用 updateConfiguration 。下面的URL展示如何使用。
http://localhost:8096/client/api?command=updateConfiguration&name=enable.ec2.api&value=true
http://localhost:8096/client/api?command=updateConfiguration&name=enable.ec2.api&value=true
一旦使能这些服务,重启服务器。
可以定义兼容 Amazon EC2实例类型 <http://aws.amazon.com/ec2/instance-types/> API名称的计算服务方案。(例如m1.small,m1.large),这个可以通过CloudStack界面进行操作。在 Service Offerings 中选择 Compute offering ,创建一个新的计算方案或者修改已存在的皆可。确保名称与EC2实例类型API名称匹配。下面的截图将展示如何操作。
总的来说,用户不需要察觉CloudStack所提供的翻译服务。只需将AWS API调用发送到CloudStack端,然后被转换为CloudStack API。Amazon EC2兼容接口用户可继续使用已有的EC2工具和脚本,并通过指定管理服务器的端及合适的用户证书,将它们用于CloudStack部署。为此,用户需要进行如下步骤的操作:
为了使用EC2命令行工具,用户需要操作以下步骤:
$ export EC2_CERT=/path/to/cert.pem
$ export EC2_PRIVATE_KEY=/path/to/private_key.pem
$ export EC2_URL=http://localhost:7080/awsapi
$ export EC2_HOME=/path/to/EC2_tools_directory
Amazon EC2命令行工具有默认的连接超时。在CloudStack中使用时,某些命令可能需要更长的超时。如果你发现命令在超时的时间内未完成,你可以指定用户定制超时。你可以将下面的可选命令行参数添加到任何支持CloudStack的EC2命令。
指定连接超时(秒)
--connection-timeout TIMEOUT
指定请求超时(秒)
--request-timeout TIMEOUT
例如:
ec2-run-instances 2 –z us-test1 –n 1-3 --connection-timeout 120 --request-timeout 120
注解
CloudStack中的超时可选参数并非特定
AWS API接口被使能后,CloudStack可支持下面的Amazon EC2命令。对于少数命令,CloudStack与Amazon EC2版本间有一些差异,差异已被标识。对于使用SOAP调用建立工具的用户,与之相关的命令也已给出。
表 1.弹性IP API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-allocate-address | AllocateAddress | associateIpAddress |
ec2-associate-address | AssociateAddress | enableStaticNat |
ec2-describe-addresses | DescribeAddresses | listPublicIpAddresses |
ec2-diassociate-address | DisassociateAddress | disableStaticNat |
ec2-release-address | ReleaseAddress | disassociateIpAddress |
表 2.可用Zone API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-describe-availability-zones | DescribeAvailabilityZones | listZones |
表 3.镜像API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-create-image | CreateImage | createTemplate |
ec2-deregister | DeregisterImage | DeleteTemplate |
ec2-describe-images | DescribeImages | listTemplates |
ec2-register | RegisterImage | registerTemplate |
表 4.镜像属性API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-describe-image-attribute | DescribeImageAttribute | listTemplatePermissions |
ec2-modify-image-attribute | ModifyImageAttribute | updateTemplatePermissions |
ec2-reset-image-attribute | ResetImageAttribute | updateTemplatePermissions |
表 5.实例API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-describe-instances | DescribeInstances | listVirtualMachines |
ec2-run-instances | RunInstances | deployVirtualMachine |
ec2-reboot-instances | RebootInstances | rebootVirtualMachine |
ec2-start-instances | StartInstances | startVirtualMachine |
ec2-stop-instances | StopInstances | stopVirtualMachine |
ec2-terminate-instances | TerminateInstances | destroyVirtualMachine |
表 6 实例属性对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-describe-instance-attribute | DescribeInstanceAttribute | listVirtualMachines |
表 7 密钥对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-add-keypair | CreateKeyPair | createSSHKeyPair |
ec2-delete-keypair | DeleteKeyPair | deleteSSHKeyPair |
ec2-describe-keypairs | DescribeKeyPairs | listSSHKeyPairs |
ec2-import-keypair | ImportKeyPair | registerSSHKeyPair |
表 8.密码API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-get-password | GetPasswordData | getVMPassword |
表 9.安全组API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-authorize | AuthorizeSecurityGroupIngress | authorizeSecurityGroupIngress |
ec2-add-group | CreateSecurityGroup | createSecurityGroup |
ec2-delete-group | DeleteSecurityGroup | deleteSecurityGroup |
ec2-describe-group | DescribeSecurityGroups | listSecurityGroups |
ec2-revoke | RevokeSecurityGroupIngress | revokeSecurityGroupIngress |
表 10.快照API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-create-snapshot | CreateSnapshot | createSnapshot |
ec2-delete-snapshot | DeleteSnapshot | deleteSnapshot |
ec2-describe-snapshots | DescribeSnapshots | listSnapshots |
表 11.卷API对应表
EC2命令 | SOAP调用 | CloudStack API调用 |
---|---|---|
ec2-attach-volume | AttachVolume | attachVolume |
ec2-create-volume | CreateVolume | createVolume |
ec2-delete-volume | DeleteVolume | deleteVolume |
ec2-describe-volume | DescribeVolume | listVolumes |
ec2-detach-volume | DetachVolume | detachVolume |
有很多工具可以提供接入AWS兼容API。本节中将提供CloudStack用户一些使用用例。
Boto是其中一个。Python包可以在 https://github.com/boto/boto 获取。本节中提供两个使用Boto并已被CloudStack AWS API接口测试过的Python脚本示例。
第一个是EC2示例,将访问和加密密钥改成你自己的,并更新端。
示例1.EC2 Boto示例
#!/usr/bin/env python
import sys
import os
import boto
import boto.ec2
region = boto.ec2.regioninfo.RegionInfo(name="ROOT",endpoint="localhost")
apikey='GwNnpUPrO6KgIdZu01z_ZhhZnKjtSdRwuYd4DvpzvFpyxGMvrzno2q05MB0ViBoFYtdqKd'
secretkey='t4eXLEYWw7chBhDlaKf38adCMSHx_wlds6JfSx3z9fSpSOm0AbP9Moj0oGIzy2LSC8iw'
def main():
'''Establish connection to EC2 cloud'''
conn = boto.connect_ec2(aws_access_key_id=apikey,
aws_secret_access_key=secretkey,
is_secure=False,
region=region,
port=7080,
path="/awsapi",
api_version="2010-11-15")
'''Get list of images that I own'''
images = conn.get_all_images()
print images
myimage = images[0]
'''Pick an instance type'''
vm_type='m1.small'
reservation = myimage.run(instance_type=vm_type,security_groups=['default'])
if __name__ == '__main__':
main()
第二个是S3示例。S3接口在CloudStack中已被废弃。如果要使用,需要考察下RiakCS,Ceph或者GlusterFS系统。这个示例已完成并可用于其他S3端。
示例2.S3 Boto示例
#!/usr/bin/env python
import sys
import os
from boto.s3.key import Key
from boto.s3.connection import S3Connection
from boto.s3.connection import OrdinaryCallingFormat
apikey='ChOw-pwdcCFy6fpeyv6kUaR0NnhzmG3tE7HLN2z3OB_s-ogF5HjZtN4rnzKnq2UjtnHeg_yLA5gOw'
secretkey='IMY8R7CJQiSGFk4cHwfXXN3DUFXz07cCiU80eM3MCmfLs7kusgyOfm0g9qzXRXhoAPCH-IRxXc3w'
cf=OrdinaryCallingFormat()
def main():
'''Establish connection to S3 service'''
conn = S3Connection(aws_access_key_id=apikey,aws_secret_access_key=secretkey, \
is_secure=False, \
host='localhost', \
port=7080, \
calling_format=cf, \
path="/awsapi/rest/AmazonS3")
try:
bucket=conn.create_bucket('cloudstack')
k = Key(bucket)
k.key = 'test'
try:
k.set_contents_from_filename('/Users/runseb/Desktop/s3cs.py')
except:
print 'could not write file'
pass
except:
bucket = conn.get_bucket('cloudstack')
k = Key(bucket)
k.key = 'test'
try:
k.get_contents_to_filename('/Users/runseb/Desktop/foobar')
except:
print 'Could not get file'
pass
try:
bucket1=conn.create_bucket('teststring')
k=Key(bucket1)
k.key('foobar')
k.set_contents_from_string('This is my silly test')
except:
bucket1=conn.get_bucket('teststring')
k = Key(bucket1)
k.key='foobar'
k.get_contents_as_string()
if __name__ == '__main__':
main()
CloudStack stores several sensitive passwords and secret keys that are used to provide security. These values are always automatically encrypted:
CloudStack uses the Java Simplified Encryption (JASYPT) library. The data values are encrypted and decrypted using a database secret key, which is stored in one of CloudStack’s internal properties files along with the database password. The other encrypted values listed above, such as SSH keys, are in the CloudStack internal database.
Of course, the database secret key itself can not be stored in the open – it must be encrypted. How then does CloudStack read it? A second secret key must be provided from an external source during Management Server startup. This key can be provided in one of two ways: loaded from a file or provided by the CloudStack administrator. The CloudStack database has a configuration setting that lets it know which of these methods will be used. If the encryption type is set to “file,” the key must be in a file in a known location. If the encryption type is set to “web,” the administrator runs the utility com.cloud.utils.crypt.EncryptionSecretKeySender, which relays the key to the Management Server over a known port.
The encryption type, database secret key, and Management Server secret key are set during CloudStack installation. They are all parameters to the CloudStack database setup script (cloudstack-setup-databases). The default values are file, password, and password. It is, of course, highly recommended that you change these to more secure keys.
Passwords are encoded when creating or updating users. CloudStack allows you to determine the default encoding and authentication mechanism for admin and user logins. Two new configurable lists have been introduced—userPasswordEncoders and userAuthenticators. userPasswordEncoders allows you to configure the order of preference for encoding passwords, whereas userAuthenticators allows you to configure the order in which authentication schemes are invoked to validate user passwords.
Additionally, the plain text user authenticator has been modified not to convert supplied passwords to their md5 sums before checking them with the database entries. It performs a simple string comparison between retrieved and supplied login passwords instead of comparing the retrieved md5 hash of the stored password against the supplied md5 hash of the password because clients no longer hash the password. The following method determines what encoding scheme is used to encode the password supplied during user creation or modification.
When a new user is created, the user password is encoded by using the
first valid encoder loaded as per the sequence specified in the
UserPasswordEncoders
property in the ComponentContext.xml
or
nonossComponentContext.xml
files. The order of authentication
schemes is determined by the UserAuthenticators
property in the same
files. If Non-OSS components, such as VMware environments, are to be
deployed, modify the UserPasswordEncoders
and UserAuthenticators
lists in the nonossComponentContext.xml
file, for OSS environments,
such as XenServer or KVM, modify the ComponentContext.xml
file. It
is recommended to make uniform changes across both the files. When a new
authenticator or encoder is added, you can add them to this list. While
doing so, ensure that the new authenticator or encoder is specified as a
bean in both these files. The administrator can change the ordering of
both these properties as preferred to change the order of schemes.
Modify the following list properties available in
client/tomcatconf/nonossComponentContext.xml.in
or
client/tomcatconf/componentContext.xml.in
as applicable, to the
desired order:
<property name="UserAuthenticators">
<list>
<ref bean="SHA256SaltedUserAuthenticator"/>
<ref bean="MD5UserAuthenticator"/>
<ref bean="LDAPUserAuthenticator"/>
<ref bean="PlainTextUserAuthenticator"/>
</list>
</property>
<property name="UserPasswordEncoders">
<list>
<ref bean="SHA256SaltedUserAuthenticator"/>
<ref bean="MD5UserAuthenticator"/>
<ref bean="LDAPUserAuthenticator"/>
<ref bean="PlainTextUserAuthenticator"/>
</list>
</property>
In the above default ordering, SHA256Salt is used first for
UserPasswordEncoders
. If the module is found and encoding returns a
valid value, the encoded password is stored in the user table’s password
column. If it fails for any reason, the MD5UserAuthenticator will be
tried next, and the order continues. For UserAuthenticators
,
SHA256Salt authentication is tried first. If it succeeds, the user is
logged into the Management server. If it fails, md5 is tried next, and
attempts continues until any of them succeeds and the user logs in . If
none of them works, the user is returned an invalid credential message.