以前我将Elasticsearch安装在自己的机器上,但是每天开关机比较麻烦。
后来买了一台云服务器。
一、外网访问问题
默认情况下,是不支持外网访问,如果你的Elasticsearch安装在其他机器上,你从外网去访问的时候,访问不到,不通。
那么需要修改配置。
进入文件夹:
elasticsearch-7.0.0/config$
修改:elasticsearch.yml
文件
添加
network.host: 0.0.0.0
二、会报错
ERROR: [2] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2]: 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
三、解决方案
1.针对问题1
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
使用sudo用户修改文件:sudo vim /etc/sysctl.conf
添加一行配置:
vm.max_map_count=655360
查看是否生效:
sudo sysctl -p
2.针对问题2
[2]: 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
放开:
cluster.initial_master_nodes: ["node-1", "node-2"]
3.启动验证
进入elasticsearch-7.0.0/bin
执行:
./elasticsearch
启动成功,并且支持任意IP,通过9200端口访问。
4.访问一下
访问OK的。
至此,完美解决