ElasticSearch 启动时异常及其解决方案
问题一:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
问题详情
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方案
# 每个进程最大同时打开文件数太小,可通过下面2个命令查看当前数量 ulimit -Hn ulimit -Sn # 修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效 * soft nofile 65536 * hard nofile 65536
如图
问题二:max number of threads [3818] for user [es] is too low, increase to at least [4096]
问题详情
max number of threads [3818] for user [es] is too low, increase to at least [4096]
解决方案
# 最大线程个数太低。可通过命令查看 ulimit -Hu ulimit -Su # 修改/etc/security/limits.conf文件,增加配置,用户退出后重新登录生效 * soft nproc 4096 * hard nproc 4096
如图
问题三:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
问题详情
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案
# 修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144 # 编辑 vim /etc/sysctl.conf # 配置 vm.max_map_count=262144 # 生效 sysctl -p
如图
问题四:[1]: 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]: 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
解决方案
# 修改 config/elasticsearch.yml 取消注释保留一个节点即可 cluster.initial_master_nodes: ["node-1"]
如图
问题五:Exception in thread “main” java.nio.file.AccessDeniedException: /usr/local/elasticsearch/elasticsearch-6.2.2-1/config/jvm.options
问题详情
Exception in thread "main" java.nio.file.AccessDeniedException: /usr/local/elasticsearch/elasticsearch-6.2.2-1/config/jvm.options
解决方案
# ElasticSearch 不支持使用 root 权限运行,需要创建一个用户并授权 ES 目录给这个用户 # 添加用户 useradd elk # 给用户设置密码 passwd elk # 更改目录所有者 chown -R elk /usr/local/apps/es/ # 目录下文件权限配置 chmod -R 755 /usr/local/apps/es/ # 切换 elk 用户 su elk # 执行 bin/elasticsearch 即可 ./bin/elasticsearch
问题六:本地通过 ip:9200 访问不到 elasticsearch 服务
问题详情
本地通过ip:9200访问不到elasticsearch服务
解决方案
# 修改 config/elasticsearch.yml network.host: 0.0.0.0
如图