ES 安装常见错误

首先下载 Linux 版本的 ES 安装包,我这里下载的是 ES 的最新版本 elasticsearch-7.14.1 ,下载完成之后,解压缩到指定目录,然后进入安装目录的 bin 目录下面,使用命令 ./elasticsearch 启动 ES

 一、执行命令之后出现如下报错

从日志上提取的错误信息如下

// Linux 上安装的 jdk 版本是 jdk1.8.0_301 ,而启动 elasticsearch-7.14.1 需要的 jdk 版本是 jdk 11
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/mysoft/jdk/jdk1.8.0_301/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

// 不能使用 root 用户去启动 ES
can not run elasticsearch as root

解决问题

1、下载并安装 jdk 11

2、在 /etc/profile 下重新配置 jdk 11 的 JAVA_HOME

# JDK 环境变量信息
# JDK 安装目录
export JAVA_HOME=/usr/local/mysoft/jdk/jdk-11.0.12
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
# MAVEN 环境变量信息 M2_HOME 的值为 Maven 的安装目录
export M2_HOME=/usr/local/mysoft/maven/apache-maven-3.6.0
export M2_PATH=${M2_HOME}/bin

# PATH 环境变量 ( Windows 中是以 ; 进行分割的, Linux 中是以 : 进行分割 ${变量值} 的方式来取值 )
export PATH=${JAVA_PATH}:${M2_PATH}:$PATH

3、使用命令 source /etc/profile 使刚刚配置的环境变量生效

4、使用 su 命令切换用户

 

二、继续使用命令 ./elasticsearch 启动,又出现了如下报错

 从日志上提取的错误信息如下

# 拒绝访问 ES 的配置文件 elasticsearch.yml ,这是由于访问权限不足造成的
nested: AccessDeniedException[/usr/local/mysoft/elasticsearch/elasticsearch-7.14.1/config/elasticsearch.yml];

解决问题:给普通用户授权

// 注意路径最后面的 /
chown -R summer /usr/local/mysoft/elasticsearch/

 

三、修改 elasticsearch 的配置文件,注意 ES 的配置文件是 .yml 格式的,千万要注意 : 后面要有空格

修改完成之后重新启动 ES,接着就报如下错误

 错误 1、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/security/limits.conf,在文件的最后追加如下配置
* soft nofile 65536
* hard nofile 65536
此文件修改后需要重新登录用户,才会生效

错误 2、bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

bootstrap check failure [2] of [3]: 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
执行 /sbin/sysctl -p 命令,使配置立即生效

错误 3、bootstrap check failure [3] of [3]: 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

 

bootstrap check failure [3] of [3]: 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

// 解决方案
在 elasticsearch 的 config 目录下,修改 elasticsearch.yml 配置文件,将下面的配置加入到该配置文件中
cluster.initial_master_nodes: ["node-1"] 

 

切换到 ES 的 bin 目录下,使用 ./elasticsearch 启动服务,启动成功之后,访问 http://192.168.59.132:9200/,如果能看到如下信息,那么 ES 就安装启动成功了

name: 主机名称(可以通过 vim /etc/hostname 修改主机名称)
cluster_name: 集群名称(默认的集群名称就是 elasticsearch)
version.number: ES 版本号
lucene_version: lucene 版本号,ES 底层封装的就是 lucene

 

posted @ 2021-09-26 18:12  变体精灵  阅读(1002)  评论(0编辑  收藏  举报