mongodb报错:Exception in thread “main“ com.mongodb.MongoTimeoutException: Timed out after 30000 ms whi
·
Exception in thread "main" 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=[{address=hadoop02:12345, type=UNKNOWN, state=
CONNECTING, exception={com.mongodb.MongoSocketOpenException:
Exception opening socket}, caused by {java.net.SocketTimeoutException:
connect timed out}}]
解决方法:
1.改配置:conf: bind_ip:0.0.0.0
mongod.conf
port = 12345
bind_ip=0.0.0.0
dbpath = data/db
logpath = logs/mongod.log
fork = true
replSet=rs0
连不上navite

之后重启就连上了

2.改依赖包:
<!-- mongodb -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.11.0</version>
</dependency>
3.进入客户端,运行代码就可以了


更多推荐
所有评论(0)