centos7.2 安装jenkins2.274
作者:互联网
1. jenkins清华源地址 传送门
https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.274-1.1.noarch.rpm
2. 安装
yum install -y https://mirrors.tuna.tsinghua.edu.cn/jenkins/redhat/jenkins-2.274-1.1.noarch.rpm
安装完结果
Dependencies Resolved ================================================================================================================================================================================================================= Package Arch Version Repository Size ================================================================================================================================================================================================================= Installing: jenkins noarch 2.274-1.1 /jenkins-2.274-1.1.noarch 68 M Transaction Summary ================================================================================================================================================================================================================= Install 1 Package Total size: 68 M Installed size: 68 M Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : jenkins-2.274-1.1.noarch 1/1 Verifying : jenkins-2.274-1.1.noarch 1/1 Installed: jenkins.noarch 0:2.274-1.1 Complete!
3. 修改jenkins配置
vi /etc/sysconfig/jenkins
修改内容JENKINS_USER 为root, JENKINS_PORT改为80 :
## Type: string ## Default: "jenkins" ## ServiceRestart: jenkins # # Unix user account that runs the Jenkins daemon # Be careful when you change this, as you need to update # permissions of $JENKINS_HOME and /var/log/jenkins. # JENKINS_USER="root" ## Type: integer(0:65535) ## Default: 8080 ## ServiceRestart: jenkins # # Port Jenkins is listening on. # Set to -1 to disable # JENKINS_PORT="80"
4. 重启服务
systemctl restart jenkins
5. 修改jenkins的java路径配置
vi /etc/init.d/jenkins
# Search usable Java as /usr/bin/java might not point to minimal version required by Jenkins.
# see http://www.nabble.com/guinea-pigs-wanted-----Hudson-RPM-for-RedHat-Linux-td25673707.html
candidates="
/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-11.0/bin/java
/usr/lib/jvm/jre-11.0/bin/java
/usr/lib/jvm/java-11-openjdk-amd64
/usr/bin/java
"
修改内容:
candidates=" /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-11.0/bin/java /usr/lib/jvm/jre-11.0/bin/java /usr/lib/jvm/java-11-openjdk-amd64 /usr/bin/java /root/soft/jdk1.8.0_261/bin/java "
6.重启服务
[root@jenkins-node ~]# systemctl daemon-reload [root@jenkins-node ~]# systemctl restart jenkins
7. 此时/var/lib/jenkins/ 目录下内容
[root@jenkins-node jenkins]# ll total 36 -rw-r--r--. 1 root root 1655 Jan 8 05:56 config.xml -rw-r--r--. 1 root root 58 Jan 8 05:55 failed-boot-attempts.txt -rw-r--r--. 1 root root 156 Jan 8 05:56 hudson.model.UpdateCenter.xml -rw-------. 1 root root 1712 Jan 8 05:56 identity.key.enc -rw-r--r--. 1 root root 5 Jan 8 05:56 jenkins.install.UpgradeWizard.state -rw-r--r--. 1 root root 171 Jan 8 05:56 jenkins.telemetry.Correlator.xml drwxr-xr-x. 2 root root 6 Jan 8 05:56 jobs drwxr-xr-x. 3 root root 19 Jan 8 05:56 logs -rw-r--r--. 1 root root 907 Jan 8 05:56 nodeMonitors.xml drwxr-xr-x. 2 root root 6 Jan 8 05:56 nodes drwxr-xr-x. 2 root root 6 Jan 8 05:56 plugins -rw-r--r--. 1 root root 129 Jan 8 05:56 queue.xml.bak -rw-r--r--. 1 root root 64 Jan 8 05:56 secret.key -rw-r--r--. 1 root root 0 Jan 8 05:56 secret.key.not-so-secret drwx------. 4 root root 265 Jan 8 05:56 secrets drwxr-xr-x. 2 root root 24 Jan 8 05:56 userContent drwxr-xr-x. 3 root root 56 Jan 8 05:56 users
8. 浏览器中访问jenkins服务IP+端口号
http://10.0.0.200/
出现页面
此时/var/lib/jenkins/ 目录下内容 多了updates目录
[root@jenkins-node jenkins]# ll total 32 -rw-r--r--. 1 root root 1638 Jan 8 05:59 config.xml -rw-r--r--. 1 root root 156 Jan 8 05:56 hudson.model.UpdateCenter.xml -rw-------. 1 root root 1712 Jan 8 05:56 identity.key.enc -rw-r--r--. 1 root root 5 Jan 8 05:56 jenkins.install.UpgradeWizard.state -rw-r--r--. 1 root root 171 Jan 8 05:56 jenkins.telemetry.Correlator.xml drwxr-xr-x. 2 root root 6 Jan 8 05:56 jobs drwxr-xr-x. 3 root root 19 Jan 8 05:56 logs -rw-r--r--. 1 root root 907 Jan 8 05:56 nodeMonitors.xml drwxr-xr-x. 2 root root 6 Jan 8 05:56 nodes drwxr-xr-x. 2 root root 6 Jan 8 05:56 plugins -rw-r--r--. 1 root root 129 Jan 8 05:56 queue.xml.bak -rw-r--r--. 1 root root 64 Jan 8 05:56 secret.key -rw-r--r--. 1 root root 0 Jan 8 05:56 secret.key.not-so-secret drwx------. 4 root root 265 Jan 8 05:56 secrets drwxr-xr-x. 2 root root 67 Jan 8 05:59 updates drwxr-xr-x. 2 root root 24 Jan 8 05:56 userContent drwxr-xr-x. 3 root root 56 Jan 8 05:56 users
9. 国内镜像加速
9.1 修改hudson.model.UpdateCenter.xml 为清华源
vi /var/lib/jenkins/hudson.model.UpdateCenter.xml
<?xml version='1.1' encoding='UTF-8'?>
<sites>
<site>
<id>default</id>
<url>https://updates.jenkins.io/update-center.json</url>
</site>
</sites>
修改内容为:
<?xml version='1.1' encoding='UTF-8'?> <sites> <site> <id>default</id> <url>https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json</url> </site> </sites>
重启
[root@jenkins-node ~]# systemctl restart jenkins
9.2 修改/var/lib/jenkins/updates/default.json
cd /var/lib/jenkins/updates/
使用sed命令替换 文件内容中的搜索为百度 ,下载服务方为清华源
sed -i 's#https://updates.jenkins.io/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
重启
[root@jenkins-node ~]# systemctl restart jenkins
10. 获取初始登录密码,输入密码,登录系统
cat /var/lib/jenkins/secrets/initialAdminPassword
选择推荐安装插件 等待安装完即可。
附踩坑记录
1. [jenkins] 启动错误 Failed to start LSB
2. 如果安装完访问不了,查看下防火墙
[root@jenkins-node jenkins]# systemctl status firewalld.service [root@jenkins-node jenkins]# systemctl stop firewalld.service
标签:java,05,安装,56,jenkins2.274,Jan,jenkins,centos7.2,root 来源: https://www.cnblogs.com/datangguott/p/14252346.html