elasticsearch 的各种报错以及解决方案

2021.03.04 elasticsearch 后台启动方式

cd /bin 目录下,

./elasticsearch -d

==========================================================

问题一:ElasticsearchException[Failed to create native process factories for Machine(系统找不到指定的文件。)

该错误解决方案

在Elasticsearch/config/elasticsearch.yml加入以下参数:

action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
xpack.security.enabled: false
xpack.monitoring.enabled: true
xpack.graph.enabled: false
xpack.watcher.enabled: false
xpack.ml.enabled: false

==========================================================

问题二: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

如图

elasticsearch 的各种报错以及解决方案_第1张图片

==========================================================

问题三: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

elasticsearch 的各种报错以及解决方案_第2张图片

==========================================================

问题四: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  或 sudo sysctl -p(用第二种是因为之前改完还出现启动不了的情况)

elasticsearch 的各种报错以及解决方案_第3张图片

==========================================================

问题五:[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

==========================================================

问题八:elasticsearch 不能再root用户下启动

问题:

Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
        Refer to the log for complete error details.

解决:

elasticsearch 的各种报错以及解决方案_第4张图片

打印信息:

[2015-12-30 10:15:44,876][WARN ][bootstrap                ] unable to install syscall filter: prctl(PR_GET_NO_NEW_PRIVS): Invalid argument
[2015-12-30 10:15:45,175][INFO ][node                     ] [Grim Hunter] version[2.1.1], pid[26383], build[40e2c53/2015-12-15T13:05:55Z]
[2015-12-30 10:15:45,176][INFO ][node                     ] [Grim Hunter] initializing ...
[2015-12-30 10:15:45,243][INFO ][plugins                  ] [Grim Hunter] loaded [], sites []
[2015-12-30 10:15:45,272][INFO ][env                      ] [Grim Hunter] using [1] data paths, mounts [[/ (/dev/mapper/vg_yong-lv_root)]], net usable_space [33.3gb], net total_space [49gb], spins? [no], types [ext4]
[2015-12-30 10:15:47,318][INFO ][node                     ] [Grim Hunter] initialized
[2015-12-30 10:15:47,318][INFO ][node                     ] [Grim Hunter] starting ...
[2015-12-30 10:15:47,388][INFO ][discovery                ] [Grim Hunter] elasticsearch/fnXUCLOQQBiC1aR7hhB82Q
[2015-12-30 10:15:50,442][INFO ][cluster.service          ] [Grim Hunter] new_master {Grim Hunter}{fnXUCLOQQBiC1aR7hhB82Q}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2015-12-30 10:15:50,491][INFO ][node                     ] [Grim Hunter] started
[2015-12-30 10:15:50,526][INFO ][gateway                  ] [Grim Hunter] recovered [0] indices into cluster_state

ElasticSearch后端启动命令:

./elasticsearch -d
参考:https://my.oschina.net/topeagle/blog/591451?fromerr=mzOr2qzZ

你可能感兴趣的:(Linux,elasticsearch,的各种报错以及解决方案)