liunx安装jenkins

本文详细描述了在Linux上安装Jenkins2.319.1的步骤,包括使用rpm命令进行安装,修改默认端口,处理jenkins离线问题,更改更新中心为清华大学镜像,并解决了yum安装时遇到的HTTP301错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

linux安装jenkins【避坑】

如果首次安装,不需卸载否在:

rpm -e jenkins      #卸载
rpm -ql jenkins     #检查是否卸载成功 
find / -iname jenkins | xargs -n 1000 rm -rf    #彻底删除残留文件

下载jenkins的版本:jenkins-2.319.1-1.1.noarch.rpm

jdk版本:jdk8

安装
rpm -ivh jenkins-2.319.1-1.1.noarch.rpm
修改端口
vim /etc/sysconfig/jenkins
重新加载配置文件
systemctl daemon-reload
# 启动
systemctl start jenkins
# 重启
systemctl restart jenkins
# 停止
systemctl stop jenkins

访问ip+端口
输密码
cat /var/lib/jenkins/secrets/initialAdminPassword
如果显示显示离线
将goole改成baidu
vim /var/lib/jenkins/updates/default.json
cd /var/lib/jenkins/updates/
下面的命令要执行,要不然重启还不好使
chattr +i default.json
配置镜像
vim /var/lib/jenkins/hudson.model.UpdateCenter.xml

# 内容如下
<?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@master ~]# yum  -y install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * elrepo: mirrors.tuna.tsinghua.edu.cn
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirror.lzu.edu.cn
http://pkg.jenkins.io/redhat-stable/repodata/repomd.xml: [Errno 14] HTTPS Error 301 - Moved Permanently
Trying other mirror.


 One of the configured repositories failed (Jenkins-stable),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=jenkins ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable jenkins
        or
            subscription-manager repos --disable=jenkins

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=jenkins.skip_if_unavailable=true

failure: repodata/repomd.xml from jenkins: [Errno 256] No more mirrors to try.
http://pkg.jenkins.io/redhat-stable/repodata/repomd.xml: [Errno 14] HTTPS Error 301 - Moved Permanently
[root@master ~]# yum -y install daemonize
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                                                 | 6.4 kB  00:00:00
 * base: mirror.lzu.edu.cn
 * elrepo: mirrors.tuna.tsinghua.edu.cn
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirror.lzu.edu.cn
base                                                                                                                                                 | 3.6 kB  00:00:00
docker-ce-stable                                                                                                                                     | 3.5 kB  00:00:00
elrepo                                                                                                                                               | 3.0 kB  00:00:00
extras                                                                                                                                               | 2.9 kB  00:00:00
jenkins                                                                                                                                              | 2.9 kB  00:00:00
nginx                                                                                                                                                | 2.9 kB  00:00:00
updates                                                                                                                                              | 2.9 kB  00:00:00
jenkins/primary_db                                                                                                                                   |  46 kB  00:00:03
Package daemonize-1.7.7-1.el7.x86_64 already installed and latest version
Nothing to do
[root@master ~]# rpm -ivh jenkins-2.319.1-1.1.noarch.rpm
warning: jenkins-2.319.1-1.1.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 45f2c3d5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jenkins-2.319.1-1.1              ################################# [100%]
[root@master ~]# vi /etc/sysconfig/jenkins
[root@master ~]#  service jenkins start
Starting jenkins (via systemctl):                          [  OK  ]
[root@master ~]# systemctl daemon-reload
[root@master ~]#  service jenkins start
Starting jenkins (via systemctl):                          [  OK  ]
[root@master ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
84063abd5d7a4cd7802187c32f145c62
[root@master ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@master ~]# systemctl stop firewalld.service
[root@master ~]# systemctl disable firewalld.service
[root@master ~]# systemctl daemon-reload
[root@master ~]#  service jenkins start
Starting jenkins (via systemctl):                          [  OK  ]
[root@master ~]#  service jenkins stop
Stopping jenkins (via systemctl):                          [  OK  ]
[root@master ~]# systemctl daemon-reload
[root@master ~]#  service jenkins start
Starting jenkins (via systemctl):                          [  OK  ]
[root@master ~]# cat /var/lib/jenkins/secrets/initialAdminPassword
84063abd5d7a4cd7802187c32f145c62
[root@master ~]# /root/.jenkins/updates
-bash: /root/.jenkins/updates: No such file or directory
[root@master ~]# vim /var/lib/jenkins/updates/default
[root@master ~]# /var/lib/jenkins/updates
-bash: /var/lib/jenkins/updates: Is a directory
[root@master ~]# vim /var/lib/jenkins/updates/default.json
[root@master ~]# chattr +i default.json
chattr: No such file or directory while trying to stat default.json
[root@master ~]# cd /var/lib/jenkins/u
updates/     userContent/ users/
[root@master ~]# cd /var/lib/jenkins/updates/
[root@master updates]# chattr +i default.json
[root@master updates]# vim /var/lib/jenkins/hudson.model.UpdateCenter.xml
[root@master updates]# vim /var/lib/jenkins/updates/default.json
[root@master updates]# cat /var/lib/jenkins/secrets/initialAdminPassword
84063abd5d7a4cd7802187c32f145c62
[root@master updates]# ^C
[root@master updates]# java -version
java version "1.8.0_341"
Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
[root@master updates]# cd /var/lib/jenkins/updates/^C
[root@master updates]# chattr +i default.json^C
[root@master updates]#

大佬勿喷,欢迎提意见建议评论!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值