【问题标题】:AWS Beanstalk Worker can't start SQS daemon aws-sqsdAWS Beanstalk Worker 无法启动 SQS 守护程序 aws-sqsd
【发布时间】:2014-07-07 13:44:17
【问题描述】:

我的目标是使用 AWS Beanstalk,创建应用程序环境类型 'Worker' 来处理繁重的负载任务,这个工作人员基于我们的 Rails 应用程序。 我创建 AWS Beanstalk 工作环境: 环境层:Ruby,64 位 Amazon Linux 上的 1.9.3 环境类型:单实例 (我确实尝试过运行 Ruby 2.0 (Puma) 的 64 位 Amazon Linux 2014.03 v1.0.3,但结果相同)

在解决了 GEMS 和数据库连接的所有问题后,我坚持启动“aws-sqs”队列客户端。它应该监听 Queue 并向 Worker 应用程序发出 HTTP 请求。 我已经为这个 Worker 实例的 ENV 变量提供了 AWS_ACCESS_KEY_ID 和 AWS_SECRET_KEY:

$ export | grep AWS
declare -x AWS_ACCESS_KEY_ID="AK...........Q"
declare -x AWS_AUTO_SCALING_HOME="/opt/aws/apitools/as"
declare -x AWS_CLOUDWATCH_HOME="/opt/aws/apitools/mon"
declare -x AWS_ELB_HOME="/opt/aws/apitools/elb"
declare -x AWS_IAM_HOME="/opt/aws/apitools/iam"
declare -x AWS_PATH="/opt/aws"
declare -x AWS_RDS_HOME="/opt/aws/apitools/rds"
declare -x AWS_SECRET_KEY="Hp.....fI"
declare -x EB_CONFIG_SYSTEM_AWSEBAGENTID=""
declare -x EB_CONFIG_SYSTEM_AWSEBREFERRERID=""

这里是日志输出:

2014-05-19T13:58:59Z init: initializing aws-sqsd 1.0 (2013-12-23)
2014-05-19T13:58:59Z start: polling https://sqs.us-east-1.amazonaws.com/201266939336/awseb-e-dq8cqaud2z-stack-AWSEBWorkerQueue-18836XBBHNDUD
2014-05-19T13:58:59Z fatal: AWS::Errors::MissingCredentialsError: 
Missing Credentials.

Unable to find AWS credentials.  You can configure your AWS credentials
a few different ways:

* Call AWS.config with :access_key_id and :secret_access_key

<<<

* On EC2 you can run instances with an IAM instance profile and credentials
  will be auto loaded from the instance metadata service on those
  instances.

* Call AWS.config with :credential_provider.  A credential provider should
  either include AWS::Core::CredentialProviders::Provider or respond to
  the same public methods.

= Ruby on Rails

In a Ruby on Rails application you may also specify your credentials in
the following ways:

* Via a config initializer script using any of the methods mentioned above
  (e.g. RAILS_ROOT/config/initializers/aws-sdk.rb).

* Via a yaml configuration file located at RAILS_ROOT/config/aws.yml.
  This file should be formated like the default RAILS_ROOT/config/database.yml
  file.

我的 Rails 应用程序中还有 config/initializers/aws-sdk.rb 包含以下内容:

AWS.config(
    access_key_id: ENV["AWS_ACCESS_KEY_ID"],
    secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"])

守护进程 aws-sqs 根本没有启动。 我有机会以其他方式配置 aws-sqs 吗?

【问题讨论】:

    标签: ruby-on-rails amazon-web-services amazon-sqs amazon-elastic-beanstalk


    【解决方案1】:

    您用于 Elastic Beanstalk 的实例配置文件可能没有工作线程环境所需的权限。

    http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.iam.roles.aeb.html#AWSHowTo.iam.policies.actions.worker

    您能否确保您的 IAM 实例配置文件具有上面链接中列出的所有权限? (复制如下供参考)

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "QueueAccess",
          "Action": [
            "sqs:ChangeMessageVisibility",
            "sqs:DeleteMessage",
            "sqs:ReceiveMessage"
          ],
          "Effect": "Allow",
          "Resource": "*"
        },
        {
          "Sid": "MetricsAccess",
          "Action": [
            "cloudwatch:PutMetricData"
          ],
          "Effect": "Allow",
          "Resource": "*"
        }
      ]
    }               
    

    【讨论】:

      猜你喜欢
      • 2014-08-02
      • 2015-09-18
      • 1970-01-01
      • 2015-05-26
      • 2018-12-13
      • 2016-04-20
      • 2017-10-01
      • 2016-05-13
      • 2017-11-29
      相关资源
      最近更新 更多