背景
原以为只是yum安装然后启动一下,结果遇到了好几个问题,应了那句老话:纸上得来终觉浅,绝知此事要躬行。
部署
1.安装jdk
关闭防火墙
[root@bogon local]# sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config & setenforce 0&& systemctl disable firewalld.service && systemctl stop firewalld.service
上传jdk1.8包
[root@bogon local]# tar -xvzf /root/jdk-8u191-linux-x64.tar.gz
[root@bogon local]# vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_191
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$HOME/bin:$HOME/.local/bin:$PATH
[root@bogon local]# source /etc/profile
[root@bogon local]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
2.安装maven
[root@bogon ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
[root@bogon ~]# ls
anaconda-ks.cfg apache-maven-3.6.3-bin.tar.gz jdk-8u191-linux-x64.tar.gz
[root@bogon ~]# vi /etc/profile
export MAVEN_HOME=/usr/local/apache-maven-3.6.3
export PATH=${MAVEN_HOME}/bin:$PATH
[root@bogon ~]# source /etc/profile
3.安装jenkins
[root@bogon local]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@bogon local]# rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
[root@bogon local]# yum install jenkins
[root@bogon local]# find / -name java
/etc/pki/ca-trust/extracted/java
/etc/pki/java
/usr/local/jdk1.8.0_191/bin/java
/usr/local/jdk1.8.0_191/jre/bin/java
找到candidates,将jdk下的JAVA命令路径添加到该配置中,注意是JAVA命令路径,不是JDK路径,不添加路径无法启动
[root@bogon local]# vi /etc/rc.d/init.d/jenkins
candidates="
/usr/local/jdk1.8/bin/java
/etc/alternatives/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/bin/java
/usr/local/jdk1.8.0_191/bin/java
"
[root@bogon local]# systemctl restart jenkins
启动jenkins后浏览器访问8080端口
查看默认管理员密码,输入密码
cat /var/lib/jenkins/secrets/initialAdminPassword
输入默认的密码后,就一直停在这里
没有反应,以为是安装问题,重装一次还是这样,最后发现是网络问题,jenkins第一次启动会访问国外插件源来下载插件,而国外源被墙,所以现在需要把国外源换成国内源。
解决
1、在$JENKINS_HOME/hudson.model.UpdateCenter.xml文件中,默认内容如下
<?xml version='1.0' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>http://updates.jenkins-ci.org/update-center.json</url>
</site>
</sites
这个地址在外国的服务器,因为墙的原因,下载初始化界面所需插件不了,就一直处于等待状态
把url改为http://mirror.xmission.com/jenkins/updates/update-center.json
重启jenkins后还是白屏
2.修改connectionCheckUrl
修改方法:
到jenkins的目录(/var/lib/jenkins)下找到update/default.json,把 “connectionCheckUrl”:“http://www.google.com/” 改为 “connectionCheckUrl”:“http://www.baidu.com/”。
再次启动:systemctl restart jenkins 问题解决
Jenkins插件下载加速
#sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json