【问题标题】:Jenkins Master vs Slave Capacity PlanningJenkins Master 与 Slave 容量规划
【发布时间】:2018-06-04 06:04:16
【问题描述】:

背景

谁能提供一些关于 Jenkins master 在容量规划方面的确切职责的见解。

我目前设置了一个主从设备,其中主设备是功能要弱得多的 EC2 t2.micro,但从设备是 t2.medium。

master 时不时会死掉,并且会出现与内存不足错误相关的错误,并且在签出项目时无法分配内存。 Jenkins 已经配置了-Xmx768m。

我已经验证构建是绑定到从节点而不是主节点。主服务器配置了 0 个执行程序,作业显示为在从属服务器上运行(1 个执行程序)。

示例错误

这就是一个例子

 ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/xyz.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:825)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1092)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1123)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
    at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:130)
    at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:120)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:262)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:421)
Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress https://github.com/xyz.git +refs/pull/16/head:refs/remotes/origin/PR-16 +refs/heads/develop:refs/remotes/origin/develop" returned status code 128:
stdout: 
stderr: error: cannot fork() for fetch-pack: Cannot allocate memory

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1990)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1709)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:400)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:823)
    ... 8 more

我的问题

从资源利用的角度来看,主服务器在此设置中的作用是什么?我会假设它是检查项目和建筑的奴隶(而不是主人)。 - 这就是为什么我在内存、CPU、磁盘容量和 IOPS 方面为从站分配更多资源的原因。

除了集中式插件配置之外,除了通过 SSH 在从属设备上启动代理之外,我没想到主服务器会发挥太多作用(从内存/CPU 的角度来看,我并不认为这是一项密集的工作)。

不过,在短期内,我计划将主服务器升级到更强大的 EC2 实例类型 - 最好了解更多有关主服务器真正需要的信息,以确保我正确规划容量而不是不必要地预置太多太多了。

【问题讨论】:

    标签: jenkins jenkins-slave


    【解决方案1】:

    如果您在构建日志中遇到此错误,并且您已编写脚本以在从属服务器上运行构建,方法是请求节点标记或将主服务器上的执行程序数量减少到 0,那么签出将发生在构建代理中。

    如果是这样,那么内存不足的不是你的主人,而是你的奴隶。

    我会尝试增加slave.jar 的堆大小。你如何做到这一点将取决于how you're firing up the slaves。

    来自 Jenkins 文档中的 this bit,您会看到它是这样写的:

    这些 Windows 服务的 JVM 启动参数分别由 XML 文件 jenkins.xml 和 jenkins-slave.xml 控制。这些文件可以分别在 $JENKINS_HOME 和从属根目录中找到,在您将它们安装为 Windows 服务之后。文件格式应该是不言自明的。调整参数例如给 JVM 更大的内存。

    但是,如果您使用java -jar slave.jar 从命令行启动它们,那么您应该在此处使用Xmx 参数。也许您运行代理的盒子确实有足够的可用内存,但 Jenkins 代理只是没有使用它。

    另外,here's Jenkins wiki 中的一个非常有趣的页面,介绍了如何调整主服务器和从服务器的大小。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 2014-12-17
      • 2017-03-24
      • 2016-04-17
      • 2012-09-26
      相关资源
      最近更新 更多