【问题标题】:cannot deploy multiple hosts in capistrano无法在 capistrano 中部署多个主机
【发布时间】:2016-11-08 15:37:19
【问题描述】:

我正在使用 capistrano 将 rails 应用程序部署到大约 20 个服务器,当服务器 num ~ 10 时它工作正常,当它增加到 >~ 10 时,它不再工作了

这是错误

cap aborted!
Errno::EPIPE: Broken pipe
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/server_version.rb:44:in `write'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/server_version.rb:44:in `negotiate!'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/server_version.rb:32:in `initialize'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:84:in `new'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:84:in `initialize'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:in `new'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:in `start'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/sshkit-1.11.2/lib/sshkit/backends/connection_pool.rb:59:in `call'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/sshkit-1.11.2/lib/sshkit/backends/connection_pool.rb:59:in `with'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/sshkit-1.11.2/lib/sshkit/backends/netssh.rb:155:in `with_ssh'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/sshkit-1.11.2/lib/sshkit/backends/netssh.rb:49:in `upload!'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/capistrano-3.6.1/lib/capistrano/tasks/git.rake:24:in `block (3 levels) in <top (required)>'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/sshkit-1.11.2/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/sshkit-1.11.2/lib/sshkit/backends/abstract.rb:29:in `run'
/Users/khiem-nguyen/workspace/ruby/nenga-onepiece/cl-chef/deploy/vendor/bundle/ruby/2.3.0/gems/sshkit-1.11.2/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => git:check => git:wrapper
The deploy has failed with an error: Broken pipe
** Invoke deploy:failed (first_time)
** Execute deploy:failed    


** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:    


 DEBUG Uploading /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh 0.0%    

 DEBUG Uploading /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh 0.0%    

  INFO [7c256e12] Running /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh on onepiece-web07    

 DEBUG [7c256e12] Command: ( export RBENV_ROOT="$HOME/.rbenv/bin/rbenv" PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" ; /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh )    

  INFO Uploading /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh 100.0%    

  INFO Uploading /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh 100.0%    

  INFO [846397ba] Finished in 0.065 seconds with exit status 0 (successful).    

  INFO [3e8f8a49] Running /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh on onepiece-web03    

 DEBUG [3e8f8a49] Command: ( export RBENV_ROOT="$HOME/.rbenv/bin/rbenv" PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" ; /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh )    

  INFO [7c256e12] Finished in 0.037 seconds with exit status 0 (successful).    

  INFO [264aa0db] Running /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh on onepiece-web01    

 DEBUG [264aa0db] Command: ( export RBENV_ROOT="$HOME/.rbenv/bin/rbenv" PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" ; /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh )    

  INFO [a8720934] Finished in 0.265 seconds with exit status 0 (successful).    

  INFO [3e8f8a49] Finished in 0.043 seconds with exit status 0 (successful).    

  INFO [264aa0db] Finished in 0.038 seconds with exit status 0 (successful).    

 DEBUG Uploading /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh 0.0%    

  INFO Uploading /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh 100.0%    

  INFO [3d959fa8] Running /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh on onepiece-web02    

 DEBUG [3d959fa8] Command: ( export RBENV_ROOT="$HOME/.rbenv/bin/rbenv" PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH" ; /usr/bin/env chmod 700 /tmp/git-ssh-nenga-onepiece-production-khiem-nguyen.sh )    

  INFO [3d959fa8] Finished in 0.045 seconds with exit status 0 (successful).

我认为有些东西与 ssh max 连接有关???

上限版本:3.6.1 SSH 工具包:1.9.0

【问题讨论】:

  • 我建议按照错误消息中的说明使用--trace 标志重新运行部署。这将提供有关错误发生位置的更多信息。另请发布您使用的 Capistrano 和 SSHKit 版本。
  • 我刚刚在此处添加了跟踪日志和上限版本。请帮忙

标签: ruby-on-rails amazon-web-services deployment capistrano


【解决方案1】:

您可以尝试在 Git 服务器上的 /etc/ssh/sshd_config 中调整 MaxStartups。

默认值为 10:30:60,前 10 个限制。

MaxStartups 指定并发未验证连接的最大数量 连接到 sshd 守护进程。额外的连接将是 在身份验证成功或 LoginGraceTime 之前丢弃 连接过期。默认值为 10。

    Alternatively, random early drop can be enabled by specifying the
    three colon separated values "start:rate:full" (e.g.,
    "10:30:60").  sshd will refuse connection attempts with a proba-
    bility of "rate/100" (30%) if there are currently "start" (10)
    unauthenticated connections.  The probability increases linearly
    and all connection attempts are refused if the number of unau-
    thenticated connections reaches "full" (60).

【讨论】:

    【解决方案2】:

    SSHKit(Capistrano 中的 SSH 层)使用连接池。这意味着它为每个主机维护一个 SSH 连接。如果您在增加主机时看到管道损坏错误,我唯一能想到的可能是防火墙或网关(即 ssh 代理)正在限制同时连接的数量。

    作为一种解决方法,您可以尝试禁用连接池。将以下内容添加到您的deploy.rb

    # Disable connection pool
    SSHKit::Backend::Netssh.pool.idle_timeout = 0
    

    这会使您的部署变慢,但它可能会解决连接错误。

    【讨论】:

    • 我发现原因是git服务器的连接限制。非常感谢
    猜你喜欢
    • 2011-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-31
    • 2012-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多