0%

Kibana_on_ES 配置教程

配置过程

实验环境: Kibana 版本8.7.1, Elasticsearch 版本8.7.1,在 wsl2-ubuntu22.0.4 上部署

作者在启动 Kibana 的时候,遇到了找不到 nodejs 的报错,最后发现是 kibana-x.x.x/node 文件权限的问题,只需要用 chmod 755 kibana-x.x.x/node 即可

ES 单节点配置

修改 config/elasticsearch.yml 文件,添加如下内容,ip地址输入本机wsl地址,可以通过 hostname -I 命令活动

1
2
3
4
5
6
7
cluster.name: es-8.7.1
node.name: es-9201
path.data: ~\elastic\data\9201
path.logs: ~\elastic\logs\9201
network.host: 172.21.168.87
http.port: 9201
transport.port: 9301

在 kibana-8.7.1/ 新建 data 和 logs 文件夹

运行启动命令

1
./elastic/elasticsearch-8.7.1/bin/elasticsearch

启动后会在控制台输出账号的密码和用于 kibana 的 enrollment token,先保存下来,待会有用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-------------------------------------------------------------------------------------------------------------------------> Elasticsearch security features have been automatically configured!
-> Authentication is enabled and cluster connections are encrypted.

-> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
rlF=_=7wFIrdNj6Zh9Z2

-> HTTP CA certificate SHA-256 fingerprint:
a15c8cfcb300affed0dbdf73c318339366b8d8ba076657056e6b85170669d0d6

-> Configure Kibana to use this cluster:
* Run Kibana and click the configuration link in the terminal when Kibana starts.
* Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjQuMiIsImFkciI6WyIxMjcuMC4wLjE6OTIwMSJdLCJmZ3IiOiJhMTVjOGNmY2IzMDBhZmZlZDBkYmRmNzNjMzE4MzM5MzY2YjhkOGJhMDc2NjU3MDU2ZTZiODUxNzA2NjlkMGQ2Iiwia2V5IjoienFtTmJZTUJfdzhtUUpvajh2TEI6WDlkMVlwenNTcENqWGV4bER4UE5QdyJ9

-> Configure other nodes to join this cluster:
* On this node:
- Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
- Uncomment the transport.host setting at the end of config/elasticsearch.yml.
- Restart Elasticsearch.
* On other nodes:
- Start Elasticsearch with `bin/elasticsearch --enrollment-token <token>`, using the enrollment token that you generated.

如果没有保存下来、token过期,也可以手动重置

把 ES 启动后,就可以通过以下两条命令重置

1
2
3
4
# 重置密码
./elastic/elasticsearch-8.7.1/bin/elasticsearch-reset-password -u elastic
# 重置 token
./elastic/elasticsearch-8.7.1/bin/elasticsearch-create-enrollment-token -s kibana --url "https://172.21.168.87:9201"

配置好ES,就可以通过浏览器访问了(记得要加https)

Kibana 配置

重开一个 wsl 窗口,执行以下命令

1
2
cd ~
./kibana-8.7.1/bin/kibana

使用命令行给出的ip和端口访问 kibana

输入刚刚复制下来的账号密码,就可以成功连接上 kibana

赏个鸡腿🍗