【发布时间】:2020-02-07 18:49:22
【问题描述】:
部署到生产环境(通过 gitlab)时出现以下错误:
Mongo::Error::NoServerAvailable: No primary server is available in cluster:
#<Cluster topology=
ReplicaSetNoPrimary[url1:27017,url2:27017,url3:27017,url4:27017,url5:27017,name=mobile01]
servers=[
#<Server address=url1:27017 UNKNOWN>,
#<Server address=url2:27017 UNKNOWN>,
#<Server address=url3:27017 UNKNOWN>,
#<Server address=url4:27017 UNKNOWN>,
#<Server address=url5:27017 UNKNOWN>]> with timeout=30, LT=0.015
我一直试图在 Rails 控制台中本地重现错误,这是我的配置:
ap Mongoid.client(:default).instance_values
{
"srv_records" => nil,
"options" => {
"database" => "mydb",
"auth_source" => "admin",
"retry_reads" => true,
"retry_writes" => true,
"user" => "rp_projects",
"password" => "xxxxxxxxxxxxxxxxx",
"ssl" => true,
"replica_set" => "mobile01",
"connect" => :replica_set,
"platform" => "mongoid-7.0.5"
},
"database" => #<Mongo::Database:0x70156564542240 name=mydb>,
"cluster" => #<Mongo::Cluster:0x70156564540720 servers=[]
topology=
ReplicaSetNoPrimary[url1:27017,url2:27017,url3:27017,url4:27017,url5:27017,
name=mobile01]>
}
服务器在 docker 镜像中运行。我在配置中遗漏了什么吗?我应该在这里寻找什么?
【问题讨论】:
标签: ruby-on-rails docker mongoid