1、描述虚拟机搭建mongo副本集虚拟机的设定的hostname为: centosc。虚拟机IP为 192.168.25.129 搭建三个副本集端口分别为,28017、28018、28019 ,运行mongo副本集报错,报错信息如下:
2024-05-20 10:22:39:235[main]INFO org.apache.coyote.http11.Http11NioProtocol-Starting ProtocolHandler ["http-nio-9118"]
2024-05-20 10:22:39:249[main]INFO o.s.boot.web.embedded.tomcat.TomcatWebServer-Tomcat started on port(s): 9118 (http) with context path ''
2024-05-20 10:22:39:257[main]INFO com.ehai.cluster.mongo.MongoServiceApplication-Started MongoServiceApplication in 2.158 seconds (JVM running for 3.731)
2024-05-20 10:22:40:921[cluster-ClusterId{value='664ab3ee38e17c15063b0852', description='null'}-centosc:28018]INFO org.mongodb.driver.cluster-Exception in monitor thread while connecting to server centosc:28018
com.mongodb.MongoSocketException: centosc
at com.mongodb.ServerAddress.getSocketAddresses(ServerAddress.java:211)
at com.mongodb.internal.connection.SocketStream.initializeSocket(SocketStream.java:75)
at com.mongodb.internal.connection.SocketStream.open(SocketStream.java:65)
at com.mongodb.internal.connection.InternalStreamConnection.open(InternalStreamConnection.java:180)
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.lookupServerDescription(DefaultServerMonitor.java:188)
at com.mongodb.internal.connection.DefaultServerMonitor$ServerMonitorRunnable.run(DefaultServerMonitor.java:152)
at java.lang.Thread.run(Thread.java:745)
2、说明及解决办法
原来没有报错不知道什么原因、可能是mongo集群搭建完一直没有做虚拟机重启可能是。反正出现找个错误原因是实体机无法识别虚拟机hostname名称,在实体机host下添加一行信息:192.168.25.129 即可
既:
标签:centosc,mongo,replicaset,mongodb,虚拟机,java,com From: https://www.cnblogs.com/northeastTycoon/p/18201479