安装elasticsearch,启动的时候有各种报错,总结如下:
报错1
java.lang.RuntimeException: can not run elasticsearch as root
解决方案:使用非root用户启动es即可。
报错2
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案:
切换root用户
vi /etc/sysctl.conf
最后添加一行
vm.max_map_count=655360
执行命令:sysctl -p
报错3
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
解决方案:
在elasticsearch的config目录下,修改elasticsearch.yml配置文件,将下面的配置加入到该配置文件中:
cluster.initial_master_nodes: ["node-1"]
报错4
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
每个进程最大同时打开文件数太小,可通过下面2个命令查看当前数量
ulimit -Hn ulimit -Sn
切换root用户,修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效
* soft nofile 65536 * hard nofile 65536
报错5
max number of threads [3818] for user [es] is too low, increase to at least [4096]
问题同上,最大线程个数太低。修改配置文件/etc/security/limits.conf(和问题4是一个文件),增加配置
* soft nproc 4096 * hard nproc 4096
可通过命令查看
ulimit -Hu ulimit -Su
修改后的文件: