MongoTimeoutException:在 Trino 中使用 MongoDB 时出错
MongoTimeoutException: Error While Using MongoDB with Trino
我将 mongodb.properties 作为
connector.name=mongodb mongodb.seeds=127.0.0.1:27017 mongodb.credentials=username:password@database
但是当 运行 目录在通过查询后给出错误,如
Query 20210312_110147_00003_zxyd4 failed: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate@469d4507. Client view of cluster state is {type=REPLICA_SET, servers=[{address=hostname:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]
有人可以帮忙吗。我在连接时做错了什么吗?
注意:-我是运行 trino,本地使用单机测试,既是coordinator又是worker,mongodb已开启其他一些服务器,但我正在使用 ssh
将本地主机路由到所需的服务器
它在使用这个JAVA代码时工作,使用这两个mongodb-driver-core-3.7.1-javadoc.jar,mongo-java-driver-3.3.0.jar 要编译的文件和 运行 下面的代码
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import java.util.Collections;
import org.bson.Document;
import java.util.List;
public class MongoSession
{
public static void main(String[] args)
{
ServerAddress seed = new ServerAddress("127.0.0.1:27017");
MongoCredential credential = MongoCredential.createCredential("user", "database", "password".toCharArray());
MongoClient client = new MongoClient(seed, Collections.singletonList(credential), MongoClientOptions.builder().build());
client.getDatabase("database").runCommand(new Document("ping", 1));
for (String name : client.getDatabase("database").listCollectionNames()) {
System.out.println(name);
}
}
}
感谢 MongoDB 社区的快速响应
我将 mongodb.properties 作为
connector.name=mongodb mongodb.seeds=127.0.0.1:27017 mongodb.credentials=username:password@database
但是当 运行 目录在通过查询后给出错误,如
Query 20210312_110147_00003_zxyd4 failed: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate@469d4507. Client view of cluster state is {type=REPLICA_SET, servers=[{address=hostname:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.SocketTimeoutException: connect timed out}}]
有人可以帮忙吗。我在连接时做错了什么吗?
注意:-我是运行 trino,本地使用单机测试,既是coordinator又是worker,mongodb已开启其他一些服务器,但我正在使用 ssh
将本地主机路由到所需的服务器它在使用这个JAVA代码时工作,使用这两个mongodb-driver-core-3.7.1-javadoc.jar,mongo-java-driver-3.3.0.jar 要编译的文件和 运行 下面的代码
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import java.util.Collections;
import org.bson.Document;
import java.util.List;
public class MongoSession
{
public static void main(String[] args)
{
ServerAddress seed = new ServerAddress("127.0.0.1:27017");
MongoCredential credential = MongoCredential.createCredential("user", "database", "password".toCharArray());
MongoClient client = new MongoClient(seed, Collections.singletonList(credential), MongoClientOptions.builder().build());
client.getDatabase("database").runCommand(new Document("ping", 1));
for (String name : client.getDatabase("database").listCollectionNames()) {
System.out.println(name);
}
}
}
感谢 MongoDB 社区的快速响应