背景:
系统: Centos7 、 ES版本:Elasticsearch7.2
问题描述:
ES安装后,发现只能在安装环境通过localhost(localhost:9200)进行访问,外网无法通过IP(http://192.168.48.20:9200/)进行访问。
解决方案:
- 如果是在虚拟机,请先关闭虚拟机防火墙
systemctl stop firewalld.service
- 修改/elasticsearch-7.2.0/configconfig/elasticsearch.yml配置
vim config/elasticsearch.yml
增加以下内容
cluster.initial_master_nodes: ["node-1"]
network.host: 0.0.0.0
http.port: 9200
#是否禁用交换区
bootstrap.memory_lock: false
#因为Centos6起不支持SecComp,而ES默认bootstrap.system_call_filter为true进行检测
bootstrap.system_call_filter: false
- 如果启动后,发现以下错误信息
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
修改/etc/security/limits.conf文件,增加配置:
* soft nofile 65536
* hard nofile 65536
修改配置后,需要用户退出后重新登录才能生效,可以通过命令ulimit -Hn ulimit -Sn查看每个进程最大同时打开文件数太小。
- 如果启动后,发现以下错误信息
max number of threads [3818] for user [es] is too low, increase to at least [4096]
修改/etc/security/limits.conf文件,增加配置:
* soft noproc 4096
* hard noproc 4096
修改配置后,需要用户退出后重新登录才能生效,可以通过命令ulimit -Hu ulimit -Su查看具体配置。
- 如果启动后,发现以下错误 max virtual memory areas vm.max_map_count [65530] is too
low, increase to at least [262144]
需要修改/etc/sysctl.conf
vi /etc/sysctl.conf
#增加配置
vm.max_map_count=262144
修改完毕后,需要执行命令sysctl -p生效
解决完以上问题后,重新启动ES。
./bin/elasticsearch
通过外网IP访问。
http://192.168.48.20:9200/
问题解决。
- 需要注意的是:
1、es不支持root用户启动。
2、修改/etc/security/limits.conf,/etc/sysctl.conf文件需要有相关权限。