1. 安裝JDK【java8】 1.1. 軟體安裝 1.2. 環境變數 2. 安裝jenkins 2.1. 軟體安裝 2.2. 啟動jenkins 解決方法修改 jenkins 啟動腳本 再次報錯修改 重啟Jenkins服務 3. 首次訪問Jenkins 根據頁面提示找密碼,輸入即可 離線問題 參考 ...
1. 安裝JDK【java8】
1.1. 軟體安裝
1 [yun@mini05 software]# pwd 2 /app/software 3 [yun@mini05 software]# tar xf jdk1.8.0_112.tar.gz 4 [yun@mini05 software]# ll 5 total 201392 6 drwxr-xr-x 8 10 143 4096 Dec 20 13:27 jdk1.8.0_112 7 -rw-r--r-- 1 root root 189815615 Mar 12 16:47 jdk1.8.0_112.tar.gz 8 [yun@mini05 software]# mv jdk1.8.0_112/ /app/ 9 [yun@mini05 software]# cd /app/ 10 [yun@mini05 app]# ll 11 total 8 12 drwxr-xr-x 8 10 143 4096 Dec 20 13:27 jdk1.8.0_112 13 [yun@mini05 app]# ln -s jdk1.8.0_112/ jdk 14 [yun@mini05 app]# ll 15 total 8 16 lrwxrwxrwx 1 root root 13 May 16 23:19 jdk -> jdk1.8.0_112/ 17 drwxr-xr-x 8 10 143 4096 Dec 20 13:27 jdk1.8.0_112
1.2. 環境變數
1 [root@mini05 ~]$ pwd 2 /app 3 [root@mini05 ~]$ ll -d jdk* 4 lrwxrwxrwx 1 yun yun 11 Mar 15 14:58 jdk -> jdk1.8.0_112 5 drwxr-xr-x 8 yun yun 4096 Dec 20 13:27 jdk1.8.0_112 6 [root@mini05 profile.d]$ pwd 7 /etc/profile.d 8 [root@mini05 profile.d]$ cat jdk.sh # java環境變數 9 export JAVA_HOME=/app/jdk 10 export JRE_HOME=/app/jdk/jre 11 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH 12 export PATH=$JAVA_HOME/bin:$PATH 13 14 [root@mini05 profile.d]# source /etc/profile 15 [root@mini05 profile.d]$ java -version 16 java version "1.8.0_112" 17 Java(TM) SE Runtime Environment (build 1.8.0_112-b15) 18 Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
2. 安裝jenkins
2.1. 軟體安裝
1 [root@mini05 ~]# cd /etc/yum.repos.d/ 2 [root@mini05 yum.repos.d]# wget http://pkg.jenkins.io/redhat/jenkins.repo 3 [root@mini05 yum.repos.d]# rpm --import http://pkg.jenkins.io/redhat/jenkins.io.key 4 [root@mini05 yum.repos.d]# yum install -y jenkins
2.2. 啟動jenkins
1 [root@mini05 ~]# systemctl start jenkins 2 Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xe" for details. 3 [root@mini05 ~]# systemctl status jenkins.service # 查看Jenkins狀態【因為有問題】 4 ● jenkins.service - LSB: Jenkins Automation Server 5 Loaded: loaded (/etc/rc.d/init.d/jenkins; bad; vendor preset: disabled) 6 Active: failed (Result: exit-code) since Sun 2018-10-07 10:28:30 CST; 5s ago 7 Docs: man:systemd-sysv-generator(8) 8 Process: 2483 ExecStart=/etc/rc.d/init.d/jenkins start (code=exited, status=1/FAILURE) 9 10 Oct 07 10:28:30 mini05 systemd[1]: Starting LSB: Jenkins Automation Server... 11 Oct 07 10:28:30 mini05 runuser[2488]: pam_unix(runuser:session): session opened for user jenkins by (uid=0) 12 Oct 07 10:28:30 mini05 jenkins[2483]: Starting Jenkins bash: /usr/bin/java: No such file or directory 13 Oct 07 10:28:30 mini05 runuser[2488]: pam_unix(runuser:session): session closed for user jenkins 14 Oct 07 10:28:30 mini05 jenkins[2483]: [FAILED] 15 Oct 07 10:28:30 mini05 systemd[1]: jenkins.service: control process exited, code=exited status=1 16 Oct 07 10:28:30 mini05 systemd[1]: Failed to start LSB: Jenkins Automation Server. 17 Oct 07 10:28:30 mini05 systemd[1]: Unit jenkins.service entered failed state. 18 Oct 07 10:28:30 mini05 systemd[1]: jenkins.service failed.
解決方法修改 jenkins 啟動腳本
1 [root@mini05 ~]# vim /etc/rc.d/init.d/jenkins 2 # 添加了 /app/jdk/bin/java 這樣信息 3 ……………… 4 candidates=" 5 /etc/alternatives/java 6 /usr/lib/jvm/java-1.8.0/bin/java 7 /usr/lib/jvm/jre-1.8.0/bin/java 8 /usr/lib/jvm/java-1.7.0/bin/java 9 /usr/lib/jvm/jre-1.7.0/bin/java 10 /usr/bin/java 11 /app/jdk/bin/java 12 " 13 ………………
再次報錯修改
1 [root@mini05 ~]# systemctl start jenkins 2 Warning: jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units. 3 [root@mini05 ~]# systemctl daemon-reload # 執行該命令
重啟Jenkins服務
1 [root@mini05 ~]# systemctl stop jenkins 2 [root@mini05 ~]# systemctl start jenkins
3. 首次訪問Jenkins
1 http://10.0.0.15
根據頁面提示找密碼,輸入即可
離線問題
說明:在網上找了很多文章去解決該離線問題,但是最後都沒有解決。所以只能進入頁面後再手動安裝常用插件。
創建用戶
Jenkins URL
完畢