新科展版权所有 盗用必究!
#!/bin/bash
#product xkz computer school
#by 2016
clear
echo
"---------------------------------------------------------------------------------"
echo " Welecome to xkz
cluster setup model
"
echo
"----------------------------------------------------------------------------------"
echo "LDirector setup....."
i="/sbin/ifconfig"
#-----------network setup
read -p "please input your DIPCARD:" dcard
read -p "please input your VIPCARD:" vcard
read -p "please input your DIP:" dip
read -p "please input your VIP:" vip
read -p "please input your DNS:" dns
read -p "please input your GATEWAY:" gateway
read -p "please input NO.1realserverIP:" aip
read -p "please input NO.2realserverIP:" bip
$i $dcard $dip up
$i $vcard $vip up
echo "nameserver $dns">/etc/resolv.conf
route add default gw $gateway
echo "1">/proc/sys/net/ipv4/ip_forward
clear
echo "network OK!"
sleep 2
#------------secrity setup
iptables -F
chkconfig --level 35 iptables off
setenforce 0
echo 'SELINUX=disabled'>/etc/sysconfig/selinux
echo 'SELINUXTYPE=targeted'>>/etc/sysconfig/selinux
echo "secrity OK"
sleep 2
#-------------software setup
yum -y install ipvsadm*
clear
echo "ipvsadm-setup OK"
sleep 2
#-------------ipvsadm setup
read -p "choose your cluster service:" cs
read -p "choose your cluster algorithm:" sf
ipvsadm -A -t $vip:$cs -s $sf
ipvsadm -a -t $vip:$cs -r $aip -m
ipvsadm -a -t $vip:$cs -r $bip -m
clear
echo "cluster LD-setup OK..."
sleep 3
clear
echo "--------------NO.1realserver-setup----------------"
echo "--------------------------------------------------"
echo "--------------------------------------------------"
read -p "please set NO.1realserverIP:192.168.1.213 to return to press any
key to continue..." var
rs1="192.168.1.213"
ssh-keygen -t rsa -P ''
ssh-copy-id -i .ssh/id_rsa.pub root@$rs1
clear
echo "ssh-setup OK"
sleep 2
ssh $rs1 'route add default gw
192.168.1.1'
ssh $rs1 'echo "nameserver 118.118.118.1">/etc/resolv.conf'
ssh $rs1 'yum -y install httpd'
ssh $rs1 'echo "web1">/var/www/html/index.html'
ssh $rs1 'echo
"DEVICE=eth0">/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo "ONBOOT=yes">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo
"BOOTPROTO=static">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo
"IPADDR=172.16.0.2">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo "DNS1=118.118.118.1">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo
"GATEWAY=172.16.0.1">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo "SELINUX=disabled">/etc/sysconfig/selinux'
ssh $rs1 'echo
"SELINUXTYPE=targeted">>/etc/sysconfig/selinux'
ssh $rs1 'chkconfig --level 35 iptables off'
ssh $rs1 'chkconfig --level 35 httpd on'
ssh $rs1 'init 6'
clear
echo "NO.1realserver setup OK"
sleep 3
clear
echo "--------------NO.2realserver-setup----------------"
echo "--------------------------------------------------"
echo "--------------------------------------------------"
read -p "please set NO.1realserverIP:192.168.1.215 to return to press any
key to continue..." var
rs1="192.168.1.215"
ssh-keygen -t rsa -P ''
ssh-copy-id -i .ssh/id_rsa.pub root@$rs1
clear
echo "ssh-setup OK"
sleep 2
ssh $rs1 'route add default gw
192.168.1.1'
ssh $rs1 'echo "nameserver 118.118.118.1">/etc/resolv.conf'
ssh $rs1 'yum -y install httpd'
ssh $rs1 'echo "web2">/var/www/html/index.html'
ssh $rs1 'echo "DEVICE=eth1">/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo
"ONBOOT=yes">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo
"BOOTPROTO=static">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo
"IPADDR=172.16.0.3">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo "DNS1=118.118.118.1">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo
"GATEWAY=172.16.0.1">>/etc/sysconfig/network-scripts/ifcfg-eth0'
ssh $rs1 'echo "SELINUX=disabled">/etc/sysconfig/selinux'
ssh $rs1 'echo "SELINUXTYPE=targeted">>/etc/sysconfig/selinux'
ssh $rs1 'chkconfig --level 35 iptables off'
ssh $rs1 'chkconfig --level 35 httpd on'
ssh $rs1 'init 6'
clear
echo "NO.2realserver setup OK"
clear
echo "---------------------the xkz cluster------------------------
"
echo "----------------------VIP
is:$vip----------------------------"
echo "---------------------SERVICE
is:web--------------------------"
echo "-----------REALSERVER:2(172.16.0.2
172.16.0.3)---------------"
sleep 5
exit 0