1.免登陆:
需要目标机生成公钥 ,并将公钥放置到跳板机的authorized_keys文件中
linux 操作中遇见的问题:
echo ''>catalina.out
chmod -R 777 filename
1、lsof -i:端口号
2、netstat -tunlp|grep 端口号
远程登录部署的脚本编写:
echo "deploy start"
whoami
echo "scp start"
scp target/$BUILD_WAR_NAME".war" root@$SERVER_ADDR:/home/program/
echo "scp done"
ssh root@$SERVER_ADDR "bash" << remoteprocess
#!/bin/bash
echo "remote process start"
PROCESS_COUNT=\$(ps aux|grep $TOMCAT_ADDR|grep -v grep|wc -l)
if [ \$PROCESS_COUNT -gt 0 ]; then
echo "stop traffic"
rm -rf $TOMCAT_ADDR/webapps/$DEPLOY_WAR_NAME/checkAlive.html
echo "waiting for current request"
sleep 10s
echo "waiting done"
PROCESS_LIST=\$(ps aux | grep java | grep $TOMCAT_ADDR|awk '{print \$2}')
echo "FOUND TOMCAT PROCESS LIST: \${PROCESS_LIST}"
for id in \$PROCESS_LIST
do
echo "killed \${id}"
kill -9 \$id
done
fi
sleep 5s
echo "sleep done"
rm -rf $TOMCAT_ADDR/webapps/$DEPLOY_WAR_NAME*
mv /home/
program/$BUILD_WAR_NAME".war" $TOMCAT_ADDR/webapps/$DEPLOY_WAR_NAME".war"
echo "deploy webapps done"
echo $TOMCAT_ADDR
sh $TOMCAT_ADDR/bin/catalina.sh start
echo "remote process done!"
exit
remoteprocess