Igo*_*nov 8 java lucene elasticsearch
我安装了ElasticSearch服务器,我正在运行:
$ ./elasticsearch -f
{0.18.2}[11698]: initializing ...
loaded [], sites []
{0.18.2}[11698]: initialized
{0.18.2}[11698]: starting ...
bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.1.106:9300]}
new_master [Stingray][ocw4qPdmSfWuD9pUxHoN1Q][inet[/192.168.1.106:9300]], reason: zen-disco-join (elected_as_master)
elasticsearch/ocw4qPdmSfWuD9pUxHoN1Q
recovered [0] indices into cluster_state
bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.1.106:9200]}
{0.18.2}[11698]: started
Run Code Online (Sandbox Code Playgroud)
如何配置Java客户端连接到此服务器?我刚才:
node.client=true
Run Code Online (Sandbox Code Playgroud)
但是,在尝试连接后我收到了:
org.elasticsearch.discovery.MasterNotDiscoveredException:
at org.elasticsearch.action.support.master.TransportMasterNodeOperationAction$3.onTimeout(TransportMasterNodeOperationAction.java:162)
Run Code Online (Sandbox Code Playgroud)
如果我将java客户端配置为:
node.data=false
Run Code Online (Sandbox Code Playgroud)
我得到以下日志:
INFO main node:internalInfo:93 - [Stark, Tony] {0.18.2}[13008]: starting ...
INFO main transport:internalInfo:93 - [Stark, Tony] bound_address {inet[/0:0:0:0:0:0:0:0:9301]}, publish_address {inet[/192.168.1.106:9301]}
INFO elasticsearch[Stark, Tony]clusterService#updateTask-pool-13-thread-1 service:internalInfo:93 - [Stark, Tony] new_master [Stark, Tony][WkNn96hgTkWXRnsR0EOZjA][inet[/192.168.1.106:9301]]{data=false}, reason: zen-disco-join (elected_as_master)
Run Code Online (Sandbox Code Playgroud)
据我所知,这意味着这个新节点(应该是客户端节点)使自己成为一个新的主节点.而且我没有记录它已被发现并连接到任何其他节点.
服务器和客户端都在同一台机器上启动.可以从浏览器访问192.168.1.106:9200.
而且我找不到任何有关发现配置的好文档.我可以在哪里阅读有关ElasticSearch配置的更多信息?以及如何配置Java客户端?
imo*_*tov 13
导致此故障的最可能原因是您的计算机上的防火墙阻止了端口54328上的多播发现流量.客户端和主服务器在初始发现期间都在此端口上进行广播,并且它们不会相互回复.这就是为什么当你指定node.client = true时,客户端节点(不能是主节点)因MasterNotDiscoveredException而失败,而没有数据的节点选择自己作为主节点.
我遇到了同样的问题,在配置文件中使用IP号码解决了它.
在/config/elasticsearch.yml中
取消注释并将network.host设置更改为:
network.host: 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
您也可以在ifconfig中将其更改为您的机器IP号.
我遇到过同样的问题.最后,事实证明我遇到了防火墙问题,我的防火墙(在Ubuntu上)阻止了ElasticSearch的端口.我在Ubuntu上使用默认防火墙,ufw.
所以,为了打开端口,我在终端上运行了这些命令:
sudo ufw allow proto tcp to any port 9200:9400
sudo ufw allow proto tcp to any port 54328
Run Code Online (Sandbox Code Playgroud)
我的集群在9200本地运行,我的所有客户都在9300+上打开.所以,我刚为他们打开了9200-9400的范围.54328用于多播广播.
只是为了完成:我也使用了TransportClient,它可以工作,但是我将我的localhost硬编码到了TransportClient将要处理的地址.对于生产代码来说不是一件好事:-)
小智 2
面临同样的问题,节点无法在节点重新启动时选择主节点。
问题在于节点之间的通信。
请确保在您的弹性搜索日志中,节点重新启动是否显示
publish_address {127.0.0.1:9200}
or
publish_address {0.0.0.1:9200}
Run Code Online (Sandbox Code Playgroud)
这意味着当前节点不会将其 IP 地址发布到其他节点,因此即使节点 IP 可能存在于 discovery.zen.ping.unicast.hosts 中,节点也不会识别该节点
解决方案 在elasticsearch.yml 中进行以下更改。添加
network.host: _non_loopback:ipv4_
and restart the node.
Ensure that the bound address now shows the <IP address>:<port no> and not the localhost.
Run Code Online (Sandbox Code Playgroud)
这意味着现在您的节点是可发现的。使其在集群中可发现的第二步是将节点的 IP 地址添加到所有主节点的单播主机列表中,以便每当我们有新的主节点时,该节点就可以被新的主节点发现。
Add the node IP to the discovery.zen.ping.unicast.hosts
list of hosts of all the masters to make it disoverable. A masterpings all the
nodes present in the unicast list.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27015 次 |
| 最近记录: |