#: Prepare Java environment, install the JDK root @ Ubuntu: ~ # cd / usr / local / src / root @ Ubuntu: / usr / local / src # LS the JDK . -8u191-Linux-x64 tar .gz root @ Ubuntu: / usr / local # LN . -sv / usr / local / the src / jdk1 . 8 .0_191 / usr / local / JDK
#: configure the environment variables
the root @ Ubuntu: / Data / Tomcat # Vim / etc / Profile
Export the JAVA_HOME = / usr / local / the JDK
Export TOMCAT_HOME = / Apps / Tomcat
Export the PATH = $ JAVA_HOME / bin: $ JAVA_HOME / jre / bin: $ TOMCAT_HOME / bin: $ the PATH
Export the CLASSPATH = $ the CLASSPATH:. $ JAVA_HOME / lib: $ JAVA_HOME / jre / lib : $ JAVA_HOME / lib / tools.jar
#: create a directory, and download the Tomcat
root @ Ubuntu: / the Data / Tomcat # mkdir / Apps
@ Ubuntu root: / the Data / Tomcat # cd / Apps /
root @ Ubuntu: / the Data / Tomcat # wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.46/bin /apache-tomcat-8.5.46.tar.gz
root @ Ubuntu: / the Data / # tar XF the Apache Tomcat-Tomcat-8.5.46.tar.gz
root @ Ubuntu: / the Data / Tomcat LN # -sv / Apps / the Apache -8.5.46 - tomcat / Apps / Tomcat
the root @ Ubuntu: / Data / CD Tomcat Tomcat #
#: Tomcat modify the configuration file
the root @ Ubuntu: / Data / Tomcat # Vim the conf / the server.xml
<the Host name = "localhost" the appBase = "/ the Data / Tomcat / tomcat_webapps" unpackWARs = "to true" autoDeploy = "to true">
#: create three directories (appdir put compressed files, webdir put extracting file, webapps Tomcat is access / directory)
root @ Ubuntu: / Data / Tomcat # mkdir / Data / Tomcat / {tomcat_appdir, tomcat_webdir, tomcat_webapps} -pv
#: Create a Tomcat user (it must log)
Ubuntu root @: / the Data / Tomcat # groupadd -g 2019 Tomcat
root @ Ubuntu: / the Data / Tomcat # useradd -m -u 2019 -s / bin / bash -g Tomcat Tomcat
#: edit the startup script to stop a Tomcat
root @ Ubuntu: ~ # vim Tomcat
! # / bin / bash
either the JDK_HOME = / Apps / jdk1.7.0_79
CATALINA_HOME = / Apps / Tomcat
Export either the JDK_HOME CATALINA_HOME
Source / etc / Profile
# PID = `PS -ef | grep -v grep | grep the Java | awk 'Print $ {2}' `
#` NUM = PS -ef | grep -v grep | grep Java | awk 'Print $ {2}' | WC -l`
#case $. 1 in
Start () {
echo "determining service state, please wait "!
echo" Please wait 3 seconds "
echo" 3 "; SLEEP 1; echo" 2 "; SLEEP 1; echo" 1 "; 1 SLEEP
IF netstat -an | grep 8080 | grep LISTEN>/dev/null
then
echo "! Tomcat is already running"
the else
echo "Tomcat is not running, 1 second after the start!"
echo 1; SLEEP 1
$ CATALINA_HOME / bin / catalina.sh Start
echo "Tomcat has started successfully completed, to determine whether to start after 5 seconds success "
echo" 5 "; SLEEP 1; echo" 4 "; SLEEP 1
echo" 3 "; SLEEP 1; echo" 2 "; SLEEP 1; echo" 1 "; 1 SLEEP
IF netstat -an | grep 8080 | grep LISTEN > / dev / null
the then
the PID = `PS -ef | grep Tomcat | grep JDK | awk '{Print $ 2}'`
NUM = `PS -ef | grep Tomcat | grep JDK | awk '{Print $ 2}' | WC - l`
echo "Tomcat has started successfully $ {NUM} a Tomcat process!,PID为${PID}"
else
echo "Tomcat failed to start, restart!"
echo. 1
Fi
Fi
}
STOP () {
the PID = `PS -ef | grep -v grep | grep Java | awk 'Print $ {2}'`
NUM = `PS -ef | -v grep "Color" | grep Tomcat | awk 'Print $ {2}' | WC -l`
echo "is determined service state, wait 3 seconds!"
echo "3"; SLEEP. 1; echo "2"; 1 SLEEP; echo "1"; 1 SLEEP
IF netstat -an | grep 8080 | grep LISTEN> / dev / null
the then
echo "Tomcat is running, shut down after one second!"
echo 1; SLEEP 1
echo "Tomcat service will be shut down, Please wait!"
$ CATALINA_HOME / bin / catalina.sh stop; echo " close the command has been executed, how much is being checked shut Tomcat process, please wait 30 seconds!"
27 SLEEP
echo ". 3"; SLEEP. 1; echo "2"; SLEEP. 1; echo ". 1"; SLEEP. 1
the pkill the pkill Tomcat Java &&
IF the netstat -an | grep 8080 | grep the LISTEN> / dev / null; the then
the PID = ` -ef PS | grep -v grep | grep Java | awk 'Print $ {2}' `
NUM =` PS -ef | grep -v "Color" | grep Tomcat | awk 'Print $ {2}' | WC -l`
the kill -9 $ PID; echo "has successfully closed a $ {NUM} tomcat process"
the else
echo "Tomcat has been closed to complete!"
echo "3"; SLEEP 1; echo "2"; SLEEP 1; echo "1";1 SLEEP
fi
the else
echo "Tomcat is not running"
echo 1
Fi
IF the netstat -an | grep 8080 | grep the LISTEN> / dev / null; the then
the PID = `PS -ef | grep -v grep | grep Java | awk 'Print $ {2}'`
# `NUM = PS -ef | grep -v "Color" | grep tomcat | awk '{Print $ 2}' | WC -l`
echo "fail closed, is about to force the removal of tomcat process!"
SLEEP 2
pkill tomcat; 2 SLEEP
IF netstat -an | grep 8080 | grep LISTEN > / dev / null; the then
echo "forced shutdown failed, once again about to force the removal of tomcat process!"
pkill the Java; SLEEP 2
fi
fi
}
#: switch to the tomcat, use a script to start the service
root @ Ubuntu: ~ # su - tomcat
tomcat @ ubuntu: ~ $ /etc/init.d/tomcat start
#:配置keepalive+haproxy
#:安装
root@ubuntu:~# apt install haproxy keepalived -y
#:配置haproxy
root@ubuntu:~# vim /etc/haproxy/haproxy.cfg
global
maxconn 100000
#chroot /usr/local/haproxy
uid 99
gid 99
daemon
nbproc 1
pidfile /run/haproxy.pid
stats socket /var/lib/haproxy/haproxy.sock mode 600 level admin
log 127.0.0.1 local3 info
defaults
option http-keep-alive
option forwardfor
maxconn 100000
mode http
timeout connect 300000ms
timeout client 300000ms
timeout server 300000ms
listen stats
mode http
bind 0.0.0.0:9999
stats enable
Global log
stats URI / Status HAProxy-
stats haadmin the auth: q1w2e3r4ys
the listen WEB_PORT
the bind 0.0.0.0:80
MODE HTTP
log Global
Server 192.168.6.104 192.168.6.104:8080 Check 2 Rise Fall 3000 Inter. 5
Server 192.168.6.103 192.168.6.103:8080 Inter 2 Rise Fall 3000 the Check 5
#: Find keepalive configuration file where the
root @ Ubuntu: ~ # the Find / -name keepalived * * .conf
#: copy the configuration file to, etc directory
root @ ubuntu: ~ # cp / usr /etc/keepalived/keepalived.conf /share/doc/keepalived/samples/keepalived.conf.vrrp
#: modify the configuration file
root @ Ubuntu: ~ # vim /etc/keepalived/keepalived.conf
notification_email_from [email protected]
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth0
garp_master_delay 10
smtp_alert
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.6.200 dev eth0 label eth0:0
}
}
#:修改内核参数
root@ubuntu:~# vim /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1
#:重启服务
root@ubuntu:~# systemctl restart haproxy keepalived
#: In jenkins server, copy the public key to the Tomcat server root @ Ubuntu: / opt / web1 # SSH -copy- the above mentioned id Tomcat @ 192.168 . 6.104
#: How to deploy the war package Jenkins #: deploy the JDK root @ Ubuntu: ~ # cd / usr / local / src / root @ Ubuntu: / usr / local / src # tar XF the JDK-8u191-Linux-x64. Tar . GZ the root @ Ubuntu: / usr / local / the src # LN -sv / usr / local / the src / JDK . jdk1 . 8 . .0_191 / JDK-8u191-x64-Linux- the tar .gz the root @ Ubuntu: / usr / local / the src # LN . -sv / usr / local / src / jdk1 8 .0_191 / usr / local / the JDK #: configuration environment variable root @ Ubuntu: / usr / local / src # vim / etc / Profile Export JAVA_HOME = / usr / local / the JDK Export TOMCAT_HOME=/apps/tomcat export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$TOMCAT_HOME/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar root@ubuntu:/usr/local/src# source /etc/profile #:下载war包 root@ubuntu:/usr/local/src# mkdir /data/jenkins -pv root@ubuntu:/usr/local/src# cd /data/jenkins/ #:启动服务 root@ubuntu:/data/jenkins# java -jar jenkins.war
#:
# Tomcat-based equipment jenkins war package #: First Business stopped root @ Ubuntu: / the Data / Tomcat / tomcat_webapps # /etc/init.d/ Tomcat STOP #: prepare war package root @ Ubuntu: / the Data / Tomcat / tomcat_webapps # LS jenkins.war #: extracting the root @ Ubuntu: / Data / Tomcat / # tomcat_webapps the unzip jenkins.war - D Jenkins the root @ Ubuntu: / Data / Tomcat / tomcat_webapps # chown -R & lt tomcat.tomcat / Data / Tomcat / #: switch to the Tomcat start the service root @ ubuntu: / the Data / Tomcat / tomcat_webapps # su - Tomcat Tomcat @ Ubuntu: ~ $ /etc/init.d/ Tomcat start #: direct access test to be wrong, install some packages root @ ubuntu:/data/tomcat/tomcat_webapps# apt-get install libxrender-dev root@ubuntu:/data/tomcat/tomcat_webapps# apt-get install libxtst-dev