Elasticsearch
访问 链接:9200问题
在Centos6.5
虚拟机上安装了ES,只能在虚拟机上通过127.0.0.1:9200来访问,代表安装成功
当在本地通过虚拟机ip+9200访问时出现错误。
解决方案:
在安装路径下的config/elasticsearch.yml文件中,
添加 network.host: 0.0.0.0
表示所有用户可访问
按理说,应该可以访问了,但是
因为本人用的虚拟机是centos6.5,centos6不支持secComp,而elasticsearch5.2.0以上的版本默认bootstrap。system_call_filter为true进行检测,所以导致检测失败,失败后会导致es不能启动。
所以,继续在该文件添加
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
继续运行,发现还是不能启动es,
出现error:
ERROR: [2] bootstrap checks failed
[1]: max number of threads [1024] for user [user] is too low, increase to at least [4096]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
所以还得继续解决:
1.切换到root用户模式
2.到 /etc/security/limits.conf
文件修改资源参数,添加:
* soft nofile 65536
* hard nofile 131072
对于错误【1】,到 /etc/security/limits.d/90-nproc.conf
文件中修改最大线程数
* soft nproc 1024
# 将上面的修改为:
* soft nproc 4096
对于错误【2】,到/etc/sysctl.conf
文件中添加最大虚拟内存,因为默认的太小
添加:
vm.max_map_count=655360
保存后并执行下行命令生效:
sysctl -p
之后,已经完全启动起来了,根据ip地址访问,还是不行,访问超时,这个时候,就要关掉防火墙试试了,
用 service iptables status
查看防火墙是否开关。
centos6.5 (其他版本可能有所不同)永久性开关防火墙:
开启:chkconfig iptables on
关闭:chkconfig iptables off
即时生效,重启后会复原
开启:service iptables start
关闭:service iptables stop
碰到错误 java.lang.IllegalStateException: failed to obtain node locks
可能是因为之前的没有正常关闭,可以通过命令
ps aux | grep 'elastic'
kill -9 进程号 关闭进程
也可以在 config/elasticsearch.yml文件中新增一个配置变量:
node.max_local_storage_nodes: 256
然后,,,就成功了