Linux下Elasticsearch+Kibana安装部署

     |   0 评论   |   0 浏览

ES 安装包下载官方链接:
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.6.2.tar.gz
kibana 安装包下载官方链接:
https://artifacts.elastic.co/downloads/kibana/kibana-6.6.2-linux-x86_64.tar.gz
二者需要安装相同的版本

ES 安装步骤

初始化安装目录

1[root@zhulin es]# cat /etc/redhat-release
2CentOS Linux release 7.9.2009 (Core)
3[root@zhulin es]# mkdir -p /export/servers
4[root@zhulin es]# mkdir -p /usr/local/elasticsearch/data
5[root@zhulin es]# mkdir -p /usr/local/elasticsearch/logs
6[root@zhulin es]# tar zxvf elasticsearch-6.6.2.tar.gz -C /export/servers/
7[root@zhulin es]# cd /export/servers/
8[root@zhulin servers]# mv elasticsearch-6.6.2 elasticsearch

修改配置文件

  • 涉及字段:cluster.name、node.name、path.data、path.logs、network.host、http.port

VIM elasticsearch/config/elasticsearch.yml

 1# Use a descriptive name for your cluster:
 2cluster.name: my-application
 3# 
 4# Use a descriptive name for the node:
 5node.name: node-1
 6# 
 7# Path to directory where to store the data (separate multiple locations by comma):
 8path.data: /usr/local/elasticsearch/data
 9# 
10# Path to log files:
11path.logs: /usr/local/elasticsearch/logs
12# 
13# Set the bind address to a specific IP (IPv4 or IPv6):
14network.host: 192.168.0.161
15# 
16# Set a custom port for HTTP:
17http.port: 9200

运行遇到的问题

系统未安装 JDK

1[root@zhulin servers]# ./elasticsearch/bin/elasticsearch
2which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
3could not find java; set JAVA_HOME or ensure java is in PATH
  • 修复:安装 JDK1.8 版本
1[root@zhulin servers]# yum search java|grep jdk
2[root@zhulin servers]# yum install java-1.8.0-openjdk
3[root@zhulin servers]# java -version
4   openjdk version "1.8.0_292"
5   OpenJDK Runtime Environment (build 1.8.0_292-b10)
6   OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode)

不能使用 root 权限

1[root@zhulin servers]# ./elasticsearch/bin/elasticsearch
2[2021-06-11T16:23:31,584][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler]
3[node-1] uncaught exception in thread [main]
4org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException:
5can not run elasticsearch as root
  • 修复:创建并使用普通用户权限运行 ES
1[root@zhulin servers]# useradd es
2[root@zhulin servers]# passwd es
3[root@zhulin servers]# chown -R es:es /export/servers/elasticsearch
4[root@zhulin servers]# chown -R es:es /usr/local/elasticsearch
5[root@zhulin servers]# su es
6[es@zhulin servers]$

ES 运行成功后,开放两服务个端口:
9200 是 ES 节点与外部通讯使用的端口。(是 http 协议的 RESTFul 接口)
9300 是 ES 节点之间通讯使用的端口。(是集群间 tcp 通讯端口)

1[es@zhulin servers]$ nohup ./elasticsearch/bin/elasticsearch &
2[root@zhulin ~]# netstat -ntlp | grep java
3tcp6       0      0 192.168.0.161:9200          :::*       LISTEN      7964/java
4tcp6       0      0 192.168.0.161:9300          :::*       LISTEN      7964/java

备注:

CentOS6.X 系统上运行出现的问题(SecComp 及 max_map_count)
问题修复参考: https://www.cnblogs.com/socketqiang/p/11363024.html

kibana 安装步骤

1[root@zhulin es]# tar zxvf kibana-6.6.2-linux-x86_64.tar.gz -C /run/
2[root@zhulin es]# cd /run/kibana-6.6.2-linux-x86_64/

修改配置文件:config/kibana.yml

1# Kibana is served by a back end server. This setting specifies the port to use.
2server.port: 80
3 
4# To allow connections from remote users, set this parameter to a non-loopback address.
5server.host: "192.168.0.161"
6 
7# new add 
8elasticsearch.url: "http://192.168.0.161:9200"

直接后台运行 Kibana(没有问题)

1[root@zhulin kibana-6.6.2-linux-x86_64]# nohup bin/kibana &
2[root@zhulin kibana-6.6.2-linux-x86_64]# netstat -ntlp | grep node
3tcp   0   0 192.168.0.161:80    0.0.0.0:*     LISTEN     8196/bin/../node/bi

image.png