我们正在尝试从aws docdb
连接到errbit
,但没有好运。这是来自docdb的连接字符串:
mongodb://user:<insertYourPassword>@dev-docdb-cluster.cluster-xxxx.us-east-1.docdb.amazonaws.com:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0
尽管我们能够连接到Atlas数据库,但我们用于Atlas的连接字符串格式如下:
mongodb://user:pass@cluster-shard-00-00-xxx.mongodb.net:27017,cluster-shard-00-01-xxx.mongodb.net:27017,cluster-shard-00-02-xxx.mongodb.net:27017/errbit?ssl=true&replicaSet=Cluster-shard-0&authSource=admin&w=majority
答案 0 :(得分:0)
您需要将config/mongo.rb
文件更改如下:
log_level = Logger.const_get Errbit::Config.log_level.upcase
Mongoid.logger.level = log_level
Mongo::Logger.level = log_level
Mongoid.configure do |config|
uri = if Errbit::Config.mongo_url == 'mongodb://localhost'
"mongodb://localhost/errbit_#{Rails.env}"
else
Errbit::Config.mongo_url
end
config.load_configuration(
clients: {
default: {
uri: uri,
options: { ssl_ca_cert: Rails.root.join('rds-combined-ca-bundle.pem') }
}
},
options: {
use_activesupport_time_zone: true
}
)
end
您会注意到,除了我添加的内容外,这与当前版本完全相同:
options: { ssl_ca_cert: Rails.root.join('rds-combined-ca-bundle.pem') }
这样做对我来说确实有用:)当然,您需要rds-combined-ca-bundle.pem
文件才能出现在Rails根文件夹中。
wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
是的,我必须使用以下代码创建一个docker映像:
FROM errbit/errbit:latest
LABEL maintainer="Tarek N. Elsamni <tarek.samni+stackoverflow@gmail.com>"
WORKDIR /app
RUN wget https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem
COPY ["mongo.rb", "/app/config/"]