标签:path _id hat chown icmp cdb system sync cte
[root@205/204 ~]#cd /apps
[root@205/204 apps]#ls
apache-tomcat-8.5.32 jdk-8u191-linux-x64.rpm apache-tomcat-8.5.32.tar.gz tomcat
[root@205/204 apps]#ln -sv /apps/apache-tomcat-8.5.37 /apps/tomcat
‘ /apps/tomcat‘ -> ‘ /apps/apache-tomcat-8.5.37‘
[root@204/205 apps]#yum -y install jdk-8u191-linux-x64.rpm
[root@204/205 apps]#/apps/tomcat/bin/catalina.sh start
Using CATALINA_BASE: /apps/tomcat
Using CATALINA_HOME: /apps/tomcat
Using CATALINA_TMPDIR: /apps/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /apps/tomcat/bin/bootstrap.jar:/apps/tomcat/bin/tomcat-juli.jar
Tomcat started.
[root@204/205 apps]#ss -ntl #先将端口开启!
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 :::8080 :::*
[root@204 apps]#vim /etc/init.d/tomcat
#!/bin/bash
JDK_HOME=/apps/jdk
CATALINA_HOME=/apps/tomcat
export JDK_HOME CATALINA_HOME
source /etc/profile
#PID=ps -ef | grep -v grep | grep java | awk ‘{print $2}‘
#NUM=ps -ef | grep -v grep | grep java | awk ‘{print $2}‘ | wc -l
#case $1 in
start() {
echo "正在判断服务状态,请稍等!"
echo "请稍等3秒钟"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
if netstat -an | grep 8080 | grep LISTEN >/dev/null
then
echo "Tomcat已经正在运行了!"
else
echo "Tomcat没有运行,1秒后启动!"
echo 1;sleep 1
$CATALINA_HOME/bin/catalina.sh start
echo "Tomcat 已经成功启动完成,5秒后判断是否启动成功"
echo "5";sleep 1;echo "4";sleep 1
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
if netstat -an | grep 8080 | grep LISTEN >/dev/null
then
PID=ps -ef | grep tomcat | grep jdk | awk ‘{print $2}‘
NUM=ps -ef | grep tomcat | grep jdk | awk ‘{print $2}‘ | wc -l
echo "Tomcat 已经成功启动${NUM} 个Tomcat进程!,PID为${PID}"
else
echo "Tomcat启动失败,请重新启动!"
echo 1
fi
fi
}
stop() {
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 "正在判断服务状态,请稍等3秒钟!"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
if netstat -an | grep 8080 | grep LISTEN >/dev/null
then
echo "Tomcat运行中,1秒后关闭!"
echo 1;sleep 1
echo "即将关闭Tomcat服务,请稍等!"
$CATALINA_HOME/bin/catalina.sh stop ;echo "已经执行关闭命令,正在检查关闭了多少Tomcat进程,请稍等30秒钟!"
sleep 3
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
pkill java && pkill tomcat
if netstat -an | grep 8080 | grep LISTEN >/dev/null;then
PID=ps -ef | grep -v grep | grep java | awk ‘{print $2}‘
NUM=ps -ef | grep -v "color" | grep tomcat | awk ‘{print $2}‘ | wc -l
kill -9 $PID ;echo "已成功关闭${NUM} 个tomcat进程"
else
echo "Tomcat 已经关闭完成!"
echo "3";sleep 1;echo "2";sleep 1;echo "1";sleep 1
fi
else
echo "Tomcat 没有运行"
echo 1
fi
if netstat -an | grep 8080 | grep LISTEN >/dev/null;then
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 "关闭失败,即将强制删除tomcat进程!"
sleep 2
pkill tomcat ;sleep 2
if netstat -an | grep 8080 | grep LISTEN >/dev/null;then
echo "强制关闭失败,即将再次强制删除tomcat进程!"
pkill java; sleep 2
fi
fi
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
esac
[root@204 apps]# /etc/init.d/tomcat status
Usage: /etc/init.d/tomcat {start|stop|restart|status}
[root@204 apps]# /etc/init.d/tomcat start
正在判断服务状态,请稍等!
请稍等3秒钟
3
2
1
Tomcat已经正在运行了!
[root@204 apps]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 :::8080 :::*
[root@204 apps]# /etc/init.d/tomcat stop
正在判断服务状态,请稍等3秒钟!
3
2
1
Tomcat 没有运行
1
[root@204 apps]#ps -ef |grep tomcat #此时已经没有tomcat服务在运行了!!
root 18598 17020 0 11:41 pts/0 00:00:00 grep --color=auto tomcat
[root@204 apps]#scp /etc/init.d/tomcat 172.18.9.205:/etc/init.d/tomcat
root@172.18.9.205‘s password:
tomcat 100% 3339 973.5KB/s 00:00
正在判断服务状态,请稍等!
请稍等3秒钟
3
2
1
Tomcat已经正在运行了!
[root@centos7 apps]#chown www.www /apps/tomcat/ -R
[root@204/205 apps]#passwd www
Changing password for user www.
New password:123gxy
BAD PASSWORD: The password is shorter than 7 characters
Retype new password:123gxy
passwd: all authentication tokens updated successfully.
[root@204/205 apps]#/etc/init.d/tomcat stop
正在判断服务状态,请稍等3秒钟!
3
2
1
Tomcat 没有运行
1
[www@205 ~]$/etc/init.d/tomcat start
正在判断服务状态,请稍等!
请稍等3秒钟
3
2
1
Tomcat 已经成功启动完成,5秒后判断是否启动成功
5
4
3
2
1
Tomcat 已经成功启动1 个Tomcat进程!,PID为23324
[root@204/205 apps]#mkdir -p /data/tomcat/webapps
[root@204/205 apps]#chown www.www /data/tomcat/webapps/ -R
[www@205 ~]$vim /apps/tomcat/conf/server.xml
<Host name="localhost" appBase="/data/tomcat/webapps"
unpackWARs="false" autoDeploy="false"> #在该文件的第148行
[www@205 ~]$cd /data/tomcat/webapps/
[www@205 webapps]$mkdir testapp
[www@205 webapps]$vim testapp/index.jsp
testjsp
[www@205 webapps]$/etc/init.d/tomcat restart
Tomcat 已经成功启动完成,5秒后判断是否启动成功
5
4
3
2
1
Tomcat 已经成功启动1 个Tomcat进程!,PID为24404
[www@205 webapps]$ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 :::8080 :::*
[www@205 webapps]$ll
total 0
drwxrwxr-x. 2 www www 23 Apr 25 13:58 testapp
在204主机上:
[root@204/205 apps]#useradd www -u 2000 #该账号用于管理tomcat
[root@204/205 apps]#chown www.www /apps/tomcat/ -R
[root@204/205 apps]#passwd www
Changing password for user www.
New password:123gxy
BAD PASSWORD: The password is shorter than 7 characters
Retype new password:123gxy
passwd: all authentication tokens updated successfully.
[root@204 apps]#mkdir -p /data/tomcat/webapps
[root@204 apps]#chown www.www /data/tomcat/webapps/ -R
[root@204 apps]#su - www
[www@204 ~]$vim /apps/tomcat/conf/server.xml
<Host name="localhost" appBase="/data/tomcat/webapps"
unpackWARs="false" autoDeploy="false">
[www@204 ~]$cd /data/tomcat/webapps/
[www@204 webapps]$mkdir testapp
[www@204 webapps]$vim testapp/index.jsp
testapp 204
[www@204 webapps]$/etc/init.d/tomcat restart
Tomcat 已经成功启动完成,5秒后判断是否启动成功
5
4
3
2
1
Tomcat 已经成功启动1 个Tomcat进程!,PID为20650
slave:[root@202 ~]#vim /etc/keepalived/keepalived.conf
global_defs {
notification_email {br/>acassen@firewall.loc
failover@firewall.locbr/>sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_iptables #该参数务必加入脚本中,否则在其他主机上ping不通VIP
vrrp_garp_interval 0
vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state MASTER
interface ens37
virtual_router_id 120
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.18.9.248 dev eth0 label ens37:0
}
} #该脚本下面的都删除!!
[root@202 ~]#systemctl restart keepalived
[root@202 ~]#ifconfig #网卡子接口绑定成功
ens37:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.18.9.248 netmask 255.255.255.255 broadcast 0.0.0.0
ether fa:16:3e:75:57:73 txqueuelen 1000 (Ethernet)
[root@204 ~]#ping 172.18.9.248 #加上参数后就ping通了!
PING 172.18.9.248 (172.18.9.248) 56(84) bytes of data.
64 bytes from 172.18.9.248: icmp_seq=48 ttl=64 time=0.029 ms
64 bytes from 172.18.9.248: icmp_seq=49 ttl=64 time=0.046 ms
现在在203 slave上同款:[root@203 ~]#vim /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state BACKUP
interface ens37
virtual_router_id 120
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.18.9.248 dev ens37 label ens37:0
}
}
[root@202/203 ~]#systemctl restart keepalived
[root@202/203 ~]#systemctl enable keepalived
Created symlink from /etc/systemd/system/multiuser.target.wants/keepalived.service to /usr/lib/systemd/system/keepalived.service.
listen webserver
bind 172.18.9.248:80
mode http
log global
option httplog
server 1 172.18.9.204:8080 check inter 3000 fall 2 rise 5
server 2 172.18.9.205:8080 check inter 3000 fall 2 rise 5
[root@202 ~]#systemctl start haproxy
[root@202 ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 172.18.9.248:80 :
net.ipv4.ip_nonlocal_bind = 1
net.ipv4.ip_forward = 1 #将2者写入配置文件,并改为1,打开状态!
[root@202 ~]#sysctl -p #验证查看
Jenkins的下载路径:https://pkg.jenkins.io/redhat-stable/jenkins-2.138.4-1.1.noarch.rpm
[root@201 ~]#wget https://pkg.jenkins.io/redhat-stable/jenkins-2.138.4-1.1.noarch.rpm
[root@201 ~]#yum -y install jenkins-2.138.4-1.1.noarch.rpm
[root@201 ~]#yum install -y jdk-8u191-linux-x64.rpm
[root@201 ~]#vim /etc/sysconfig/jenkins
JENKINS_USER="root/www" 两者都行,默认为Jenkins,为了方便登陆才修改的
[root@201 ~]#systemctl start jenkins
[root@201 ~]#systemctl enable jenkins
jenkins.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig jenkins on
[root@201 ~]#ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 :::8080 :::* #Jenkins的端口也是8080,端口开启即可访问页面!!
查看密码:[root@201 ~]#cat /var/lib/jenkins/secrets/initialAdminPassword
dab1711156e2417180f029f56100984c
查看日志:[root@201 ~]#tail -f /var/log/jenkins/jenkins.log
Apr 26, 2019 10:16:10 PM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tasks.Maven.MavenInstaller
Apr 26, 2019 10:16:10 PM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 19,854 ms
Apr 26, 2019 10:16:21 PM hudson.model.UpdateSite updateData
INFO: Obtained the latest update center data file for UpdateSource default
Apr 26, 2019 10:16:21 PM jenkins.InitReactorRunner$1 onAttained
INFO: Completed initialization
20190422 Gitlab Jenkins 的搭建及准备web页面
标签:path _id hat chown icmp cdb system sync cte
原文地址:https://blog.51cto.com/14128387/2385480