使用IP无法连接本地虚拟机上的elasticsearch:curl: (7) Failed connect to 192.168.xxx.xxx:9200 Connection refused
1.问题
我在本地,通过VM安装Centos之后。安装es正常启动后,通过在虚拟机控制台输入
curl 'http://127.0.0.1:9200/?pretty/'
可以正常访问es!
但是,我在本地机器上Window系统访问,通过虚拟机的IP访问,却提示:
curl: (7) Failed connect to 192.168.xxx.xxx:9200; Connection refused
2.解决
原因是需要修改es的配置文件,es文件目录/config/elasticsearch.yml,修改如图地方。将注释掉的network.host 改为自己虚拟机的IP地址。如图:
如此,再启动便可以访问了!我在本地window再通过head插件访问,便可以了!
(head插件下载地址:https://download.****.net/download/yy339452689/12492563)
3.elasticsearch启动异常插曲
我在上述设置完成之后,重新启动es,其实并没有启动成功。通过控制台启动es,报如下错误:
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535][2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[5]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
报错问题可参考:https://blog.****.net/happyzxs/article/details/89156068
我使用上述链接完美解决!