Toggle navigation
Home
Java
Spring
Spring框架
SpringBoot
SpringCloud
SpringGateway
Nacos
Apollo配置中心
中间件
Redis
Mysql
ElasticSearch
算法
LeetCode
Docker安装Elasticsearch和Kibana 8.4.1
## 安装Elasticsearch #### 环境准备 因为我们要安装es和kibana,我们先为他们创建网络 ```shell docker network create elastic ``` 拉取docker镜像,这里我们安装8.4.1 ```shell docker pull elasticsearch:8.4.1 ``` #### 启动es ```shell docker run --name myes --net elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e CLI_JAVA_OPTS="-Xms128m -Xmx1024m" -v /data/service/es/plugins:/usr/share/elasticsearch/plugins -it elasticsearch:8.4.1 ``` 启动es之后我们可以看到输出日志末尾有如下日志: ```shell -> 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`): vSmuF==WnQl*V8m4APAc -> HTTP CA certificate SHA-256 fingerprint: fdbc10be17db909e1ea7d2b6dfee6727531f30b1b12ca98a5a4eac8b83739d28 -> 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): eyJ2ZXIiOiI4LjQuMSIsImFkciI6WyIxNzIuMTguMC4yOjkyMDAiXSwiZmdyIjoiZmRiYzEwYmUxN2RiOTA5ZTFlYTdkMmI2ZGZlZTY3Mjc1MzFmMzBiMWIxMmNhOThhNWE0ZWFjOGI4MzczOWQyOCIsImtleSI6Imk2ZF9RWVlCWUszMVg5NThtbFNlOnVrYXdibzJIVGtlYjBobG1ETlBVX2cifQ== -> Configure other nodes to join this cluster: * Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes): eyJ2ZXIiOiI4LjQuMSIsImFkciI6WyIxNzIuMTguMC4yOjkyMDAiXSwiZmdyIjoiZmRiYzEwYmUxN2RiOTA5ZTFlYTdkMmI2ZGZlZTY3Mjc1MzFmMzBiMWIxMmNhOThhNWE0ZWFjOGI4MzczOWQyOCIsImtleSI6ImphZF9RWVlCWUszMVg5NThtbFM5OlBHb0dzNkd2VEx1OFlJSkhmby04OWcifQ== If you're running in Docker, copy the enrollment token and run: `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.4.1` ``` 可以看到其中两个比较重要的日志 ```shell -> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`): vSmuF==WnQl*V8m4APAc 和 -> 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): eyJ2ZXIiOiI4LjQuMSIsImFkciI6WyIxNzIuMTguMC4yOjkyMDAiXSwiZmdyIjoiZmRiYzEwYmUxN2RiOTA5ZTFlYTdkMmI2ZGZlZTY3Mjc1MzFmMzBiMWIxMmNhOThhNWE0ZWFjOGI4MzczOWQyOCIsImtleSI6Imk2ZF9RWVlCWUszMVg5NThtbFNlOnVrYXdibzJIVGtlYjBobG1ETlBVX2cifQ== ``` 第一行为es密码 账户为es, 并且之指明了, 用户名为elastic 和重置密码的命令 第二个为kibana密码,并且该密码有效期只有三十分钟,如果过期参考最下边的解决方案。 #### 启动Kibana 拉取kibana镜像,这里需要注意,因为ES多个组件之间需要保持版本一致。 ```shell docker pull kibana:8.4.1 ``` ```shell docker run --name mykb --net elastic -p 5601:5601 kibana:8.4.1 ``` 启动后日志输出如下: ```shell [root@localhost ~]# docker run --name mykb --net elastic -p 5601:5601 kibana:8.4.1 [2023-02-11T17:30:09.304+00:00][INFO ][node] Kibana process configured with roles: [background_tasks, ui] [2023-02-11T17:30:23.917+00:00][INFO ][http.server.Preboot] http server running at http://0.0.0.0:5601 [2023-02-11T17:30:23.964+00:00][INFO ][plugins-system.preboot] Setting up [1] plugins: [interactiveSetup] [2023-02-11T17:30:23.966+00:00][INFO ][preboot] "interactiveSetup" plugin is holding setup: Validating Elasticsearch connection configuration… [2023-02-11T17:30:23.998+00:00][INFO ][root] Holding setup until preboot stage is completed. i Kibana has not been configured. Go to http://0.0.0.0:5601/?code=696159 to get started. ``` 这个时候我们访问 ```shell http://{{ip}}:5601 ``` ![image.png](https://private.andycoder.com/basic/file/getFileById?fileId=822567953638756352) 点击Configure Elastic 提示如如下页面, ![image.png](https://private.andycoder.com/basic/file/getFileById?fileId=822568152629121024) 进入kibana容器中查看到对应日志数据有验证码日志: ```shell Your verification code is: 696 159 ``` 输入验证码之后点击Verify,可以看到kibana初始化完成 ![image.png](https://private.andycoder.com/basic/file/getFileById?fileId=822568262473748480) 此处输入ES密码即可登录kibana ##### kibana令牌过期如何重新生成? 1. 登录es实例: ```shell docker exec -it myes /bin/bash ``` 1. 执行命令重新生成 ```shell ./elasticsearch-create-enrollment-token -s kibana --url "https://172.18.0.2:9200" eyJ2ZXIiOiI4LjQuMSIsImFkciI6WyIxNzIuMTguMC4yOjkyMDAiXSwiZmdyIjoiZmRiYzEwYmUxN2RiOTA5ZTFlYTdkMmI2ZGZlZTY3Mjc1MzFmMzBiMWIxMmNhOThhNWE0ZWFjOGI4MzczOWQyOCIsImtleSI6ImpxZkRRWVlCWUszMVg5NThFbFNDOi1wUHN2OGczU0htYTF1NnlYVGhULXcifQ== ``` 其中ip地址为es地址 官方参考地址: > https://www.elastic.co/guide/en/elasticsearch/reference/8.1/create-enrollment-token.html
软件安装
中间件
文章分类
Nacos
SpringGateway
Nacos
Java
Spring
SpringBoot
SpringCloud
中间件
SpringGateway
Nacos
Redis
Mysql
算法
LeetCode
Apollo配置中心
ElasticSearch
Spring框架
文章标签
Redis基础知识
中间件
数据库
Mysql
算法题
面试题
软件安装
SpringFramework
ES