【Linux】Jenkins以war包运行及开机启动配置(四)
本例介绍jenkins已war包运行及开机启动配置
环境:Linux环境(CentOS 7.4)
以war包运行
1、下载jenkins.war包
2、启动war包( 默认端口:8080,默认JENKINS_HOME目录:~/.jenkins )
前台启动命令:java -jar jenkins.war
后台启动命令:nohup java -jar jenkins.war &
3、使用浏览器打开地址:http://ip:8080,即可访问到jenkins
关闭jenkins,页面访问地址:http://ip:8080/exit
重启jenkins,页面访问地址:http://ip:8080/restart
4、其他安装参考【Linux】Jenkins安装(一)
5、修改JENKINS_HOME目录启动,需要新建一个脚本jenkins.sh,然后运行脚本
#!/bin/bash
# 导入JENKINS_HOME环境变量
export JENKINS_HOME=/data/soft/jenkins cd $JENKINS_HOME # 启动Jenkins
nohup java -jar jenkins.war --ajp13Port=- --httpPort= >/dev/null >& &
6、构建shell,demo如下:
#!/bin/bash
# 编译+部署zeus站点 # 保持Jenkins启动的Service(tomcat) 不被杀死
export BUILD_ID=dontKillMe # 需要配置如下参数
# 项目路径,在Execute Shell中国配置项目路径, pwd 就可以获得项目路径
# export PROJ_PATH=这个jenkins任务在部署机器上的路径
export PROJ_PATH=`pwd` # 输入你在环境上tomcat的全路径
# export TOMCAT_APP_PATH=tomcat在部署机器上的路径
export TOMCAT_APP_PATH=/data/soft/apache-tomcat- ### base 函数
killTomcat()
{
pid=`ps -ef | grep tomcat- | grep -v grep | awk '{print $2}'`
echo "Tomcat Id is : $pid"
if [ ! -n "$pid" ];
then
echo "No Tomcat Pid alive"
else
echo "Tomcat Pid alive"
fi
} cd $PROJ_PATH/god-site
pwd mvn clean package # 停tomcat
killTomcat # 删除原有工程
rm -rf $TOMCAT_APP_PATH/webapps/zeus.war # 复制新的工程
cp $PROJ_PATH/god-site/god-web/god-web-zeus/target/zeus.war $TOMCAT_APP_PATH/webapps/ # 启动Tomcat
cd $TOMCAT_APP_PATH
sh bin/startup.sh
补充:
使用java -jar 命令的时候可以加入启动参数,启动命令格式:java -jar jenkins.war [--option=value] [--option=value],
到达一些配置效果,例如:
修改jenkins端口启动命令:java -jar jenkins.war --httpPort=18080
其他启动参数查看命令:java -jar jenkins.war --help
[root@H__D jenkins]# java -jar jenkins.war --help
Running from: /data/soft/jenkins/jenkins.war
webroot: $user.home/.jenkins
Jenkins Automation Server Engine 2.184
Usage: java -jar jenkins.war [--option=value] [--option=value] Options:
--webroot = folder where the WAR file is expanded into. Default is ${JENKINS_HOME}/war
--pluginroot = folder where the plugin archives are expanded into. Default is ${JENKINS_HOME}/plugins
(NOTE: this option does not change the directory where the plugin archives are stored)
--extractedFilesFolder = folder where extracted files are to be located. Default is the temp folder
--daemon = fork into background and run as daemon (Unix only)
--logfile = redirect log messages to this file
--enable-future-java = allows running with new Java versions which are not fully supported (class version and above)
--javaHome = Override the JAVA_HOME variable
--toolsJar = The location of tools.jar. Default is JAVA_HOME/lib/tools.jar
--config = load configuration properties from here. Default is ./winstone.properties
--prefix = add this prefix to all URLs (eg http://localhost:8080/prefix/resource). Default is none
--commonLibFolder = folder for additional jar files. Default is ./lib --extraLibFolder = folder for additional jar files to add to Jetty classloader --logThrowingLineNo = show the line no that logged the message (slow). Default is false
--logThrowingThread = show the thread that logged the message. Default is false
--debug = set the level of debug msgs (-). Default is (INFO level) --httpPort = set the http listening port. - to disable, Default is
--httpListenAddress = set the http listening address. Default is all interfaces
--httpKeepAliveTimeout = how long idle HTTP keep-alive connections are kept around (in ms; default )?
--httpsPort = set the https listening port. - to disable, Default is disabled
--httpsListenAddress = set the https listening address. Default is all interfaces
--httpsKeepAliveTimeout = how long idle HTTPS keep-alive connections are kept around (in ms; default )?
--httpsKeyStore = the location of the SSL KeyStore file. Default is ./winstone.ks
--httpsKeyStorePassword = the password for the SSL KeyStore file. Default is null
--httpsKeyManagerType = the SSL KeyManagerFactory type (eg SunX509, IbmX509). Default is SunX509
--httpsPrivateKey = this switch with --httpsCertificate can be used to run HTTPS with OpenSSL secret key
/ --httpsCertificate file and the corresponding certificate file
--http2Port = set the http2 listening port. - to disable, Default is disabled
--http2ListenAddress = set the http2 listening address. Default is all interfaces
--excludeCipherSuites = set the ciphers to exclude (comma separated, use blank quote " " to exclude none) (default is
// Exclude weak / insecure ciphers
"^.*_(MD5|SHA|SHA1)$",
// Exclude ciphers that don't support forward secrecy
"^TLS_RSA_.*$",
// The following exclusions are present to cleanup known bad cipher
// suites that may be accidentally included via include patterns.
// The default enabled cipher list in Java will not include these
// (but they are available in the supported list).
"^SSL_.*$",
"^.*_NULL_.*$",
"^.*_anon_.*$"
--controlPort = set the shutdown/control port. - to disable, Default disabled --useJasper = enable jasper JSP handling (true/false). Default is false
--sessionTimeout = set the http session timeout value in minutes. Default to what webapp specifies, and then to minutes
--sessionEviction = set the session eviction timeout for idle sessions in seconds. Default value is . - never evict, evict on exit
--mimeTypes=ARG = define additional MIME type mappings. ARG would be EXT=MIMETYPE:EXT=MIMETYPE:...
(e.g., xls=application/vnd.ms-excel:wmf=application/x-msmetafile)
--maxParamCount=N = set the max number of parameters allowed in a form submission to protect
against hash DoS attack (oCERT #-). Default is .
--useJmx = Enable Jetty Jmx
--qtpMaxThreadsCount = max threads number when using Jetty Queued Thread Pool
--jettyAcceptorsCount = Jetty Acceptors number
--jettySelectorsCount = Jetty Selectors number
--usage / --help = show this message
Security options:
--realmClassName = Set the realm class to use for user authentication. Defaults to ArgumentsRealm class --argumentsRealm.passwd.<user> = Password for user <user>. Only valid for the ArgumentsRealm realm class
--argumentsRealm.roles.<user> = Roles for user <user> (comma separated). Only valid for the ArgumentsRealm realm class --fileRealm.configFile = File containing users/passwds/roles. Only valid for the FileRealm realm class Access logging:
--accessLoggerClassName = Set the access logger class to use for user authentication. Defaults to disabled
--simpleAccessLogger.format = The log format to use. Supports combined/common/resin/custom (SimpleAccessLogger only)
--simpleAccessLogger.file = The location pattern for the log file(SimpleAccessLogger only)
开机启动配置
1、编写启动脚本jenkins
命令:vim /data/soft/jenkins/jenkins.sh
#!/bin/bash # 导入环境变量
export JENKINS_HOME=/data/soft/jenkins
export JAVA_HOME=/data/soft/jdk1..0_181 cd $JENKINS_HOME pid=`ps -ef | grep jenkins.war | grep -v 'grep'| awk '{print $2}'`
if [ "$1" = "start" ];then
if [ -n "$pid" ];then
echo 'jenkins is running...'
else
### java启动服务 配置java安装根路径,和启动war包存的根路径
nohup $JAVA_HOME/bin/java -Xms128m -Xmx256m -jar $JENKINS_HOME/jenkins.war --ajp13Port=- --httpPort= >/dev/null >& &
fi
elif [ "$1" = "stop" ];then
exec ps -ef | grep jenkins | grep -v grep | awk '{print $2}'| xargs kill -
echo 'jenkins is stop...'
else
echo "Please input like this:"./jenkins.sh start" or "./jenkins stop""
fi
2、给jenkins.sh文件授权
命令:chmod +x /data/soft/jenkins/jenkins.sh
3、在/etc/rc.d/rc.local文件底部,添加内容:
# jenkins
/data/soft/jenkins/jenkins.sh start
4、重启计算机
命令:reboot
Jenkins常用功能
1、备份、迁移、恢复jenkins
首先找到JENKINS_HOME,因为Jenkins的所有的数据都是以文件的形式存放在JENKINS_HOME目录中。不管是迁移还是备份,只需要操作JENKINS_HOME就行了。
迁移:建议将JENKINS_HOME打包后在拷贝,windows可以用zip,rar等,Linux有zip,tar等,然后将打包的文件解压到新的JENKINS_HOME目录就行了。
备份:如果是临时备份,整个压缩文件就行了。
恢复:恢复的时候需要先停止jenkins。
2、升级Jenkins
Jenkins的开发迭代非常快,每周发布一个开发版本,长期支持版每半年更新一次(ps:大版本更新)。如此频繁的更新,怎么升级呢?
war:下载新版的war文件,替换旧版本war文件。重启即可。
二进制:卸载旧版本,安装新版本即可。
Jenkins程序下载地址:http://mirrors.jenkins-ci.org/
【Linux】Jenkins以war包运行及开机启动配置(四)的更多相关文章
- Linux tomcat部署War包,Linux在Tomcat部署JavaWeb项目,Linux部署War包
Linux tomcat部署War包,Linux在Tomcat部署JavaWeb项目,Linux部署War包 >>>>>>>>>>>& ...
- jenkins部署war包到远程服务器的tomcat
一.目的 jenkins上将war包,部署到远程服务器的tomcat上. 这边tomcat在windows 主机A上,版本apache-tomcat-8.5.23. jenkins在主机B上,cent ...
- jenkins相关war包下载
1.jenkins的war包下载地址 地址:http://mirrors.jenkins-ci.org/,打开链接后,表格有war列,Releases行是短期更新包.LTS是长期更新包.一般选择Rel ...
- CentOS下nginx+php的配置及nginx开机启动配置
关闭防火墙 (不然外链接是访问不了 apache) service iptables stop 关闭安全系统 SELinux( 不然报403 访问页面错误 ) 1.Nginx安装主要在于配置文件的修改 ...
- spring boot生成的war包运行时出现java.lang.NullPointerException: null
最近写了一个数据库同步的程序,见之前的博客,没有用到spring框架来集成,用的时纯Java代码.然后,项目经理要我把程序合到spring boot框架中,因为涉及到多数据源,时间又比较紧,同意我直接 ...
- gitlab+jenkins+tomcat war包部署(此文有新版本)
对本文进行格式整理,url: https://www.cnblogs.com/huandada/p/9969234.html 整个项目的框架为: 1.gitlab的安装(Centos7) 新建/etc ...
- Jenkins的war包安装
安装Jenkins首先要安装jdk,在官网下载jdk安装并配置环境变量 1.Jenkins下载地址,下载war包 https://www.jenkins.io/download/ 2.打开命令行窗口, ...
- 【Tomcat部署】Linux环境部署war包到tomcat
以turbine为例. 一.部署 1.下载或者生成war包(从maven上下载war包,并改名字为turbine.war) 2.将turbine.war拷贝到$TOMCAT_HOME/webapps中 ...
- springboot项目作为war包运行
一.首先是pom文件中设置打成war包 < packaging>war< /packaging> 二.然后是修改依赖: <dependency> <group ...
随机推荐
- TODO : 一些新的学习计划
1.读完jvm那本书 2.加深Android的开发知识 3.编写atx的demo 4.跑几个apk的性能测试并做详细的性能分析 5.尝试实现一个uiautomator多个手机同时执行脚本的可能性(连线 ...
- 关于redis的持久化策略
Redis的持久化 Redis虽然是基于内存的存储系统,但是它本身是支持内存数据的持久化的,而且提供两种主要的持久化策略:RDB快照和AOF日志. Redis的RDB快照 Redis支持将当前数据的快 ...
- 语义(Semantics)
流计算语义(Semantics)的定义 每一条记录被流计算系统处理了几次 有三种语义: 1.At most once 一条记录要么被处理一次,要么没有被处理 2.At least once 一条记录可 ...
- 详解C++中基类与派生类的转换以及虚基类
很详细!转载链接 C++基类与派生类的转换在公用继承.私有继承和保护继承中,只有公用继承能较好地保留基类的特征,它保留了除构造函数和析构函数以外的基类所有成员,基类的公用或保护成员的访问权限在派生类中 ...
- LightOJ - 1095 - Arrange the Numbers(错排)
链接: https://vjudge.net/problem/LightOJ-1095 题意: Consider this sequence {1, 2, 3 ... N}, as an initia ...
- 使用apache 的 ab命令压力测试nginx服务器
nginx压力测试方法: #ab命令 #安装ab #Centos系统 yum install apr-util #Ubuntu系统 sudo apt-get install apache2-utils ...
- BZOJ 1406: [AHOI2007]密码箱
二次联通门 : BZOJ 1406: [AHOI2007]密码箱 /* BZOJ 1406: [AHOI2007]密码箱 数论 要求 x^2 ≡ 1 (mod n) 可以转换为 x ^ 2 - k * ...
- Mujin Programming Challenge 2017题解
传送门 \(A\) 似乎并不难啊然而还是没想出来-- 首先我们发现对于一个数\(k\),它能第一个走到当且仅当对于每一个\(i<k\)满足\(x_i\geq 2i-1\),这样我们就可以把所有的 ...
- P5025 [SNOI2017]炸弹
原题链接 https://www.luogu.org/problem/P5025 闲话时刻: 第一道 AC 的黑题,虽然众人皆说水... 其实思路不是很难,代码也不是很难打,是一些我们已经学过的东西 ...
- [Web前端] WEEX、React-Native开发App心得 (转载)
转自: https://www.jianshu.com/p/139c5074ae5d 2018 JS状态报告: https://2018.stateofjs.com/mobile-and-deskto ...