mongo连接不上Timed out after 30000

本地连接mongo报错,错误代码为:

Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers= ...............................
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers= ...............................

系统:

  centos7, 64位

  mongo,mongodb-linux-x86_64-rhel70-4.0.10

解压,进入bin,启动

./mongod --dbpath=/data/db/ --config=./mongodb.conf &
./mongod --dbpath=/data/db/ --config=./mongodb.conf &

报错了

为什么呢?

用linux本地连接mongo测试 --》 是ok的,证明服务没有问题

那是什么呢?--》防火墙

[root@localhost data]# systemctl stop firewalld.service #停止firewall
[root@localhost data]# systemctl disable firewalld.service #禁止firewall开机启动
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost data]#
[root@localhost data]# systemctl stop firewalld.service #停止firewall [root@localhost data]# systemctl disable firewalld.service #禁止firewall开机启动 Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@localhost data]#

搞定ok!!!!

本地连接mongo报错,错误代码为: Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches WritableServerSelector. Client view of cluster state is {type=UNKNOWN, servers= ............................... 系统:   centos7, 64位   mongo,mongodb-linux-x86_64-rhel70-4.0.10 解压,进入bin,启动 ./mongod --dbpath=/data/db/ --config=./mongodb.conf & 报错了 为什么呢? 用linux本地连接mongo测试 --》 是ok的,证明服务没有问题 那是什么呢?--》防火墙 [root@localhost data]# systemctl stop firewalld.service #停止firewall [root@localhost data]# systemctl disable firewalld.service #禁止firewall开机启动 Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@localhost data]# 搞定ok!!!!
经验分享 程序员 微信小程序 职场和发展