centos7 单机版安装
安装环境
操作系统:centos7
elasticsearch版本:elasticsearch-7.12.0-linux-x86_64
JDK版本:1.8
安装
tip:安装ES前提是已经安装好Java JDK并配置好 环境变量
1、选择自己的解压目录(,将下载下来的包解压
tar -zxvf elasticsearch-7.12.0-linux-x86_64.tar
2、配置文件修改
进入配置目录config
cd /../../elasticsearch-7.12.0/config
对文件进行修改
vim elasticsearch.yml
#
# ---------------------------------- Cluster -----------------------------------
cluster.name: my-application
# ------------------------------------ Node ------------------------------------
node.name: node-1
# ----------------------------------- Paths ------------------------------------
#注意:新建的用户一定需要具有这两个path的权限
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
# ----------------------------------- Memory -----------------------------------
# Lock the memory on startup:
bootstrap.memory_lock: false
# ---------------------------------- Network -----------------------------------
network.host: 自己服务器ip
http.port: 9200
# --------------------------------- Discovery ----------------------------------
discovery.seed_hosts: ["自己服务器ip"]
问题
1、elasticsearch不能使用root启动问题解决,使用root启动会报错:can not run elasticsearch as root
[root@iZbp1bb2egi7w0ueys548pZ bin]# ./elasticsearch
[2021-04-08T09:50:59,387][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] 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:134) ~[elasticsearch-7.12.0.jar:7.12.0]
原因: 为了安全不允许使用root用户启动
解决:elasticsearch之后的都不能使用添加启动参数或者修改配置文件等方法启动了,必须要创建用户
1、创建用户:elasticsearch
adduser elasticsearch
2、创建用户密码,需要输入两次
passwd elasticsearch
3、将对应的文件夹权限赋给该用户
[root@localhost config]# chown -R elasticsearch elasticsearch
[root@localhost config]# chown -R elasticsearch /data/elasticsearch
4、可能遇到其他错误
第一种错误:
ERROR: [1] bootstrap checks failed
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
su 进入root
vim /etc/sysctl.conf
添加参数 vm.max_map_count=262144
参数大小 大于 262144
修改完后执行以下命令
sysctl -p
第二种错误:
ERROR: [1] bootstrap checks failed
[1]: max number of threads [3758] for user [es] is too low, increase to at least [4096]
解决办法:
切换到root用户
vim /etc/security/limits.conf
在末尾添加下面设置(参数值大于4096)
* soft nproc 4096
* hard nproc 4096
第三种错误:
ERROR: [1] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
解决办法
切换到root用户
vim /etc/security/limits.conf
在末尾添加下面设置(参数值大于65535)
* soft nofile 65535
* hard nofile 65535
5、后台启动
sh /opt/soft/Elasticsearch/elasticsearch-7.12.0/bin/elasticsearch -d
##
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_231/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.
warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME
Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/java/jdk1.8.0_231/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.
6、访问
浏览器打开ip:9200
看到这个界面说明Elasticsearch搭建成功