电话

0431-85663671

0431-85636186

联系我们

关注我们

18043161979
首页

就业新闻

新科展企业级CENTOS集群脚本出炉
发布时间:2017-02-19 07:48:37| 浏览次数:

新科展版权所有 盗用必究!

#!/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

 
 
打印本页 || 关闭窗口
 上一篇:新科展教你Excel中输入数字自动转换为中文大写数字
 下一篇:新科展2017年初室内设计实战排尺成功进行