当前位置: 首页 > 面试题库 >

如何修复连接被拒绝并且在Elasticsearch Mongoriver上找不到主错误的方法

裴俊智
2023-03-14
问题内容

启动elasticsearch时遇到此错误

~  elasticsearch -f
getopt: illegal option -- f
[2014-04-22 23:23:27,793][INFO ][node                     ] [Starlight] version[1.0.0], pid[3785], build[a46900e/2014-02-12T16:18:34Z]
[2014-04-22 23:23:27,794][INFO ][node                     ] [Starlight] initializing ...
[2014-04-22 23:23:27,837][INFO ][plugins                  ] [Starlight] loaded [mongodb-river, mapper-attachments], sites [river-mongodb]
[2014-04-22 23:23:29,997][INFO ][node                     ] [Starlight] initialized
[2014-04-22 23:23:29,998][INFO ][node                     ] [Starlight] starting ...
[2014-04-22 23:23:30,077][INFO ][transport                ] [Starlight] bound_address {inet[/127.0.0.1:9300]}, publish_address {inet[/127.0.0.1:9300]}
[2014-04-22 23:23:33,149][INFO ][cluster.service          ] [Starlight] new_master [Starlight][5kL_aPXDQVy-kecgDGY4VA][JOHNs-MacBook-Pro.local][inet[/127.0.0.1:9300]], reason: zen-disco-join (elected_as_master)
[2014-04-22 23:23:33,177][INFO ][discovery                ] [Starlight] elasticsearch_johnkevinmbasco/5kL_aPXDQVy-kecgDGY4VA
[2014-04-22 23:23:33,200][INFO ][http                     ] [Starlight] bound_address {inet[/127.0.0.1:9200]}, publish_address {inet[/127.0.0.1:9200]}
[2014-04-22 23:23:33,880][INFO ][gateway                  ] [Starlight] recovered [11] indices into cluster_state
[2014-04-22 23:23:34,990][INFO ][river.mongodb            ] Parse river settings for mongodb
[2014-04-22 23:23:34,993][INFO ][river.mongodb            ] Server: 127.0.0.1 - 27017
[2014-04-22 23:23:35,020][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] Starting river mongodb
[2014-04-22 23:23:35,031][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] MongoDB River Plugin - version[2.0.0] - hash[a0c23f1] - time[2014-02-23T20:40:05Z]
[2014-04-22 23:23:35,032][INFO ][org.elasticsearch.river.mongodb.MongoDBRiver] starting mongodb stream. options: secondaryreadpreference [false], drop_collection [false], include_collection [], throttlesize [5000], gridfs [false], filter [null], db [testmongo], collection [person], script [null], indexing to [mongoindex]/[person]
Apr 22, 2014 11:23:35 PM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: JOHNs-MacBook-Pro.local/10.209.30.254:27017
java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:382)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:241)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:228)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:431)
    at java.net.Socket.connect(Socket.java:527)
    at com.mongodb.DBPort._open(DBPort.java:223)
    at com.mongodb.DBPort.go(DBPort.java:125)
    at com.mongodb.DBPort.go(DBPort.java:106)
    at com.mongodb.DBPort.findOne(DBPort.java:162)
    at com.mongodb.DBPort.runCommand(DBPort.java:170)
    at com.mongodb.ConnectionStatus$UpdatableNode.update(ConnectionStatus.java:196)
    at com.mongodb.ReplicaSetStatus$UpdatableReplicaSetNode.update(ReplicaSetStatus.java:603)
    at com.mongodb.ReplicaSetStatus$Updater.updateAll(ReplicaSetStatus.java:755)
    at com.mongodb.ReplicaSetStatus$Updater.run(ReplicaSetStatus.java:725)
[2014-04-22 23:23:35,367][INFO ][node                     ] [Starlight] started
[2014-04-22 23:23:35,397][WARN ][org.elasticsearch.river.mongodb.MongoDBRiver] Fail to start river mongodb
com.mongodb.MongoException: can't find a master
    at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:517)
    at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:236)
    at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
    at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
    at com.mongodb.DB.command(DB.java:262)
    at com.mongodb.DB.command(DB.java:244)
    at com.mongodb.DB.command(DB.java:301)
    at com.mongodb.DB.command(DB.java:199)
    at org.elasticsearch.river.mongodb.MongoDBRiver.isMongos(MongoDBRiver.java:264)
    at org.elasticsearch.river.mongodb.MongoDBRiver.start(MongoDBRiver.java:208)
    at org.elasticsearch.river.RiversService.createRiver(RiversService.java:148)
    at org.elasticsearch.river.RiversService$ApplyRivers$2.onResponse(RiversService.java:275)
    at org.elasticsearch.river.RiversService$ApplyRivers$2.onResponse(RiversService.java:269)
    at org.elasticsearch.action.support.TransportAction$ThreadedActionListener$1.run(TransportAction.java:93)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:680)
[2014-04-22 23:23:38,979][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts
[2014-04-22 23:23:39,083][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts
[2014-04-22 23:23:39,204][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts
[2014-04-22 23:23:39,287][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts
[2014-04-22 23:23:39,345][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts
[2014-04-22 23:23:39,356][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts
[2014-04-22 23:23:39,371][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts
[2014-04-22 23:23:39,374][WARN ][river.routing            ] [Starlight] no river _meta document found after 5 attempts

有人知道我在做什么错吗?

这是rs.status()的输出

{
    "set" : "rs0",
    "date" : ISODate("2014-04-22T15:26:33Z"),
    "myState" : 1,
    "members" : [
        {
            "_id" : 0,
            "name" : "JOHNs-MacBook-Pro.local:27017",
            "health" : 1,
            "state" : 1,
            "stateStr" : "PRIMARY",
            "uptime" : 503,
            "optime" : Timestamp(1398179531, 1),
            "optimeDate" : ISODate("2014-04-22T15:12:11Z"),
            "self" : true
        }
    ],
    "ok" : 1
}

ifconfig输出:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
    inet 127.0.0.1 netmask 0xff000000
    inet6 ::1 prefixlen 128
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8823<UP,BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
    ether 54:26:96:d8:3e:57
    media: autoselect (<unknown type>)
    status: inactive
p2p0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 2304
    ether 06:26:96:d8:3e:57
    media: autoselect
    status: inactive
ppp0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
    inet 10.141.75.33 --> 10.64.64.64 netmask 0xff000000

我正在使用MongoDB River插件2.0.0- https://github.com/richardwilly98/elasticsearch-
river-mongodb,Elasticsearch
1.0.0和MongoDB 2.4.9


问题答案:

首先,请注意,您在连接字符串中写入的内容不是驱动程序要连接的内容。对于副本集,URL,例如:

mongodb://hostname/some_db

此处的主机名是“种子”,驱动程序将在其中获取“可用服务器列表”。这是因为副本集通常是可变的。您可以随时在副本集中添加节点或从副本集中删除节点。因此,可用列表总是从种子中获得。
根据您的信息,这里返回一个成员列表:

"name" : "JOHNs-MacBook-Pro.local:27017",

因此,驱动程序稍后尝试连接到JOHNs-MacBook-Pro.local:27017。您需要确保可以从您的客户端计算机上访问名称JOHNs-
MacBook-Pro.local:27017。因此,如果解析为127.0.0.1,您的客户端将永远无法连接到它。



 类似资料: