前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >大数据ELK Stack(四):Elasticsearch 集群部署所遇的坑

大数据ELK Stack(四):Elasticsearch 集群部署所遇的坑

原创
作者头像
zjiekou
发布2022-09-18 20:25:12
4110
发布2022-09-18 20:25:12
举报
文章被收录于专栏:大数据zjiekou大数据zjiekou

现象一

ES使用root用户安装报错如下

Caused by: java.lang.RuntimeException: can not run elasticsearch as root

代码语言:javascript
复制
[root@localhost elasticsearch-7.14.2]# ./bin/elasticsearch
[2022-09-18T16:40:41,166][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [localhost.localdomain] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.14.2.jar:7.14.2]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.14.2.jar:7.14.2]
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75) ~[elasticsearch-7.14.2.jar:7.14.2]
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116) ~[elasticsearch-cli-7.14.2.jar:7.14.2]
        at org.elasticsearch.cli.Command.main(Command.java:79) ~[elasticsearch-cli-7.14.2.jar:7.14.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.14.2.jar:7.14.2]
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81) ~[elasticsearch-7.14.2.jar:7.14.2]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-7.14.2.jar:7.14.2]
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-7.14.2.jar:7.14.2]
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:399) ~[elasticsearch-7.14.2.jar:7.14.2]
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.14.2.jar:7.14.2]
        ... 6 more
uncaught exception in thread [main]
java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:399)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:75)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:116)
        at org.elasticsearch.cli.Command.main(Command.java:79)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:81)
For complete error details, refer to the log at /opt/ES/elasticsearch-7.14.2/logs/elasticsearch.log

解决方法

ES官方为了安全起见,禁止启用Root启动ES服务,因此我们需要进行普通用户的创建,才能正常启动ES服务。所以我们需要新建一个普通用户,并将ES安装目录授权给刚新建的用户。

代码语言:javascript
复制
[root@localhost ES]# useradd Elastic
[root@localhost ES]# chown -R Elastic:Elastic /opt/ES/elasticsearch-7.14.2

现象二

因为 es 不允许使用root用户安装,在使用新建的es用户安装的时候报错如下,

max file descriptors 4096 for elasticsearch process is too low, increase to at least 65535

代码语言:javascript
复制
[2022-09-18T16:58:23,719][INFO ][o.e.t.TransportService   ] [localhost.localdomain] publish_address {192.168.239.134:9300}, bound_addresses {192.168.239.134:9300}
[2022-09-18T16:58:23,805][INFO ][o.e.b.BootstrapChecks    ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed. You must address the points described in the following [2] lines before starting Elasticsearch.
bootstrap check failure [1] of [2]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
bootstrap check failure [2] of [2]: 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
ERROR: Elasticsearch did not exit normally - check the logs at /opt/ES/elasticsearch-7.14.2/logs/elasticsearch.log

解决办法

将当前用户的软硬限制调大。找到文件 /etc/security/limits.conf,编辑,在文件的最后追加如下配置:

文件描述符
文件描述符

现象三

默认发现设置不适合生产使用;必须至少配置一个discovery.seed_hosts、discovery.seed_providers、cluster.initial_master_nodes

代码语言:javascript
复制
[2022-09-18T17:23:09,988][INFO ][o.e.t.TransportService   ] [localhost.localdomain] publish_address {192.168.239.134:9300}, bound_addresses {192.168.239.134:9300}
[2022-09-18T17:23:10,086][INFO ][o.e.b.BootstrapChecks    ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [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
ERROR: Elasticsearch did not exit normally - check the logs at /opt/ES/elasticsearch-7.14.2/logs/elasticsearch.log

解决办法

修改elasticsearch.yml将discovery.seed_hosts: "node-1"改为主机名

代码语言:javascript
复制
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.seed_hosts: ["node-1"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 现象一
    • 解决方法
    • 现象二
      • 解决办法
      • 现象三
        • 解决办法
        相关产品与服务
        Elasticsearch Service
        腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档