ES linux 环境下安装问题集锦

文章详细列举了在安装和配置Elasticsearch过程中遇到的常见问题,包括连接验证、线程限制、SSL证书错误、权限不足以及JDK版本不匹配等。针对这些问题,提供了相应的解决方案,如设置用户名和密码、调整系统限制、生成并配置SSL证书、创建非根用户以及确保使用兼容的JDK版本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1: 所有的环境配置安装完成后验证: curl -u elastic http://127.0.0.1:9400 输入密码;

2:错误1:

解决方法:

配置连接的用户名与密码; 重启ES

错误2:

[1]: max number of threads [2048] for user [es] is too low, increase to at least [4096]

解决方法:

ulimit -a 查看

vim /etc/security/limits.conf

在最后添加:*代表所有用户

# End of file

root soft nofile 65535

root hard nofile 65535

* soft nofile 65535

* hard nofile 131072

错误3:

send message failed [channel: Netty4TcpChannel{localAddress=0.0.0.0/0.0.0.0:56339, remoteAddress=/192.168.88.131:9300}]

javax.net.ssl.SSLException: Received fatal alert: handshake_failure

解决方案:

bin/elasticsearch-certutil ca

bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

需要把生成的文件放入config文件夹,如果没有该文件夹需要创建,上面2个指令输入过后一路回车。

更改 elasticsearch.yml 配置文件

xpack.security.transport.ssl.enabled: true

xpack.security.transport.ssl.verification_mode: certificate

xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12

xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

更改 elasticsearch-7.17.9/jdk/conf/security/java.policy 目录下:

permission java.io.FilePermission "/opt/ruanjian/elasticsearch-7.17.9", "read"; ---安装文件目录

permission java.io.FilePermission "-", "read";

加入到keystore:

bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password

bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password

错误3:

vm.max 空间不足

解决方案

更改后 ,然后 输入 sysctl -p 进行刷新配置

错误4:

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

at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:107) ~[elasticsearch-7.17.9.jar:7.17.9]

解决方法:

创建启动用户:

adduser es

passwd es

su es ./elasticsearch

如果报权限不够,无法实现写入日志,更改文件夹权限即可;

后台启动ES:

su es

./elasticsearch -d

错误5: 安装jdk 版本与ES 要求版本不一致:

解决方法:

更改: elasticsearch-env

# now set the path to java

if [ ! -z "$ES_JAVA_HOME" ]; then

JAVA="$ES_JAVA_HOME/bin/java"

JAVA_TYPE="ES_JAVA_HOME"

elif [ ! -z "$JAVA_HOME" ]; then

# fallback to JAVA_HOME

echo "warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME" >&2

JAVA="$ES_HOME/jdk/bin/java"

JAVA_TYPE="bundled jdk"

else

# use the bundled JDK (default)

if [ "$(uname -s)" = "Darwin" ]; then

# macOS has a different structure

JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"

else

JAVA="$ES_HOME/jdk/bin/java"

fi

JAVA_TYPE="bundled JDK"

fi

elasticsearch.yml 完整配置案例:

# ======================== Elasticsearch Configuration =========================

#

# NOTE: Elasticsearch comes with reasonable defaults for most settings.

# Before you set out to tweak and tune the configuration, make sure you

# understand what are you trying to accomplish and the consequences.

#

# The primary way of configuring a node is via this file. This template lists

# the most important settings you may want to configure for a production cluster.

#

# Please consult the documentation for further information on configuration options:

# https://www.elastic.co/guide/en/elasticsearch/reference/index.html

#

# ---------------------------------- Cluster -----------------------------------

#

# Use a descriptive name for your cluster:

#

#cluster.name: my-application

#

# ------------------------------------ Node ------------------------------------

#

# Use a descriptive name for the node:

#

node.name: node-1

#

# Add custom attributes to the node:

#

#node.attr.rack: r1

#

# ----------------------------------- Paths ------------------------------------

#

# Path to directory where to store the data (separate multiple locations by comma):

#

#path.data: /path/to/data

#

# Path to log files:

#

#path.logs: /path/to/logs

#

# ----------------------------------- Memory -----------------------------------

#

# Lock the memory on startup:

#

#bootstrap.memory_lock: true

#

# Make sure that the heap size is set to about half the memory available

# on the system and that the owner of the process is allowed to use this

# limit.

#

# Elasticsearch performs poorly when the system is swapping the memory.

#

# ---------------------------------- Network -----------------------------------

#

# By default Elasticsearch is only accessible on localhost. Set a different

# address here to expose this node on the network:

#

network.host: 0.0.0.0

#

# By default Elasticsearch listens for HTTP traffic on the first free port it

# finds starting at 9200. Set a specific HTTP port here:

#

http.port: 9400

#

# For more information, consult the network module documentation.

#

# --------------------------------- 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: ["host1", "host2"]

#

# 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.

#

# ---------------------------------- Various -----------------------------------

#

# Require explicit names when deleting indices:

#

#action.destructive_requires_name: true

#

# ---------------------------------- Security ----------------------------------

#

# *** WARNING ***

#

# Elasticsearch security features are not enabled by default.

# These features are free, but require configuration changes to enable them.

# This means that users don’t have to provide credentials and can get full access

# to the cluster. Network connections are also not encrypted.

#

# To protect your data, we strongly encourage you to enable the Elasticsearch security features.

# Refer to the following documentation for instructions.

#

# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html

xpack.security.enabled: true

xpack.license.self_generated.type: basic

xpack.security.transport.ssl.enabled: true

xpack.security.transport.ssl.verification_mode: certificate

xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12

xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

# es head 配置文件

http.cors.enabled: true

http.cors.allow-origin: "*"

#http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

#添加配置

discovery.seed_hosts: ["127.0.0.1"]

cluster.initial_master_nodes: ["node-1"]

ingest.geoip.downloader.enabled: false

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值