cloudstack pike 一键安装脚本 单机

本文参考来源:https://www.jianshu.com/p/ffd363f557cb
一、环境 centos 7.4.1708 x86_64
~]# vim install_cloudstack.sh (复制以下步骤到install_cloudstack.sh文件中,保存)

#!/bin/sh
#1、设置
echo ‘调整selinux、关闭防火墙’
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state
sed -i '/^SELINUX=.
/c SELINUX=disable’ /etc/selinux/config
grep --color=auto ‘^SELINUX’ /etc/selinux/config
setenforce 0
echo ‘设置hostname,上面已设置,这里怕忘记设置,在搞一遍’
hostnamectl set-hostname N o d e e c h o " Node echo " Nodeecho"MyIP $Node">>/etc/hosts
yum install -y wget
#使用阿里源
mkdir -p /etc/yum.repos.d/remark && mv /etc/yum.repos.d/* /etc/yum.repos.d/remark/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i ‘/aliyuncs.com/d’ /etc/yum.repos.d/*.repo
##设置yum源
touch /etc/yum.repos.d/{cloudstack.repo,mysql.repo}
echo "#cloudstack-yum源 repo
[cloudstack]
name=cloudstack
baseurl=http://download.cloudstack.org/centos/7/4.11/
enabled=1
gpgcheck=0
">/etc/yum.repos.d/cloudstack.repo
echo "#mysql-yum源 repo
[mysql-connectors-community]
name=MySQL Community connectors
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/$releasever/$basearch/
enabled=1
gpgcheck=1
">/etc/yum.repos.d/mysql.repo
yum clean all && yum makecache #清理缓存

echo ‘时间同步’
[[ -f /usr/sbin/ntpdate ]] || { echo “install ntp”;yum install ntp ntpdate -y &> /dev/null; } #若没NTP则安装
/usr/sbin/ntpdate ntp6.aliyun.com
echo “*/3 * * * * /usr/sbin/ntpdate ntp6.aliyun.com &> /dev/null” > /tmp/crontab
crontab /tmp/crontab
##########################################
#2 安装
yum -y upgrade &> /dev/null
yum install -y ntp wget vim net-tools openssh tree &> /dev/null
echo ‘CloudStack tools 安装’
yum -y install nfs-utils &> /dev/null
echo ‘mysql安装’
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-release-el7-5.noarch.rpm
yum -y update
yum -y install mysql-server
echo ‘安装nfs’
##########################################
#3、nfs配置
mkdir -p /var/export/{primary,secondary}
echo “/var/export/secondary *(rw,async,no_root_squash,no_subtree_check)
/var/export/primary *(rw,async,no_root_squash,no_subtree_check)” >> /etc/exports
#域是kvm.io
sed -i '/^#Domain = */c Domain = kvm.io ’ /etc/idmapd.conf
#添加配置值
echo “LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892
RQUOTAD_PORT=875
STATD_PORT=662
STATD_OUTGOING_PORT=2020” >> /etc/sysconfig/nfs
#启动nfs
systemctl enable rpcbind && systemctl start rpcbind
systemctl enable nfs && systemctl start nfs

#------------------#####################

echo ‘SQL数据库配置’
touch /etc/my.cnf.d/cloudstack.cnf
echo "[mysqld]
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = ‘ROW’
">/etc/my.cnf.d/cloudstack.cnf
echo ‘启动数据库服务’
systemctl enable mysqld && systemctl start mysqld
sleep 5
netstat -antp|grep mysqld
##############从MySQL导入GPG公钥:
rpm --import http://repo.mysql.com/RPM-GPG-KEY-mysql
#安装mysql-connector
yum -y install mysql-connector-python
#安装服务器管理器
yum -y install cloudstack-management
#设置数据库
cloudstack-setup-databases cloud:password@localhost --deploy-as=root
#下载vm模板
/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt -m /var/export/secondary -u http://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.2-kvm.qcow2.bz2 -h kvm -F
#安装管理代理
yum -y install cloudstack-agent
#QEMU VNC配置
sed -i '/^#vnc_listen=/c vnc_listen=“0.0.0.0”’ /etc/libvirt/qemu.conf
#Libvirt配置
echo “listen_tls = 0
listen_tcp = 1
tcp_port = “16509”
auth_tcp = “none”
mdns_adv = 0
" >> /etc/libvirt/libvirtd.conf
sed -i '/^#LIBVIRTD_ARGS=”–listen"/c LIBVIRTD_ARGS="–listen"’ /etc/sysconfig/libvirtd
#重新启动libvirtd
systemctl enable libvirtd && systemctl start libvirtd
systemctl enable cloudstack-management && systemctl start cloudstack-management
#查看是否启用kvm模块
lsmod | grep kvm #查看是否启用kvm模块
##########################################
##########################################
#end

二、执行脚本
~]# . install_cloudstack.sh

三、安装完毕!
登录Web管理 http://’$MyIP’:8080/client

后添加了一个小硬盘作为辅助存储,存储镜像文件用,不添加也可以用

~]# echo “/dev/sda1 /var/export/secondary/ ext4 defaults 0 0” >> /etc/fstab

然后添加集群添加主机添加存储…

你可能感兴趣的:(cloudstack)