问题
- 本地 curl
curl 127.0.0.1:9200
- 换成 ip 来curl
curl 192.168.xxx.xxx:9200
显示访问不了 ╮(╯▽╰)╭
- 查看端口
netstat -anp | grep 9200
ps: 请注意,这个时候红框显示的是 127.0.0.1,而不是 0.0.0.0,修好了懒得给回去,哈哈哈😜
解决
显然,这是配置设置了只能本地访问的问题,改一下就好,这里引用了另一篇文章来解决:
这篇文章有个不太适合我的地方,就是有些得切换为 elastic 用户操作(es 的启动需要 非root用户,不哟啊问我为什么,我也不知道🤦),有的切换为 root 用户操作 。
- 修改/elasticsearch-x.x.x/configconfig/elasticsearch.yml配置
su root
vim /elasticsearch-x.x.x/configconfig/elasticsearch.yml
- 增加以下内容
network.host: 0.0.0.0
http.port: 9200
- 启动 ES
su elasitc
cd ~
./elasticsearch-x.x.x/bin/elasticsearch
- 按照引用文章的流程,问题不出意料的出现了,虽然我还期待就此完成,(●’◡’●)
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 修改 /etc/security/limits.conf 文件:
su root
vim /etc/security/limits.conf
- 增加配置:
* soft nofile 65536
* hard nofile 65536
* soft noproc 4096
* hard noproc 4096
- 重新启动 ES,但还是躲避不了预见的错误,/(ㄒoㄒ)/~~
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 修改 /etc/sysctl.conf
su root
vim /etc/sysctl.conf
- 添加配置
vm.max_map_count=262144
- 重新启动 ES
- 查看端口
- 外网访问,搞定 o( ̄▽ ̄)ブ