centos6.4安装CloudStack 4.2(开源云计算平台)详解
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>CloudStack 的前身是 Cloud.com 家的一款商业云计算产品(也有开源版本),2011年 Cloud.com 被 Citrix 收购,2012年的时候 Citrix 将收购的云平台 CloudStack 全部捐给了 Apache 基金会,自己则以 Citrix CloudPlatform (powered by Apache CloudStack) 的形式为客户提供商业化的云计算解决方案。</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
按照《OpenStack, OpenNebula, Eucalyptus, CloudStack 社区活跃度比较》的统计,貌似 CloudStack 项目的活跃程度仅次于 OpenStack. 和大多数云计算、集群软件一样,CloudStack 也是控制节点+计算节点这种架构,控制节点(cloudstack-management)用来统一管理计算节点,提供资源分配和任务,提供 API、GUI、数据库等服务;计算节点(cloudstack-agent)则用来跑虚拟机。我们需要做的是,</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
在控制节点上安装 cloudstack-management;<br>
在(每个)计算节点上安装 cloudstack-agent 和 kvm.<br>
在控制节点上</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
安装完 CentOS 6.4 系统后,升级系统并修改 hostname 后重启:</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode9" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# yum update <br>
# echo "cloudstack.vpsee.com" > /etc/hostname <br>
# vi /etc/sysconfig/network <br>
NETWORKING=yes <br>
NETWORKING_IPV6=no <br>
HOSTNAME=cloudstack.vpsee.com <br>
# echo "192.168.2.150 cloudstack cloudstack.vpsee.com" >> /etc/hosts <br>
# reboot <br>
添加 cloudstack 软件包的官方源,安装 ntp, cloudstack-management, mysql 数据库服务器:</p> <p># vi /etc/yum.repos.d/cloudstack.repo <br>
<br>
name=cloudstack <br>
baseurl=http://cloudstack.apt-get.eu/rhel/4.2/ <br>
enabled=1 <br>
gpgcheck=0 <br>
# yum update <br>
# yum install ntp <br>
# yum install cloudstack-management <br>
# yum install mysql-server </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
修改 mysql 配置文件,加入下面几行,启动 ntp, mysql 服务并运行 mysql_secure_installation 给 mysql 设置密码:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode10" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# vi /etc/my.cnf <br>
... <br>
<br>
... <br>
innodb_rollback_on_timeout=1 <br>
innodb_lock_wait_timeout=600 <br>
max_connections=350 <br>
log-bin=mysql-bin <br>
binlog-format = 'ROW' <br>
<br>
... <br>
# service ntpd start <br>
# chkconfig ntpd on <br>
# service mysqld start <br>
# chkconfig mysqld on <br>
# mysql_secure_installation </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
修改 SELINUX 设置,并配置防火墙允许访问 mysql 的 3306 端口:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode11" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# vi /etc/selinux/config <br>
... <br>
SELINUX=permissive <br>
... <br>
# setenforce permissive <br>
# vi /etc/sysconfig/iptables <br>
... <br>
-A INPUT -p tcp --dport 3306 -j ACCEPT <br>
... <br>
# service iptables restart <br>
使用 cloudstack-setup-databases 初始化 ClouStack 数据库,完成后运行 cloudstack-setup-management:</p> <p># cloudstack-setup-databases cloud:cloud@localhost --deploy-as=root:root -i 192.168.2.150 <br>
# cloudstack-setup-management <br>
Starting to configure CloudStack Management Server: <br>
Configure sudoers ... <br>
Configure Firewall ... <br>
Configure CloudStack Management Server ... <br>
CloudStack Management Server setup is Done! </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
控制节点应该和存储分开,这里为了方便,我们把 NFS 也装在这个控制节点上,并自己挂载自己的 NFS 分区:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode12" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# yum install nfs-utils <br>
# mkdir -p /export/primary <br>
# mkdir -p /export/secondary <br>
# vi /etc/exports <br>
/export *(rw,async,no_root_squash,no_subtree_check) <br>
# exportfs -a <br>
# vi /etc/sysconfig/nfs <br>
... <br>
LOCKD_TCPPORT=32803 <br>
LOCKD_UDPPORT=32769 <br>
MOUNTD_PORT=892 <br>
RQUOTAD_PORT=875 <br>
STATD_PORT=662 <br>
STATD_OUTGOING_PORT=2020 <br>
... <br>
# service rpcbind start <br>
# service nfs start <br>
# chkconfig nfs on <br>
# chkconfig rpcbind on <br>
# reboot <br>
# mkdir -p /mnt/primary <br>
# mkdir -p /mnt/secondary <br>
# mount -t nfs 192.168.2.150:/export/primary /mnt/primary <br>
# mount -t nfs 192.168.2.150:/export/secondary /mnt/secondary </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
修改防火墙配置,开放下面一些端口:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode13" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# vi /etc/sysconfig/iptables <br>
... <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p udp --dport 111 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p tcp --dport 111 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p tcp --dport 2049 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p tcp --dport 32803 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p udp --dport 32769 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p tcp --dport 892 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p udp --dport 892 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p tcp --dport 875 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p udp --dport 875 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p tcp --dport 662 -j ACCEPT <br>
-A INPUT -s 192.168.2.0/24 -m state --state NEW -p udp --dport 662 -j ACCEPT <br>
... <br>
# service iptables restart <br>
# service iptables save </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
创建虚拟机需要有模版,这个模版可以自己做,也可以下载官方现成的。需要注意的是,官方文档中的 /usr/lib64/cloud/common/… 路径不对,应该是 /usr/share/cloudstack-common/…:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode14" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /mnt/secondary -u <a href="http://d21ifhcun6b1t2.cloudfront.net/templates/4.2/systemvmtemplate-2013-06-12-master-kvm.qcow2.bz2">http://d21ifhcun6b1t2.cloudfront.net/templates/4.2/systemvmtemplate-2013-06-12-master-kvm.qcow2.bz2</a> -h kvm -s -F </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
在计算节点上</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
为了保持一致,我们在计算节点上也采用 CentOS 6.4. 在每个计算节点上都需要如下的安装和配置。升级系统并修改 hostname、重启:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode15" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# yum update <br>
# echo "cloudstack01.vpsee.com" > /etc/hostname <br>
# vi /etc/sysconfig/network <br>
NETWORKING=yes <br>
NETWORKING_IPV6=no <br>
HOSTNAME=cloudstack01.vpsee.com <br>
# echo "192.168.2.151 cloudstack01 cloudstack.vpsee.com" >> /etc/hosts <br>
# reboot <br>
添加 cloudstack 软件包的官方源,安装 ntp, cloudstack-agent 和 kvm:</p> <p># vi /etc/yum.repos.d/cloudstack.repo <br>
<br>
name=cloudstack <br>
baseurl=http://cloudstack.apt-get.eu/rhel/4.2/ <br>
enabled=1 <br>
gpgcheck=0 <br>
# yum update <br>
# yum install ntp <br>
# yum install cloudstack-agent <br>
# yum install qemu-kvm </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
修改 libvirt 相关配置文件,去掉下面几行的注释,注意把 auth_tcp 改成 “none”,如果需要 vnc 访问的话别忘了取消 qemu.conf 里面的 vnc_listen 相关注释,重启 libvirtd 服务使配置生效:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode16" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# vi /etc/libvirt/libvirtd.conf <br>
... <br>
listen_tls = 0 <br>
listen_tcp = 1 <br>
tcp_port = "16509" <br>
auth_tcp = "none" <br>
mdns_adv = 0 <br>
... <br>
# vi /etc/sysconfig/libvirtd <br>
... <br>
LIBVIRTD_ARGS="--listen" <br>
... <br>
# vi /etc/libvirt/qemu.conf <br>
... <br>
vnc_listen = "0.0.0.0" <br>
... <br>
# service libvirtd restart </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
别忘了让防火墙开放必要的端口:<br>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<div class="right">
<span><u>复制代码</u></span>
</div>
<p>
代码如下:</p>
</div>
<div class="msgborder" id="phpcode17" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
# iptables -I INPUT -p tcp -m tcp --dport 22 -j ACCEPT <br>
# iptables -I INPUT -p tcp -m tcp --dport 1798 -j ACCEPT <br>
# iptables -I INPUT -p tcp -m tcp --dport 16509 -j ACCEPT <br>
# iptables -I INPUT -p tcp -m tcp --dport 5900:6100 -j ACCEPT <br>
# iptables -I INPUT -p tcp -m tcp --dport 49152:49216 -j ACCEPT <br>
# iptables-save > /etc/sysconfig/iptables </div>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
测试</p>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
打开浏览器,访问控制节点 http://192.168.2.150:8080/client/ 就会看到登录界面,默认用户名和密码是 admin/password,登录后修改密码、做一些配置后就可以开始用了:</p>
頁:
[1]