ElasticSearch(es) 如何远程调用?

es默认本地调用,只能用localhost和127.0.0.1访问,如果远程调用则会报错拒绝访问。

解决方法

1. 修改ES的配置文件,进入es安装目录中config目录中修改elasticsearch.yml

vim elasticsearch.yml

2. 修改network.host

修改网络配置
#network.host: 192.168.0.1
改为:
network.host: 0.0.0.0

改成0.0.0.0或者你的机器的ip地址。

如果重启报错

1. 报错:max file descriptors [4096] for elasticsearch process is too low,increase to at least [65536]

2. 报错:max number of threads [3836] for user [xxx] is too low, increase to at least [4096]

3. 报错:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

4. 报错:controller process has stopped - no new native processes can be started

需要修改/config/elasticsearch.yml下cluster.initial_master_nodes,改为cluster.initial_master_nodes: [“node-1”]即可。

这样es就可以远程调用了

版权声明:本文为JAVASCHOOL原创文章,未经本站允许不得转载。