Elasticsearch 问题:无法连接 AWS elasticsearch 服务
Elasticsearch issue: Cannot connect AWS elasticsearch service
我有一个关于配置 elasticsearch 以将 AWS elasticsearch 服务连接到生产中的 运行 项目的问题。
我的宝石文件:
gem 'searchkick'
gem 'faraday_middleware-aws-signers-v4'
gem 'aws-sdk', '~> 2'
gem "elasticsearch", ">= 1.0.15"
参考:https://github.com/ankane/searchkick
我的 config/initializers/elasticsearch.rb 文件:
require "faraday_middleware/aws_signers_v4"
ENV["ELASTICSEARCH_URL"] = "https://search-eaterybot-u3yjm6cdn3ogkmv3bcdl5j7poy.ap-southeast-1.es.amazonaws.com/"
Searchkick.client = Elasticsearch::Client.new(
url: ENV["ELASTICSEARCH_URL"],
transport_options: {request: {timeout: 10}}
) do |f|
f.request :aws_signers_v4, {credentials: Aws::Credentials.new(Rails.application.secrets.aws_access_key_id, Rails.application.secrets.aws_secret_access_key),
service_name: "es",
region: "ap-southeast-1"
}
end
当我运行"rake searchkick:reindex:all"时,显示错误:
Elasticsearch::Transport::Transport::Errors::Forbidden: [403] {"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'GET\n/_aliases\n\naccept-encoding:gzip;q=1.0,deflate;q=0.6,identity;q=0.3\nhost:search-eaterybot-u3yjm6cdn3ogkmv3bcdl5j7poy.ap-southeast-1.es.amazonaws.com\nx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-date:20160914T095023Z\n\naccept-encoding;host;x-amz-content-sha256;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\nThe String-to-Sign should have been\n'AWS4-HMAC-SHA256\n20160914T095023Z\n20160914/ap-southeast-1/es/aws4_request\n47bc69b4440a13aeac990b8c6c49934f1dcc4693bbbda577bfdeb02e685c507b'\n"}"
任何人都可以帮助我!谢谢!
您应该从 ELASTICSEARCH_URL
中排除尾部斜线
我有一个关于配置 elasticsearch 以将 AWS elasticsearch 服务连接到生产中的 运行 项目的问题。 我的宝石文件:
gem 'searchkick'
gem 'faraday_middleware-aws-signers-v4'
gem 'aws-sdk', '~> 2'
gem "elasticsearch", ">= 1.0.15"
参考:https://github.com/ankane/searchkick
我的 config/initializers/elasticsearch.rb 文件:
require "faraday_middleware/aws_signers_v4"
ENV["ELASTICSEARCH_URL"] = "https://search-eaterybot-u3yjm6cdn3ogkmv3bcdl5j7poy.ap-southeast-1.es.amazonaws.com/"
Searchkick.client = Elasticsearch::Client.new(
url: ENV["ELASTICSEARCH_URL"],
transport_options: {request: {timeout: 10}}
) do |f|
f.request :aws_signers_v4, {credentials: Aws::Credentials.new(Rails.application.secrets.aws_access_key_id, Rails.application.secrets.aws_secret_access_key),
service_name: "es",
region: "ap-southeast-1"
}
end
当我运行"rake searchkick:reindex:all"时,显示错误:
Elasticsearch::Transport::Transport::Errors::Forbidden: [403] {"message":"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.\n\nThe Canonical String for this request should have been\n'GET\n/_aliases\n\naccept-encoding:gzip;q=1.0,deflate;q=0.6,identity;q=0.3\nhost:search-eaterybot-u3yjm6cdn3ogkmv3bcdl5j7poy.ap-southeast-1.es.amazonaws.com\nx-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\nx-amz-date:20160914T095023Z\n\naccept-encoding;host;x-amz-content-sha256;x-amz-date\ne3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n\nThe String-to-Sign should have been\n'AWS4-HMAC-SHA256\n20160914T095023Z\n20160914/ap-southeast-1/es/aws4_request\n47bc69b4440a13aeac990b8c6c49934f1dcc4693bbbda577bfdeb02e685c507b'\n"}"
任何人都可以帮助我!谢谢!
您应该从 ELASTICSEARCH_URL