标签:cloudstack
cloudstack4.5安装
实验环境:
management:CentOS-6.6
cs-manage.qcow2模板虚拟机
ip:192.168.10.230
nfs-server:CentOS-7.1
ip:192.168.10.231
配置nfs、ntp
agent:CentOS-7.1
host232:192.168.10.232
host242:192.168.10.242
host244:192.168.10.244
host245:192.168.10.245
准备工作:
安装好系统,准备好cloudstack安装包;可到cloudstack提供商下载:
http://packages.shapeblue.com/cloudstack/upstream/centos/4.5/
配置好各系统的ip地址,方便远程连接操作
# 安装centos7后创建桥接网络:
nmcli connectionshow nmcli connectiondelete enp2s0 #具体的网卡地址请根据实际情况 nmcli connectionadd type bridge con-name cloudbr0 ifname cloudbr0 nmcli connectionmodify cloudbr0 ipv4.addresses "192.168.10.231/24" nmcli connectionmodify cloudbr0 ipv4.method manual nmcli connectionmodify cloudbr0 ipv4.gateway 192.168.10.253 nmcli connectionmodify cloudbr0 ipv4.dns 192.168.10.1 nmcli connectionadd type bridge-slave con-name eth0 ifname enp2s0 master cloudbr0 systemctl restart network
nfs-server安装:
host231是用做nfs-server、ntp-server和cs-manage的物理机,所以要安装nfs、ntp、和virtual组件:
ps:防火墙配置文件ipt和nfs配置文件exports提前写好上传到指定目录
#!/bin/bash hostnamectl set-hostname host231.cloud.com echo "192.168.10.231 host231.cloud.com" >> /etc/hosts setenforce 0 sed -i ‘/SELINUX=enforcing/c SELINUX=disabled‘ /etc/selinux/config yum install -y ntp #ntpdate 192.168.10.231 systemctl enable ntpd &> /dev/null sed -i.bak ‘17c restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap‘ /etc/ntp.conf sed -i ‘24a server 127.127.1.0‘ /etc/ntp.conf sed -i ‘21,24d‘ /etc/ntp.conf systemctl start ntpd yum groups install -y virtual* sed -i.bak ‘/#vnc_listen = "0.0.0.0"/c vnc_listen = "0.0.0.0"‘ /etc/libvirt/qemu.conf sed -i.bak ‘/#listen_tls = 0/c listen_tls = 0‘ /etc/libvirt/libvirtd.conf sed -i ‘/#listen_tcp = 1/c listen_tcp = 1‘ /etc/libvirt/libvirtd.conf sed -i ‘/#tcp_port = "16509"/c tcp_port = "16509"‘ /etc/libvirt/libvirtd.conf sed -i ‘/#mdns_adv = 1/c mdns_adv = 0‘ /etc/libvirt/libvirtd.conf sed -i ‘/#auth_tcp = "sasl"/c auth_tcp = "none"‘ /etc/libvirt/libvirtd.conf sed -i.bak ‘/#LIBVIRTD_ARGS="--listen"/c LIBVIRTD_ARGS="--listen"‘ /etc/sysconfig/libvirtd systemctl restart libvirtd mkdir /home/primary mkdir /home/secondary cat /data/exports > /etc/exports exportfs -a sed -i.bak ‘/#Domain = local.domain.edu/c Domain = cloud.com‘ /etc/idmapd.conf sed -i.bak ‘/#RQUOTAD_PORT=875/c RQUOTAD_PORT=875‘ /etc/sysconfig/nfs sed -i ‘/#LOCKD_TCPPORT=32803/c LOCKD_TCPPORT=32803‘ /etc/sysconfig/nfs sed -i ‘/#LOCKD_UDPPORT=32769/c LOCKD_UDPPORT=32769‘ /etc/sysconfig/nfs sed -i ‘/#MOUNTD_PORT=892/c MOUNTD_PORT=892‘ /etc/sysconfig/nfs sed -i ‘/#STATD_PORT=662/c STATD_PORT=662‘ /etc/sysconfig/nfs sed -i ‘/#STATD_OUTGOING_PORT=2020/c STATD_OUTGOING_PORT=2020‘ /etc/sysconfig/nfs systemctl restart nfs systemctl enable nfs-server cat /data/ipt > /etc/sysconfig/iptables firewall-cmd --set-default-zone=trusted &> /dev/null systemctl stop firewalld systemctl disable firewalld exit
agent安装:
agent安装比较简单,主要是修改
1、hostname
2、selinux
3、ntp(同步到host231)
4、cloudstack-agent
5、防火墙
ps:安装包也是提前上传到指定目录
#!/bin/bash ip=$(ifconfig cloudbr0 | awk ‘NR==2{print$2}‘) ip_d=$(ifconfig cloudbr0 | awk ‘NR==2{print$2}‘ | awk -F‘.‘ ‘{print$4}‘) hostnamectl set-hostname host"$ip_d".cloud.com hostname=$(hostname) echo "$ip $hostname" >> /etc/hosts setenforce 0 sed -i ‘/SELINUX=enforcing/c SELINUX=disabled‘ /etc/selinux/config yum install -y ntp &> /dev/null ntpdate 192.168.10.231 systemctl enable ntpd &> /dev/null sed -i ‘24a server 192.168.10.231‘ /etc/ntp.conf sed -i ‘21,24d‘ /etc/ntp.conf systemctl start ntpd yum groups install -y virtual* &> /dev/null #上传cloudstack4.5 agent安装包到/data while true do read -p ‘do you upload the coudstack-agent packages to /data (y/n)?‘ ans case $ans in y) break;; n) echo ‘upload the coudstack-agent packages to /data‘;; *) echo ‘only input y or n‘;; esac done yum install -y createrepo &> /dev/null createrepo -pv /data/cloudstack4.5/ &> /dev/null cat >> /etc/yum.repos.d/cloud.repo << EOF [cloudstack] name=cloudstack baseurl=file:///data/cloudstack4.5 enabled=1 gpgcheck=0 EOF yum clean all &> /dev/null yum makecache &> /dev/null yum install -y cloudstack-agent &> /dev/null /sbin/chkconfig cloudstack-agent on systemctl start cloudstack-agent sed -i.bak ‘/#vnc_listen = "0.0.0.0"/c vnc_listen = "0.0.0.0"‘ /etc/libvirt/qemu.conf sed -i.bak ‘/#listen_tls = 0/c listen_tls = 0‘ /etc/libvirt/libvirtd.conf sed -i ‘/#listen_tcp = 1/c listen_tcp = 1‘ /etc/libvirt/libvirtd.conf sed -i ‘/#tcp_port = "16509"/c tcp_port = "16509"‘ /etc/libvirt/libvirtd.conf sed -i ‘/#mdns_adv = 1/c mdns_adv = 0‘ /etc/libvirt/libvirtd.conf sed -i ‘/#auth_tcp = "sasl"/c auth_tcp = "none"‘ /etc/libvirt/libvirtd.conf sed -i.bak ‘/#LIBVIRTD_ARGS="--listen"/c LIBVIRTD_ARGS="--listen"‘ /etc/sysconfig/libvirtd sed -i.bak ‘496d‘ /usr/lib64/python2.7/site-packages/cloudutils/serviceConfig.py sed -i.bak ‘/#Domain = local.domain.edu/c Domain = cloud.com‘ /etc/idmapd.conf systemctl restart libvirtd systemctl restart network cat /data/ipt > /etc/sysconfig/iptables firewall-cmd --set-default-zone=trusted &> /dev/null systemctl stop firewalld systemctl disable firewalld exit
重启后再看看服务状况,agent就安装好了
management安装:
management是安装在host231物理机上的虚拟机,模板是cs-manger-c6.qcow2,在host231上使用命令virt-install安装或者使用virt-manage图形化界面安装
安装好虚拟机后需要修改网络:
cd /etc/sysconfig/network-scripts/ cp ifcfg-eth0 ifcfg-cloudbr0 cat > ifcfg-cloudbr0 <<EOF DEVICE=cloudbr0 TYPE=Bridge ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=none IPADDR=192.168.10.230 PREFIX=24 GATEWAY=192.168.10.253 DNS1=192.168.10.1 DEFROUTE=yes EOF cat > ifcfg-eth0 << EOF DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=none BRIDGE=cloudbr0 DEFROUTE=yes EOF
修改hostname
# vim /etc/sysconfit/network #把对应的hostname修改了
添加host表解析
echo "192.168.10.230 host230.cloud.com">> /etc/hosts
配置selinux
setenforce 0 sed -i ‘/SELINUX=enforcing/c SELINUX=disabled‘/etc/selinux/config
配置ntp
sed -i ‘25a server 192.168.10.231‘/etc/ntp.conf sed -i ‘22,25d‘ /etc/ntp.conf
修改mysql配置文件,添加以下参数;
vim /etc/my.cnf
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
执行安全初始化:
mysql_secure_installation
ps:会提示修改密码和删除一些没有的库,全部yes就行
等mysql启动起来后,执行数据库初始化:
cloudstack-setup-databases cloud:password@localhost --deploy-as=root:password
完成后挂载二级存储到本地
mkdir /secondsry mount 192.168.10.231:/home/secondary/ /secondary/
上传模板:
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /secondary/ -f /home/rpm-for-CentOS6/systemvm64template-4.5-kvm.qcow2.bz2 -h kvm -F/
卸载挂载并启动cloudstack-management
umount /secondary cloudstack-setup-management
ps:模板本来就已经安装好mysql和cloudstack-management
到此cloudstack4.5就安装完毕了
如果没有模板,可以安装一台CentOS-6.6系统的主机作为management:
#!/bin/bash hostname=$(hostname) ip=$(ifconfig cloudbr0 | awk -F‘[: ]+‘ ‘NR==2{print $4}‘) echo "$ip $hostname" >> /etc/hosts hostname --fqdn setenforce 0 sed -i ‘/SELINUX=enforcing/c SELINUX=disabled‘ /etc/selinux/config sed -i ‘25a server 192.168.10.231‘ /etc/ntp.conf sed -i ‘22,25d‘ /etc/ntp.conf chkconfig ntpd on service ntpd start sed -i.bak ‘/#Domain = local.domain.edu/c Domain = cloud.com‘ /etc/idmapd.conf cat /data/ipt > /etc/sysconfig/iptables service iptables save service iptables restart yum install mysql-server -y sed -i.bak ‘6a innodb_rollback_on_timeout=1‘ /etc/my.cnf sed -i ‘7a innodb_lock_wait_timeout=600‘ /etc/my.cnf sed -i ‘8a max_connections=350‘ /etc/my.cnf sed -i ‘9a log-bin=mysql-bin‘ /etc/my.cnf sed -i "10a binlog-format = ‘ROW‘" /etc/my.cnf chkconfig mysqld on service mysqld start mysql_secure_installation sleep 5 yum install -y createrepo createrepo -pv /data/cloudstack4.5/ cat >> /etc/yum.repos.d/cloud.repo << EOF [cloudstack] name=cloudstack baseurl=file:///data/cloudstack4.5 enabled=1 gpgcheck=0 EOF yum clean all && yum makecache yum install -y cloudstack-management cloudstack-setup-databases cloud:password@localhost --deploy-as=root:password mkdir /secondary mount 192.168.10.231:/home/secondary/ /secondary/ /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /secondary/ -f /data/systemvm64template-4.5-kvm.qcow2.bz2 -h kvm -F umount /secondary/ cloudstack-setup-management service iptables stop exit
安装完成后打开http://192.168.10.230:8080/client/,登陆到管理平台
用户名:admin
密码:password
然后就添加一个zone
做实验的时候可能会出现各种问题,那时需要删除zone重置,手动删除需要逐级删除比较麻烦,直接删除数据库比较快:
#!/bin/bash service cloudstack-management stop mysql -uroot -ppassword -e "drop database cloud;" mysql -uroot -ppassword -e "drop database cloud_usage;" mysql -uroot -ppassword -e "drop database cloudbridge;" mysql -uroot -ppassword -e "show databases;" cloudstack-setup-databases cloud:password@localhost --deploy-as=root:password sleep 5 #到nfs存储删除之前的模板 while true do read -p ‘do you remove the secondary storage template in nfs server? (y/n)?‘ ans case $ans in y) break;; n) echo ‘please remove the secondary storage template in nfs server‘;; *) echo ‘only input y or n‘;; esac done mount 192.168.10.231:/home/secondary/ /secondary/ /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /secondary/ -f /home/rpm-for-CentOS6/systemvm64template-4.5-kvm.qcow2.bz2 -h kvm -F umount /secondary/ cloudstack-setup-management service iptables stop exit
本文出自 “ld0381的学习之旅” 博客,请务必保留此出处http://ld0381.blog.51cto.com/3318114/1837165
标签:cloudstack
原文地址:http://ld0381.blog.51cto.com/3318114/1837165