docker
运行mongo复制集,只能连接主节点,无法连接集群
我运行在一台云服务器上的
mongo的配置是这样的
代码是连接集群的
程序单独访问主机点可以,但是访问不了集群,报错
server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: 192.168.0.127:27017, Type: Unknown, Last error: connection() error occurred during connection handshake: dial tcp 192.168.0.127:27017: i/o timeout }, { Addr: 192.168.0.127:27018, Type: Unknown, Last error: connection() error occurred during connection handshake: dial tcp 192.168.0.127:27018: i/o timeout }, { Addr: 192.168.0.127:27019, Type: Unknown, Last error: connection() error occurred during connection handshake: dial tcp 192.168.0.127:27019: i/o timeout }, ] }
关于mongo的副本集的host我设置过:172.17.0.1、localhost、云主机地址,都无效