Linux安装jenkins

「爱情、让人受尽委屈。」 2022-05-22 01:47 299阅读 0赞
inux下安装jenkins有两种方式:

1,通过rpm方式

2,通过war方式

本文是基于war方式,以下是war方式安装的步骤:

1,下载安装配置JDK环境;

具体操作查看笔者Linux下装JDK笔录:

https://www.jianshu.com/p/5557fb0bc5d4

2,下载安装配置Tomcat环境;

具体操作查看笔者Linux安装tomcat笔录:

https://www.jianshu.com/p/f62f75c00c97

3,下载安装jenkins;
1,下载jenkins的war包:

去该地址下载想要安装的版本:

http://mirrors.jenkins.io/war-stable/

这里笔者下载的是2.121.1版本

  1. [root@iZj6c7eeosj2t5vjw8rf4xZ jenkins]# wget http://mirrors.shu.edu.cn/jenkins/war-stable/2.121.1/jenkins.war

2,把jenkins.war包放置到tomcat的webapps目录下面;

  1. [root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# cp -f /opt/frank/jenkins/jenkins.war /opt/tomcat/webapps/
  2. [root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# ls
  3. docs examples host-manager jenkins.war manager ROOT tatoo

3,启动tomcat;

启动tomcat,tomcat会自动解压war包,生成一个jenkins文件夹,而且Jenkins默认会存放在用户主目录下的.jenkins文件夹中。
如:Linux root用户:/root/.jenkins

tomcat自动解压生成jenkins文件查看:

  1. [root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# ls
  2. docs examples host-manager jenkins jenkins.war manager ROOT tatoo
  3. [root@iZj6c7eeosj2t5vjw8rf4xZ webapps]# cd jenkins
  4. [root@iZj6c7eeosj2t5vjw8rf4xZ jenkins]# ls
  5. bootstrap favicon.ico LogFileOutputStream$1.class MainDialog$1.class scripts
  6. ColorFormatter.class help LogFileOutputStream$2.class MainDialog.class WEB-INF
  7. css images LogFileOutputStream.class Main$FileAndDescription.class winstone.jar
  8. dc-license.txt JNLPMain.class Main.class META-INF
  9. executable jsbundles MainDialog$1$1.class robots.txt

jenkins的.jenkins文件位置

  1. [root@iZj6c7eeosj2t5vjw8rf4xZ jenkins]# cd /root/.jenkins/
  2. [root@iZj6c7eeosj2t5vjw8rf4xZ .jenkins]# ls
  3. config.xml jenkins.install.UpgradeWizard.state nodes secrets
  4. hudson.model.UpdateCenter.xml jobs plugins updates
  5. identity.key.enc logs secret.key userContent
  6. jenkins.CLI.xml nodeMonitors.xml secret.key.not-so-secret users

4,如果不知道tomcat的访问端口是什么可以通过以下命令:

  1. [root@iZj6c7eeosj2t5vjw8rf4xZ .jenkins]# ps -ef|grep tomcat
  2. root 1913 1883 0 Apr01 ? 01:14:19 java -jar /opt/frank/tomcat/apache-tomcat-8.5.23/melibs/cn-jufuns-ien-api-provider-1.0.0-local_dev.jar
  3. root 18774 1 0 Apr12 ? 01:51:33 /usr/java/jdk1.8.0_144/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dignore.endorsed.dirs= -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcatalina.home=/opt/tomcat -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
  4. root 19027 17608 0 14:51 pts/0 00:00:00 grep tomcat
  5. [root@iZj6c7eeosj2t5vjw8rf4xZ .jenkins]# netstat -apn
  6. Active Internet connections (servers and established)
  7. Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
  8. tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1432/sshd
  9. tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 2108/nginx
  10. tcp 0 0 0.0.0.0:42395 0.0.0.0:* LISTEN 1894/java
  11. tcp 0 0 127.0.0.1:32000 0.0.0.0:* LISTEN 1144/java
  12. tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 18774/java
  13. tcp 0 0 0.0.0.0:2181 0.0.0.0:* LISTEN 1894/java
  14. tcp 0 0 0.0.0.0:12200 0.0.0.0:* LISTEN 1913/java
  15. tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1766/php-fpm
  16. tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 18774/java
  17. tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 18774/java
  18. tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2108/nginx
  19. tcp 0 0 172.31.195.1:57890 140.205.140.205:80 ESTABLISHED 19072/AliYunDun
  20. tcp 0 0 127.0.0.1:31000 127.0.0.1:32000 ESTABLISHED 1144/java
  21. tcp 0 2804 172.31.195.1:22 183.6.179.98:2048 ESTABLISHED 17606/sshd
  22. tcp 0 0 127.0.0.1:2181 127.0.0.1:45840 ESTABLISHED 1894/java
  23. tcp 0 0 127.0.0.1:45840 127.0.0.1:2181 ESTABLISHED 1913/java
  24. tcp 0 0 127.0.0.1:32000 127.0.0.1:31000 ESTABLISHED 1142/wrapper
  25. tcp 0 0 :::8989 :::* LISTEN 1803/python
  26. tcp 0 0 :::3306 :::* LISTEN 1680/mysqld
  27. udp 0 0 0.0.0.0:33848 0.0.0.0:* 18774/java
  28. udp 0 0 0.0.0.0:68 0.0.0.0:* 942/dhclient
  29. udp 0 0 172.31.195.1:123 0.0.0.0:* 1443/ntpd
  30. udp 0 0 127.0.0.1:123 0.0.0.0:* 1443/ntpd
  31. udp 0 0 0.0.0.0:123 0.0.0.0:* 1443/ntpd
  32. udp 0 0 0.0.0.0:34999 0.0.0.0:* 1803/python
  33. udp 0 0 0.0.0.0:5353 0.0.0.0:* 18774/java
  34. udp 0 0 :::123 :::* 1443/ntpd
  35. udp 0 0 :::8989 :::* 1803/python
  36. Active UNIX domain sockets (servers and established)
  37. Proto RefCnt Flags Type State I-Node PID/Program name Path
  38. unix 2 [ ACC ] STREAM LISTENING 20736497 19072/AliYunDun /tmp/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
  39. unix 2 [ ACC ] STREAM LISTENING 11161 1/init @/com/ubuntu/upstart
  40. unix 2 [ ] DGRAM 11542 367/udevd @/org/kernel/udev/udevd
  41. unix 5 [ ] DGRAM 12729 1021/rsyslogd /dev/log
  42. unix 2 [ ACC ] STREAM LISTENING 9784 154/plymouthd @/ply-boot-protocol@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  43. unix 2 [ ACC ] STREAM LISTENING 14744 1680/mysqld /var/lib/mysql/mysql.sock
  44. unix 2 [ ACC ] STREAM LISTENING 20736498 19072/AliYunDun /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
  45. unix 3 [ ] STREAM CONNECTED 14909 1766/php-fpm
  46. unix 2 [ ] STREAM CONNECTED 4213164 18774/java
  47. unix 3 [ ] STREAM CONNECTED 17926 2108/nginx
  48. unix 2 [ ] DGRAM 10537908 999/auditd
  49. unix 3 [ ] STREAM CONNECTED 17927 2108/nginx
  50. unix 3 [ ] STREAM CONNECTED 20736493 19072/AliYunDun
  51. unix 3 [ ] STREAM CONNECTED 20736494 19072/AliYunDun
  52. unix 3 [ ] STREAM CONNECTED 20736495 19072/AliYunDun
  53. unix 2 [ ] DGRAM 14270 1443/ntpd
  54. unix 2 [ ] STREAM CONNECTED 4213151 18774/java
  55. unix 2 [ ] STREAM CONNECTED 13699 1144/java
  56. unix 3 [ ] DGRAM 11556 367/udevd
  57. unix 3 [ ] STREAM CONNECTED 14910 1766/php-fpm
  58. unix 2 [ ] STREAM CONNECTED 15663 1894/java
  59. unix 3 [ ] STREAM CONNECTED 12689 999/auditd
  60. unix 2 [ ] STREAM CONNECTED 15669 1894/java
  61. unix 2 [ ] STREAM CONNECTED 12920 1144/java
  62. unix 3 [ ] STREAM CONNECTED 20736496 19072/AliYunDun
  63. unix 3 [ ] STREAM CONNECTED 12688 999/auditd
  64. unix 3 [ ] DGRAM 11555 367/udevd
  65. unix 2 [ ] STREAM CONNECTED 15759 1913/java
  66. unix 2 [ ] STREAM CONNECTED 16175 1913/java
  67. unix 2 [ ] DGRAM 25634203 17606/sshd

ps -ef|grep java 和 netstat -apn命令:有上可知我们的tomcat端口是8080

4,访问jenkins界面:

在浏览器上输入ip地址http://47.52.41.245:8080/jenkins(http://ip:端口/jenkins)即可访问,如图:

image

首次进入jenkins如要输入密码,密码位置:/root/.jenkins/secrets/initialAdminPassword

通过cat查看密码,复制粘贴进来,点击继续,进入插件选择安装界面,点击安装默认插件,然后进入插件安装界面,安装完插件之后创建账号然后登录;

如果插件安装失败可以去镜像地址下载插件,然后手动上传
镜像地址:https://mirrors.tuna.tsinghua.edu.cn/jenkins/

发表评论

表情:
评论列表 (有 0 条评论,299人围观)

还没有评论,来说两句吧...

相关阅读