【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,然后运行脚本 

1 #!/bin/bash
2 # 导入JENKINS_HOME环境变量
3 export JENKINS_HOME=/data/soft/jenkins
4
5 cd $JENKINS_HOME
6
7 # 启动Jenkins
8 nohup java -jar jenkins.war  --ajp13Port=-1 --httpPort=18080 >/dev/null 2>&1 &

  补充:

  使用java -jar 命令的时候可以加入启动参数,启动命令格式:java -jar jenkins.war [--option=value] [--option=value],

  到达一些配置效果,例如:

    修改jenkins端口启动命令:java -jar jenkins.war --httpPort=18080

  其他启动参数查看命令:java -jar jenkins.war --help

 1 [[email protected]__D jenkins]# java -jar jenkins.war --help
 2 Running from: /data/soft/jenkins/jenkins.war
 3 webroot: $user.home/.jenkins
 4 Jenkins Automation Server Engine 2.184
 5 Usage: java -jar jenkins.war [--option=value] [--option=value]
 6
 7 Options:
 8    --webroot                = folder where the WAR file is expanded into. Default is ${JENKINS_HOME}/war
 9    --pluginroot             = folder where the plugin archives are expanded into. Default is ${JENKINS_HOME}/plugins
10                               (NOTE: this option does not change the directory where the plugin archives are stored)
11    --extractedFilesFolder   = folder where extracted files are to be located. Default is the temp folder
12    --daemon                 = fork into background and run as daemon (Unix only)
13    --logfile                = redirect log messages to this file
14    --enable-future-java     = allows running with new Java versions which are not fully supported (class version 52 and above)
15    --javaHome               = Override the JAVA_HOME variable
16    --toolsJar               = The location of tools.jar. Default is JAVA_HOME/lib/tools.jar
17    --config                 = load configuration properties from here. Default is ./winstone.properties
18    --prefix                 = add this prefix to all URLs (eg http://localhost:8080/prefix/resource). Default is none
19    --commonLibFolder        = folder for additional jar files. Default is ./lib
20
21    --extraLibFolder         = folder for additional jar files to add to Jetty classloader
22
23    --logThrowingLineNo      = show the line no that logged the message (slow). Default is false
24    --logThrowingThread      = show the thread that logged the message. Default is false
25    --debug                  = set the level of debug msgs (1-9). Default is 5 (INFO level)
26
27    --httpPort               = set the http listening port. -1 to disable, Default is 8080
28    --httpListenAddress      = set the http listening address. Default is all interfaces
29    --httpKeepAliveTimeout   = how long idle HTTP keep-alive connections are kept around (in ms; default 5000)?
30    --httpsPort              = set the https listening port. -1 to disable, Default is disabled
31    --httpsListenAddress     = set the https listening address. Default is all interfaces
32    --httpsKeepAliveTimeout  = how long idle HTTPS keep-alive connections are kept around (in ms; default 5000)?
33    --httpsKeyStore          = the location of the SSL KeyStore file. Default is ./winstone.ks
34    --httpsKeyStorePassword  = the password for the SSL KeyStore file. Default is null
35    --httpsKeyManagerType    = the SSL KeyManagerFactory type (eg SunX509, IbmX509). Default is SunX509
36    --httpsPrivateKey        = this switch with --httpsCertificate can be used to run HTTPS with OpenSSL secret key
37      / --httpsCertificate     file and the corresponding certificate file
38    --http2Port              = set the http2 listening port. -1 to disable, Default is disabled
39    --http2ListenAddress     = set the http2 listening address. Default is all interfaces
40    --excludeCipherSuites    = set the ciphers to exclude (comma separated, use blank quote " " to exclude none) (default is
41                            // Exclude weak / insecure ciphers
42                            "^.*_(MD5|SHA|SHA1)$",
43                            // Exclude ciphers that don‘t support forward secrecy
44                            "^TLS_RSA_.*$",
45                            // The following exclusions are present to cleanup known bad cipher
46                            // suites that may be accidentally included via include patterns.
47                            // The default enabled cipher list in Java will not include these
48                            // (but they are available in the supported list).
49                            "^SSL_.*$",
50                            "^.*_NULL_.*$",
51                            "^.*_anon_.*$"
52    --controlPort            = set the shutdown/control port. -1 to disable, Default disabled
53
54    --useJasper              = enable jasper JSP handling (true/false). Default is false
55    --sessionTimeout         = set the http session timeout value in minutes. Default to what webapp specifies, and then to 60 minutes
56    --sessionEviction        = set the session eviction timeout for idle sessions in seconds. Default value is 180. -1 never evict, 0 evict on exit
57    --mimeTypes=ARG          = define additional MIME type mappings. ARG would be EXT=MIMETYPE:EXT=MIMETYPE:...
58                               (e.g., xls=application/vnd.ms-excel:wmf=application/x-msmetafile)
59    --maxParamCount=N        = set the max number of parameters allowed in a form submission to protect
60                               against hash DoS attack (oCERT #2011-003). Default is 10000.
61    --useJmx                 = Enable Jetty Jmx
62    --qtpMaxThreadsCount     = max threads number when using Jetty Queued Thread Pool
63    --jettyAcceptorsCount    = Jetty Acceptors number
64    --jettySelectorsCount    = Jetty Selectors number
65    --usage / --help         = show this message
66  Security options:
67    --realmClassName               = Set the realm class to use for user authentication. Defaults to ArgumentsRealm class
68
69    --argumentsRealm.passwd.<user> = Password for user <user>. Only valid for the ArgumentsRealm realm class
70    --argumentsRealm.roles.<user>  = Roles for user <user> (comma separated). Only valid for the ArgumentsRealm realm class
71
72    --fileRealm.configFile         = File containing users/passwds/roles. Only valid for the FileRealm realm class
73
74  Access logging:
75    --accessLoggerClassName        = Set the access logger class to use for user authentication. Defaults to disabled
76    --simpleAccessLogger.format    = The log format to use. Supports combined/common/resin/custom (SimpleAccessLogger only)
77    --simpleAccessLogger.file      = The location pattern for the log file(SimpleAccessLogger only)

开机启动配置

  参考:【Linux】开机自动启动脚本

  1、编写启动脚本jenkins

    命令:vim /data/soft/jenkins/jenkins.sh

 1 #!/bin/bash
 2
 3 # 导入环境变量
 4 export JENKINS_HOME=/data/soft/jenkins
 5 export JAVA_HOME=/data/soft/jdk1.8.0_181
 6
 7 cd $JENKINS_HOME
 8
 9 pid=`ps -ef | grep jenkins.war | grep -v ‘grep‘| awk ‘{print $2}‘`
10   if [ "$1" = "start" ];then
11   if [ $pid -gt 0 ];then
12   echo ‘jenkins is running...‘
13 else
14   ### java启动服务 配置java安装根路径,和启动war包存的根路径
15   nohup $JAVA_HOME/bin/java  -Xms128m -Xmx256m   -jar $JENKINS_HOME/jenkins.war  --ajp13Port=-1 --httpPort=18080 --prefix=/jenkins  >/dev/null 2>&1 &
16   fi
17   elif [ "$1" = "stop" ];then
18   exec ps -ef | grep jenkins | grep -v grep | awk ‘{print $2}‘| xargs kill -9
19   echo ‘jenkins is stop...‘
20 else
21   echo "Please input like this:"./jenkins.sh start" or "./jenkins stop""
22   fi 

  2、给jenkins.sh文件授权

    命令:chmod +x /data/soft/jenkins/jenkins.sh

  3、在/etc/rc.d/rc.local文件底部,添加内容:

1 # jenkins
2 /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/

  

    

原文地址:https://www.cnblogs.com/h--d/p/11186529.html

时间: 2024-10-27 05:59:41

【Linux】Jenkins以war包运行及开机启动配置(四)的相关文章

Linux tomcat部署War包,Linux在Tomcat部署JavaWeb项目,Linux部署War包

Linux tomcat部署War包,Linux在Tomcat部署JavaWeb项目,Linux部署War包 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ©Copyright 蕃薯耀 2017年3月6日 http://www.cnblogs.com/fanshuyao/ 一.Linux快速部署W

linux下部署war包

首先,直接把相应的war包放到$TOMCAT_HOME/webapps下(我直接用的WinSCP工具上传) 然后,修改$TOMCAT_HOME/conf/server.xml,在Host配置段中添加类似于如下内容: <Context path="/" docBase="hdfs-webdav.war" debug="0" privileged="true" reloadable="true"/>

Linux中tomcat开机启动配置脚本【参考其他文章的总结备忘录】

参考文章http://blog.sina.com.cn/s/blog_a57562c80101ic47.html http://blog.csdn.net/cheng168520/article/details/4312828 http://blog.sina.com.cn/s/blog_7f395ece0100ti5y.html 以前在自己本机上安装过一个Linux,后台应为系统崩溃,以前配置的开机启动脚本.数据库主从双备份.负载均衡等都没了,所以现在在重新配置一次,赶紧做个笔记防止自己以后又

推荐几位jenkins发布war包和jar包大佬的博客

jenkins部署tomcat的war包和jar包 https://blog.csdn.net/liuxiaoming1109/article/details/89311696 原文地址:https://www.cnblogs.com/nsh123/p/12143877.html

linux解压war包的命令

网上很多人说用jar包解压,但jar命令解压时不能指定目录,推荐使用unzip解压war包. unzip -d 指定目录 [[email protected] upload]# unzip -oq common.war -d common 命令名: unzip 功 能说明:解压缩zip文 件 语 法:unzip [-cflptuvz][-agCjLMnoqsVX][-P <密 码>][.zip文 件][文件][-d <目录>][-x <文件>] 或 unzip [-Z]

Maven项目打包成war包并启动war包运行

1 项目打包 1.1 右键点击所需要打包的项目,点击如图所示 Maven clean,这里 Maven 会清除掉之前对这个项目所有的打包信息. 1.2进行完 Maven clean 操作后,在eclipse的控制台会出现以下的信息. 1.3然后我们重新右键所需打包的项目,点击如图所示 maven build... 1.4 在弹出的界面中,进行如下图的操作. “Goals”输入框中输入 -X package,同时勾选下方 Update Snapshots 和 Skip Tests 选项框 1.5

spring boot + jersey工程由jar包转为war包在tomcat中启动报错问题

第一步: 在maven下,将Spring Boot工程由jar转换为war包启动,很简单,将pom.xml文件中的packaging改为war <packaging>war</packaging> 如果你使用Gradle,你需要修改build.gradle来将war插件应用到项目上: apply plugin: 'war'第二步: 产生一个可部署war包的第一步是提供一个SpringBootServletInitializer子类,并覆盖它的configure方法.这充分利用了Sp

Mac OSX的开机启动配置

Login Items Mac OSX的当前用户成功登录后启动的程序,该类别的启动项配置文件存放在~/Library/Preferences/com.apple.loginitems.plist,所以只针当前用户,你可以通过以下方式进行设置: 1.在系统偏好设置的“用户与群组”下面进行设置,可以删除.添加.开启和关闭; 2.你可以直接修改~/Library/Preferences/com.apple.loginitems.plist配置文件,其中每一个启动项对应一个字典,有Alias.Icon.

centos 6.8 开机启动配置

查看系统开机启动项 chkconfig --list 把写好的启动脚本添加到目录/etc/rc.d/init.d/,然后使用命令chkconfig设置开机启动. chkconfig 功能说明:检查,设置系统的各种服务. 语法:chkconfig [--add][--del][--list][系统服务] 或 chkconfig [--level <等级代号>][系统服务][on/off/reset] --add 添加服务 --del 删除服务 --list 查看各服务启动状态 如: 将mysql