码迷,mamicode.com
首页 > 系统相关 > 详细

【Linux】Jenkins以war包运行及开机启动配置(四)

时间:2019-07-15 01:25:23      阅读:495      评论:0      收藏:0      [点我收藏+]

标签:页面   目录   下载地址   name   cond   tps   Suite   reads   archive   

  本例介绍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 [root@H__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/

 

  

    

【Linux】Jenkins以war包运行及开机启动配置(四)

标签:页面   目录   下载地址   name   cond   tps   Suite   reads   archive   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!