一、Installation ELK-7.8.1 on CentOS 7.9
地址
- https://github.com/medcl/elasticsearch-analysis-ik
- https://www.elastic.co/guide/en/logstash/7.8/index.html
二、安装准备
JDK 11+:由于elasticsearch 运行需要JDK环境,如果 JDK 低于 1.8 会有一些问题。
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_333/jre] does not meet this requirement
版本需要和elasticserach版本一致,否则会报错
三、安装 ElasticSearch
1 下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.1-linux-x86_64.tar.gz
2 解压
tar -zxvf /opt/software/elastic/elasticsearch-7.8.1-linux-x86_64.tar.gz -C /opt/elastic/
3 进入elasticsearch目录中
目录中自带了jdk
4 修改配置:jvm.options
因为默认的jvm参数-Xms和Xmx都是1G。自己搭的虚拟机可能内存分配不多,会导致启动失败,根据自己的机器情况合理分配。
vim /opt/elastic/elasticsearch-7.8.1/config/jvm.options
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms512m
-Xmx512m
################################################################
5 修改配置:elasticsearch.yml
vim /opt/elastic/elasticsearch-7.8.1/config/elasticsearch.yml
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /opt/elastic/es/data # 数据存放位置
#
# Path to log files:
#
path.logs: /opt/elastic/es/logs # 日志存放位置
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.0. # 开放外网访问
#
# Set a custom port for HTTP:
#
http.port: 9200 # 设置端口
#
# For more information, consult the network module documentation.
五、ES尝试启动
1 require 必须 Java 11
2 运行elasticsearch不能使用root用户启动
查看代码
[root@ecs-65685 bin]# /opt/elastic/elasticsearch-7.8.1/bin/elasticsearch
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_333/jre] does not meet this requirement
future versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_333/jre] does not meet this requirement
[2022-10-11T17:40:42,664][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [ecs-65685] 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:174) ~[elasticsearch-7.8.1.jar:7.8.1]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) ~[elasticsearch-7.8.1.jar:7.8.1]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.8.1.jar:7.8.1]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) ~[elasticsearch-cli-7.8.1.jar:7.8.1]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.8.1.jar:7.8.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) ~[elasticsearch-7.8.1.jar:7.8.1]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~