【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 ...
随机推荐
- Visual Studio 2017 许可证已过期解决方案
1.卸载并重安VS2017 2.安装后打开VS2017,点击帮助=>注册产品,输入序列号NJVYC-BMHX2-G77MM-4XJMR-6Q8QF(企业版), KBJFW-NXHK6-W4WJM ...
- python API _ 1 (EasyDict)
作用:参数调用文件一:from easydict import EasyDict as edictimport numpy as np config = edict() config.IMG_HEIG ...
- 关于跨域介绍和djiago解决跨域问题
什么是跨域? 跨域,指的是浏览器不能执行其他网站的脚本.它是由浏览器的同源策略造成的,是浏览器对javascript施加的安全限制. 什么是同源策略? 同源策略又分为以下两种 DOM同源策略:禁止对不 ...
- redis详解(包含使用场景)
本文围绕以下几点进行阐述 1.为什么使用redis2.使用redis有什么缺点3.单线程的redis为什么这么快4.redis的数据类型,以及每种数据类型的使用场景5.redis的过期策略以及内存淘汰 ...
- Acwing P274 移动服务 题解
每日一题 day21 打卡 Analysis DP的状态为已经完成的请求数量,通过指派一位服务员可以把”完成i - 1个请求的状态”转移到”完成i个请求的状态”那么我们可以知道转移从dp[i - 1] ...
- centos7.3 安装 mysql-5.7.13
系统环境: [root@localhost ~]# cat /etc/RedHat-release CentOS release 6.7 (Final)[root@localhost tools]# ...
- java书籍推荐[转]
作为Java程序员来说,最痛苦的事情莫过于可以选择的范围太广,可以读的书太多,往往容易无所适从.下面就按照学习顺序,给大家推荐下面这些JAVA书籍.一.Java编程入门类,选择大于努力,入门太重要.对 ...
- 原生javascript禁用和屏蔽鼠标右键
(function(){ var doc=document, ua = navigator.userAgent.toLowerCase(), check = function(r){return r. ...
- 28、对多次使用的RDD进行持久化或Checkpoint
一.图解 二.说明 如果程序中,对某一个RDD,基于它进行了多次transformation或者action操作.那么就非常有必要对其进行持久化操作,以避免对一个RDD反复进行计算. 此外,如果要保证 ...
- ZR#1009
ZR#1009 解法: 因为无敌的SR给了一个大暴力算法,所以通过打表发现了了一些神奇的性质,即第一行和第一列的对应位置数值相等. 我们可以通过手算得出 $ F(n) = \frac{n(n + 1) ...