本文介绍CentOS 6.3操作系统主机安装 CloudStack 4.1.1 AllInOne的运行环境。
前置条件
Management Server, Database, and Storage System Requirements
Operating system: Preferred: CentOS/RHEL 6.3+ or Ubuntu12.04(.1)
64-bit x86 CPU (more cores results in better performance)
4 GB of memory
250 GB of local disk (more results in better capability; 500 GBrecommended)
At least 1 NIC
Statically allocated IP address
Fully qualified domain name as returned by the hostnamecommand
Host/Hypervisor System Requirements
Must support HVM (Intel-VT or AMD-V enabled).
64-bit x86 CPU (more cores results in better performance)
Hardware virtualization support required
4 GB of memory
36 GB of local disk
At least 1 NIC
When you deploy CloudStack, the hypervisor hostmust not have any VMs already running
All hosts within a cluster must be homogeneous. The CPUs must be ofthe same type, count, and feature flags.
KVM 主机需求http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.1.1/html/Installation_Guide/hypervisor-kvm-install-flow.html#hypervisor-kvm-requirements
XenServer 主机需求http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.1.1/html/Installation_Guide/citrix-xenserver-installation.html#system-requirements-xenserver-hosts
vSphere 主机需求http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.1.1/html/Installation_Guide/vmware-install.html#vmware-requirements
禁用IPv6
# service ip6tables stop
# chkconfig ip6tables off
(一)安装配置管理服务器
设置静态网络IP地址
#vim
/etc/sysconfig/network-scripts/ifcfg-eth0
除物理MAC,静态IP地址、网关、掩码以外,参考如下设置
DEVICE=eth0
HWADDR=00:1F:16:34:xx:yy
ONBOOT=yes
HOTPLUG=no
BOOTPROTO=static
IPV6INIT=no
NM_CONTROLLED=no #这里不需要NetworkManager托管网络配置,将NetworkManager断开Wired Networks和Wireless Networks
TYPE=Ethernet
IPADDR=192.168.0.103
NETMASK=255.255.255.0
DNS1=202.96.134.33
DNS2=202.96.128.86
DOMAIN=cloudstack.org
Host名称
# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=mgmt1.cloudstack.org
NETWORKING_IPV6=no
NOZEROCONF=yes
GATEWAY=192.168.0.1
# vim /etc/hosts
127.0.0.1 localhost
192.168.0.103 mgmt1.cloudstack.org
DNS(广东电信)
# vim /etc/resolv.conf
nameserver 127.0.0.1
# Generated by NetworkManager
search cloudstack.org
nameserver 202.96.134.33
nameserver 202.96.128.86
重启网络
#
service
networkrestart
开机启用网络
#
chkconfig
networkon
开机启用NetworkManager
# chkconfig --add NetworkManager
# chkconfig NetworkManager on
验证网络
# ping 192.168.0.1
# ping www.baidu.com
# hostname --fqdn
安装并启动NTP服务器
#yum install ntp
# service ntpd start
将其加入boot时启动
# chkconfig ntpd on
安装CloudStack管理节点
#yum install cloudstack-management
安装MySQL数据库
#yum install mysql-server
修改/etc/my.cnf,在 [mysqld] 段 datadir 下增加以下内容:
注意:若单个management节点max_connections配置为350
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'
重启MySQL
#service mysqld restart
建立安全链接,除了"Disallow root login remotely?"选项以外,全部选择“y”
#mysql_secure_installation
放宽SELinux权限
1)检查是否安装了selinux,如果没有,那么跳过后续步骤
#rpm -qa | grep selinux
2)修改/etc/selinux/config,将SELINUX=enforcing修改为SELINUX=permissive
3)及时生效
#setenforce permissive
建立CloudStack的MySQL数据库帐户cloud及口令密码,以及初始化元数据:
#cloudstack-setup-databasescloud:<dbpassword>@localhost \
--deploy-as=root:<password>\
-e <encryption_type> \
-m <management_server_key>\
-k <database_key> \
-i <management_server_ip>
以上命令根据实际情况替换,encryption_type默认值为file,management_server_key默认值为password,database_key默认值为password,详细参考http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.1.1/html/Installation_Guide/management-server-install-flow.html#about-password-encryption,如下参考:
#cloudstack-setup-databases cloud:cloud@mgmt1.cloudstack.org \
--deploy-as=root:root \
-m cloud \
-k cloud \
-i mgmt1.cloudstack.org
若KVM hypervisor在同一台主机运行,那么修改/etc/sudoers增加以下内容:
Defaults:cloud !requiretty
初始化CloudStack管理服务器
#cloudstack-setup-management
注意:只有XenServer需要下载vhd-util
(二)在其他节点独立安装数据库
若不是采取CloudStack的AllInOne方式,则需要在新主机上安装MySQL
修改/etc/my.cnf,在 [mysqld] 段 datadir 下增加以下内容:
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'
bind-address = 0.0.0.0
重启MySQL
#service mysqld restart
将MySQL加入boot时启动
# chkconfig mysqld on
建立安全链接,除了"Disallow root login remotely?"选项以外,全部选择“y”
#mysql_secure_installation
修改防火墙,允许MySQL的3306端口运行
#vim /etc/sysconfig/iptables
在:INPUT ACCEPT [0:0]下面增加以下内容:
-A INPUT -p tcp --dport 3306 -j ACCEPT
重启iptables
#service iptables restart
重新建立CloudStack的MySQL数据库帐户,以及初始化元数据,参考如上所述:
#cloudstack-setup-databasescloud:<dbpassword>@localhost \
--deploy-as=root:<password>\
-e <encryption_type> \
-m <management_server_key>\
-k <database_key> \
-i <management_server_ip>
(三)使用Management Server作为 NFS Server
生产环境建议独立安装网络文件系统,详细参考http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.1.1/html/Installation_Guide/management-server-install-flow.html#nfs-shares-on-separate-server
本文CloudStack的AllInOne方式,网络文件系统安装在同一主机
#yum install nfs-utils
#mkdir -p /export/primary
#mkdir -p /export/secondary
#vi /etc/exports
填写以下内容:
/export *(rw,async,insecure,no_root_squash)
NFS Server导出export目录
#exportfs -arv
#vi /etc/sysconfig/nfs
取消以下行的注释
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020
修改iptables
#vi /etc/sysconfig/iptables
在:INPUT ACCEPT[0:0]之前加入以下行:(这里<NETWORK>替换当前主机IP或域名)
-A INPUT -s <NETWORK> -m state--state NEW -p udp --dport 111 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p tcp --dport 111 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p tcp --dport 2049 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p tcp --dport 32803 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p udp --dport 32769 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p tcp --dport 892 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p udp --dport 892 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p tcp --dport 875 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p udp --dport 875 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p tcp --dport 662 -j ACCEPT
-A INPUT -s <NETWORK> -m state--state NEW -p udp --dport 662 -j ACCEPT
# cat /etc/sysconfig/iptables
如果IP不对,可通过命令进行修改:sed -i's/127.0.0.1/mgmt1.cloudstack.org/g'
/etc/sysconfig/iptables
重启iptables
#service iptables restart
#service iptables save
修改hypervisor主机 和 Management服务器idmapd
#vi /etc/idmapd.conf
取消Domain注释,并写入域名
Domain = cloudstack.org
重启Management服务器
登录hypervisor主机,验证上述配置,并将其加入boot时启动
# service rpcbind start
# service nfs start
# chkconfig nfs on
# chkconfig rpcbind on
# reboot
登录hypervisor主机,在Management服务器上
测试挂载/export目录
# mkdir /primarymount
# mount -t nfs mgmt1.cloudstack.org:/export/primary/primarymount
# umount /primarymount
# mkdir /secondarymount
# mount -t nfs mgmt1.cloudstack.org:/export/secondary/secondarymount
# umount /secondarymount
检查是否挂载发生错误
# tail -f /var/log/messages
验证NFS挂载情况
# reboot
# showmount -e mgmt1.cloudstack.org
Export list for mgmt1.cloudstack.org:
/export *
# mount | grep primary
# mount -l
... ...
mgmt1.cloudstack.org:/export/primary on /mnt/b050decd-2d7f-3428-9dcf-81bd4b2fdeda type nfs (rw,noac,vers=4,addr=192.168.0.103,clientaddr=192.168.0.103)
(当Zone配置完毕,Secondary storage vm s-1-VM 和Console proxy v-2-VM才会挂载到NFS存储)
(四)安装额外的其他管理节点服务器(可选)
开机启动服务
# service rpcbind start
# service nfs start
# chkconfig nfs on
# chkconfig rpcbind on
重新建立CloudStack的MySQL数据库帐户,以及初始化元数据,参考如上所述:
#cloudstack-setup-databasescloud:<dbpassword>@localhost \
--deploy-as=root:<password>\
-e <encryption_type> \
-m <management_server_key>\
-k <database_key> \
-i <management_server_ip>
初始化配置
# cloudstack-setup-management
若有多台额外的管理服务器,重复执行上述步骤
管理节点服务器间集群负载均衡配置参考以下链接:
http://cloudstack.apache.org/docs/en-US/Apache_CloudStack/4.1.1/html/Installation_Guide/management-server-install-flow.html
(五)准备System VM Template
注意:若前述步骤CloudStack database 加密方式encryption type 选择的是 "web",那么必须使用-s 参数:
For XenServer:
#/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt-m /mnt/secondary -uhttp://download.cloud.com/templates/acton/acton-systemvm-02062012.vhd.bz2-h xenserver -s -F
ForvSphere:
#/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt-m /mnt/secondary -uhttp://download.cloud.com/templates/burbank/burbank-systemvm-08012012.ova-h vmware -s -F
ForKVM:
#/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt-m /mnt/secondary -uhttp://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2-h kvm -s -F
本机KVM执行命令参考如下:
#/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt-m /secondarymount -uhttp://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2-h kvm -F -o mgmt1.cloudstack.org -r cloud -d cloud
当然也可以下载到本机进行安装,命令由-u改为-f参数指定文件路径
(六)登录CloudStack
检测CloudStack运行状态
#service cloudstack-management status
或者观察启动日志
#tail -100f /var/log/cloudstack/management/catalina.out
成功启动后登录 http://mgmt1.cloudstack.org:8080/client 默认用户名及密码admin/password
(七)卸载CloudStack及MySQL数据库
#yum remove cloudstack-management
#yum remove mysql-server