centos部署zookeeper+dubbo一键脚本

#!/bin/sh

#Author fanwx

#-*- coding :utf-8 -*-

#系统:centos6.5

#中间件:tomcat8.5.5

#zookeeper版本:3.4.8

#dubbo版本:2.5.3

#安装依赖组件

#关闭selinux

sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config  #重启生效

# setenforce 0  #临时关闭

yum -y install unzip vim wget gcc++ gcc autoconf automake

yum -y install pcre*

yum -y install openssl*

#提前下载 jdk-7u79-linux-x64.tar、apache-tomcat-8.5.5.tar.gz、apache-maven-3.3.9-bin.tar.gz、dubbo-admin-2.5.3.war 并放置在/usr/local目录下

#安装jdk

cd /usr/local

tar -xvf jdk-7u79-linux-x64.tar

rm -rf jdk-7u79-linux-x64.tar

#安装Tomcat

tar zxvf apache-tomcat-8.5.5.tar.gz

rm -rf apache-tomcat-8.5.5.tar.gz

mv apache-tomcat-8.5.5 tomcat

cp -p /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat

chmod 755 /etc/init.d/tomcat

/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

/etc/rc.d/init.d/iptables save

#安装maven

cd /usr/local/

tar -zxvf apache-maven-3.3.9-bin.tar.gz

rm -rf apache-maven-3.3.9-bin.tar.gz

ln -s apache-maven-3.3.9 apache-maven

#设置环境变量

#cd /root

#修改profile文件,vim /etc/profile

echo -e "JAVA_HOME=/usr/local/jdk1.7.0_79/" >> /etc/profile

echo -e "JAVA_BIN=/usr/local/jdk1.7.0_79/bin"  >> /etc/profile

echo -e "JRE_HOME=/usr/local/jdk1.7.0_79/jre" >> /etc/profile

echo -e "PATH=$PATH:/usr/local/jdk1.7.0_79/bin:/usr/local/jdk1.7.0_79/jre/bin" >> /etc/profile

echo -e "CLASSPATH=/usr/local/jdk1.7.0_79/jre/lib:/usr/local/jdk1.7.0_79/lib:/usr/local/jdk1.7.0_79/jre/lib/charsets.jar" >> /etc/profile

echo -e "export  JAVA_HOME  JAVA_BIN JRE_HOME  PATH  CLASSPATH" >> /etc/profile

source /etc/profile

#修改.bash_profile文件,vim .bash_profile

cd /root

sed -i '/export PATH/a\JAVA_HOME=/usr/local/jdk1.7.0_79/\nJAVA_BIN=/usr/local/jdk1.7.0_79/bin\nJRE_HOME=/usr/local/jdk1.7.0_79/jre\nPATH=$PATH:/usr/local/jdk1.7.0_79/bin:/usr/local/jdk1.7.0_79/jre/bin\nCLASSPATH=/usr/local/jdk1.7.0_79/jre/lib:/usr/local/jdk1.7.0_79/lib:/usr/local/jdk1.7.0_79/jre/lib/charsets.jar\nexport  JAVA_HOME  JAVA_BIN JRE_HOME  PATH  CLASSPATH' .bash_profile

source /root/.bash_profile

#修改Tomcat启动文件,vim /etc/init.d/tomcat 在第二行加入以下内容:

sed -i '/#!\/bin\/sh/a\# chkconfig: 112 63 37\n# description: tomcat server init script\n# Source Function Library\n. /etc/init.d/functions\nJAVA_HOME=/usr/local/jdk1.7.0_79/\nCATALINA_HOME=/usr/local/tomcat' /etc/init.d/tomcat

chkconfig --add tomcat

chkconfig tomcat on

#配置maven环境

sed -i '/JAVA_HOME  JAVA_BIN JRE_HOME  PATH  CLASSPATH/a\export M2_HOME=/usr/local/apache-maven\nPATH=$PATH:$JAVA_HOME/bin:$M2_HOME/bin\nexport PATH USER LOGNAME MAIL HOSTNAME HISTSIZE' /etc/profile

cd /root

source /etc/profile

#把zookeeper拷贝到服务器/usr/local/下,执行以下命令:

cd /usr/local/

#wget http://apache.fayea.com/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz

#tar -zxvf zookeeper-3.4.9

mkdir -p /usr/local/zookeeper/data

mkdir -p /usr/local/zookeeper/log

/sbin/iptables -I INPUT -p tcp --dport 2181 -j ACCEPT

#/sbin/iptables -I INPUT -s 10.0.0.0/8 -p tcp --dport 2181 -j ACCEPT

/etc/init.d/iptables save

service iptables restart

cd zookeeper-3.4.8/bin

./zkServer.sh start

#把dubbo-admin放在tomcat的webapps下

cd /usr/local/tomcat/webapps

mv ROOT ../ROOT_BAK

rm -rf *

#

cp /usr/local/dubbo-admin-2.5.3.war .

#jar -xvf  ddubbo-admin-2.5.3.war -d ROOT

unzip dubbo-admin-2.5.3.war -d ROOT

service tomcat start

cd /usr/local/zookeeper-3.4.8/bin

./zkCli.sh

exit

你可能感兴趣的:(centos部署zookeeper+dubbo一键脚本)