目录
一、JDK不匹配
单机es启动的时候遇到一个问题,如下:
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el7_9.x86_64/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
在网上看下了,JDK版本不匹配,好在网上解决方法比较全,顺便扩展下知识。
es 7.X版本内置了JDK,不过可以看下,文件:/elasticsearch安装目录/bin/elasticsearch-env
里面有jdk选择逻辑:
# 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="$JAVA_HOME/bin/java"
JAVA_TYPE="JAVA_HOME"
如果服务器上面的jdk版本不满足es的需要,可以修改这里的逻辑,例如:
# 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="$JAVA_HOME/bin/java"
# JAVA_TYPE="JAVA_HOME"
JAVA="$ES_JAVA_HOME/bin/java"
JAVA_TYPE="ES_JAVA_HOME"
echo "hello world"
可以重启es ./elsaticseatch 即可,
如果要使用服务器上面的jdk,那么记得在 /etc/profile 文件里面指定安装的JDK路径:
export JAVA_HOME=/mnt/obs/jdk/public/jdk/8_151/jdk1.8.0_151
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
JAVA_HOME 后面是你的服务器安装的路径。
二.修改参数
启动还是报错!,出现问题:
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 virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
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 /lxw/elasticsearch/elasticsearch-7.13.2/logs/elasticsearch.log
参考博客:https://www.cnblogs.com/gyli20170901/p/10150183.html 这里的大神这样做的:
执行如下操作:
(1) 编辑 /etc/security/limits.conf,追加以下内容;
这里记得要切换用户, 一般我们会新建一个 es的用户来执行而不是root,所以要切回root,编辑文件用root就完事了
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
此文件修改后需要重新登录用户,才会生效
(2) 编辑 /etc/sysctl.conf,追加以下内容:
vm.max_map_count=262144
保存后,执行:
sysctl -p
但是我的服务器启动还是报错,上述操作解决了:
bootstrap check failure [1] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
还有问题:
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 /lxw/elasticsearch/elasticsearch-7.13.2/logs/elasticsearch.log
参考博客:https://blog.csdn.net/LICAZ1122/article/details/108011551,这里的大神是这样干的:
修改 /config/elasticsearch.yml文件,我的yml开始是这样的:
#
# ------------------------------------ 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: 192.168.0.1
#
# 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: 9200
#
# 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 -----------------------------------
然后我放开了 注释:
#node.name: node-1
变成
node.name: node-1
#cluster.initial_master_nodes: ["node-1", "node-2"]
变成了
cluster.initial_master_nodes: ["node-1"]
重启 到达目录 /es安装目录/bin/ 执行: ./elasticearch
浏览器访问: ip:9200
出现:
说明部署成功了,同事服务器也没显示错误日志。
参考博客:
https://blog.csdn.net/asty9000/article/details/95127448
https://blog.csdn.net/asty9000/article/details/95127448
https://blog.csdn.net/qq_41883461/article/details/112169435
https://www.cnblogs.com/gyli20170901/p/10150183.html
https://blog.csdn.net/LICAZ1122/article/details/108011551