CentOS 7.9 安装 ELK

一、CentOS 7.9 安装 elasticsearch-7.8.1地址

  • https://www.elastic.co
  • https://www.elastic.co/cn/downloads/past-releases
  • https://github.com/elastic
  • https://github.com/medcl/elasticsearch-analysis-ik
  • https://www.elastic.co/guide/en/logstash/7.8/index.html

CentOS 7.9 安装 ELK

文章插图

CentOS 7.9 安装 ELK

文章插图
二、安装准备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解压
tar -zxvf /opt/software/elastic/elasticsearch-7.8.1-linux-x86_64.tar.gz -C /opt/elastic/进入elasticsearch目录中
目录中自带了jdk
CentOS 7.9 安装 ELK

文章插图
四、修改配置文件1 修改配置: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################################################################2 修改配置: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.五、尝试启动1 require 必须 Java 11
2 运行elasticsearch不能使用root用户启动
查看代码 [root@ecs-65685 bin]# /opt/elastic/elasticsearch-7.8.1/bin/elasticsearchfuture versions of Elasticsearch will require Java 11; your Java version from [/opt/jdk1.8.0_333/jre] does not meet this requirementfuture 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) ~[elasticsearch-7.8.1.jar:7.8.1]Caused by: java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) ~[elasticsearch-7.8.1.jar:7.8.1] at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) ~[elasticsearch-7.8.1.jar:7.8.1] at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) ~[elasticsearch-7.8.1.jar:7.8.1] at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-7.8.1.jar:7.8.1] ... 6 moreuncaught exception in thread [main]java.lang.RuntimeException: can not run elasticsearch as root at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393) at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161) at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127) at org.elasticsearch.cli.Command.main(Command.java:90) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)For complete error details, refer to the log at /opt/elastic/es/logs/elasticsearch.log[root@ecs-65685 bin]# 2022-10-11 09:40:42,993994 UTC [6056] ERROR CLogger.cc@311 Cannot log to named pipe /tmp/elasticsearch-1369077120224648390/controller_log_5893 as it could not be opened for writing2022-10-11 09:40:42,994085 UTC [6056] INFOMain.cc@104 Parent process died - ML controller exiting

经验总结扩展阅读