gpt4 book ai didi

ruby-on-rails - Mongo::Error::NoServerAvailable:群集中没有主服务器可用

转载 作者:行者123 更新时间:2023-12-02 19:51:56 25 4
gpt4 key购买 nike

部署到生产环境(通过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镜像中运行。我在配置中缺少什么吗?我应该在这里找什么?

最佳答案

  • 确认您能够使用MongoDB Shell(mongo二进制文件)连接到节点。您很可能没有连接。
  • 设置日志级别为debug(https://docs.mongodb.com/mongoid/master/tutorials/mongoid-configuration/#logging),它将告诉您驱动程序在尝试连接到部署时正在做什么。
  • 关于ruby-on-rails - Mongo::Error::NoServerAvailable:群集中没有主服务器可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60119400/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com