【问题标题】:Jenkins slave unable to install java via yumJenkins slave 无法通过 yum 安装 java
【发布时间】:2020-07-30 21:50:14
【问题描述】:

我正在关注 this guide 并坚持使用我新创建的云配置来配置我的 Jenkins 从站。

我正在使用公共 Amazon AMI (ami-062f7200baf2fa504) 作为从站。

通过点击Provision via <cloud-name>,我启动了一个新的从站,然后日志如下所示:

INFO: Connected via SSH.
Feb 12, 2020 8:34:00 AM hudson.plugins.ec2.EC2Cloud
INFO: connect fresh as root
Feb 12, 2020 8:34:00 AM hudson.plugins.ec2.EC2Cloud
INFO: Connecting to 172.31.86.97 on port 22, with timeout 10000.
Feb 12, 2020 8:34:00 AM hudson.plugins.ec2.EC2Cloud
INFO: Connected via SSH.
Feb 12, 2020 8:34:00 AM hudson.plugins.ec2.EC2Cloud
INFO: Creating tmp directory (/tmp) if it does not exist
Feb 12, 2020 8:34:00 AM hudson.plugins.ec2.EC2Cloud
INFO: Verifying: java -fullversion
bash: java: command not found
Feb 12, 2020 8:34:00 AM hudson.plugins.ec2.EC2Cloud
INFO: Installing: sudo yum install -y java-1.8.0-openjdk.x86_64
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Existing lock /var/run/yum.pid: another copy is running as pid 3381.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  34 M RSS (325 MB VSZ)
    Started: Wed Feb 12 08:33:58 2020 - 00:09 ago
    State  : Sleeping, pid: 3381
...
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: yum
    Memory :  34 M RSS (325 MB VSZ)
    Started: Wed Feb 12 08:33:58 2020 - 00:35 ago
    State  : Sleeping, pid: 3381

 One of the configured repositories failed (Unknown),
 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=<repoid> ...

     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 <repoid>
        or
            subscription-manager repos --disable=<repoid>

     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=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: amzn2-core/2/x86_64
Could not retrieve mirrorlist http://amazonlinux.us-east-1.amazonaws.com/2/core/latest/x86_64/mirror.list error was
12: Timeout on http://amazonlinux.us-east-1.amazonaws.com/2/core/latest/x86_64/mirror.list: (28, 'Connection timed out after 5000 milliseconds')
Feb 12, 2020 8:35:10 AM hudson.plugins.ec2.EC2Cloud
WARNING: Failed to install: sudo yum install -y java-1.8.0-openjdk.x86_64
Feb 12, 2020 8:35:10 AM hudson.plugins.ec2.EC2Cloud
INFO: Verifying: which scp
/usr/bin/scp
Feb 12, 2020 8:35:10 AM hudson.plugins.ec2.EC2Cloud
INFO: Copying remoting.jar to: /tmp

我的 Jenkins 从站似乎无法使用yum 安装java?这是为什么?我在我的主 Jenkins 实例上安装了 java 就好了......主和从使用相同的 AWS 安全组,可以对任何地方进行出站访问。

在 Chrome 上转到 http://amazonlinux.us-east-1.amazonaws.com/2/core/latest/x86_64/mirror.list 工作正常,下载会自动开始...任何关于为什么会发生此错误的线索表示赞赏!

【问题讨论】:

    标签: amazon-web-services jenkins amazon-ec2


    【解决方案1】:

    我知道这已经有几个月了,您可能已经解决了这个问题,但是对于其他任何人......我最近遇到了一个类似的问题,这让我来到了这个页面。就我而言,jenkins 无法即时安装 java,因为我使用的是基于 debian 的系统,该系统使用 apt 而不是 yum 作为包管理器。它试图通过 yum 安装 java,而我的 worker 上不存在该包管理器。我认为我的解决方案也适用于您的问题,即将 java 烘焙到 ami 本身。我使用了 hashcorp 的打包程序,将 java 和其他依赖项安装到一个新的 ami 中。然后我将 jenkins 工作人员配置为指向我的新 ami 并预装了 java,并且工作人员能够按预期连接和运行。我认为这个解决方案也对你有用,因为如果你正在使用的 ami 中已经安装了 java,那么 yum 包管理器中就不会有竞争条件。这是一篇帮助我理解工作流程的文章: https://medium.com/velotio-perspectives/using-packer-and-terraform-to-setup-jenkins-master-slave-architecture-7bcc4b014874

    【讨论】:

    • 感谢跟进和建议!我真的不记得我做了什么,我想我只是换了一个有 Java 的 AMI...
    • 是的。这是有道理的,也有效。就我而言,我想控制 ami 的内容以添加更多依赖项并加快在工作人员上运行的作业。以前,工作人员使用用户数据块在空的 ami 上安装东西。像这样拉最新,有时会导致随机发生的兼容性问题。这种方法还增加了每项工作的时间和带宽,这可能会变得很昂贵。将 deps 烘焙到 ami 中可以在这些依赖项发生重大更改时隔离回归测试,并减少设置作业所需的时间。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-20
    • 2013-12-09
    • 1970-01-01
    • 2015-07-28
    • 2016-12-26
    • 1970-01-01
    • 2020-10-20
    相关资源
    最近更新 更多