ubuntu22.04 docker安装ES8

创建es的网络

docker network create elastic

安装运行es

docker run --name es01 --net elastic -p 9200:9200 -e ES_JAVA_OPTS="-Xms1024m -Xmx1024m"  -idt elasticsearch:8.2.2

将配置文件拷贝出来

docker cp es01:/usr/share/elasticsearch/config /home/sunyuhua/docker/elasticsearch/config

将容器停止并删除

root@sunyuhua-HKF-WXX:/home/sunyuhua/localcert# docker stop es01
es01
root@sunyuhua-HKF-WXX:/home/sunyuhua/localcert# docker rm  es01
es01

docker run --name es01 --net elastic -p 9200:9200 -e ES_JAVA_OPTS="-Xms1024m -Xmx1024m" -v /home/sunyuhua/docker/elasticsearch/config/certs:/usr/share/elasticsearch/config/certs -v /home/sunyuhua/docker/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml   -idt elasticsearch:8.2.2

在这个命令中:

-v /path/to/local/config:/usr/share/elasticsearch/config 将容器内的 /usr/share/elasticsearch/config 目录映射到宿主机的 /path/to/local/config 目录。
-v /path/to/local/certs:/usr/share/elasticsearch/config/certs 将容器内的证书目录 /usr/share/elasticsearch/config/certs 映射到宿主机的 /path/to/local/certs 目录。
您需要替换 /path/to/local/config 和 /path/to/local/certs 为您宿主机上的实际路径。这些目录需要在运行命令之前在宿主机上创建。

通过这种方式,您可以直接在宿主机上编辑 Elasticsearch 的配置文件和管理证书,而这些更改将直接反映在容器内。

检查是否安装成功

sunyuhua@sunyuhua-HKF-WXX:~$ docker ps
CONTAINER ID   IMAGE                     COMMAND                   CREATED          STATUS         PORTS                                                                                                                                      NAMES
213c6e518a18   elasticsearch:8.2.2       "/bin/tini -- /usr/l…"   10 minutes ago   Up 3 seconds   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 9300/tcp                                                                                        es01
519916b1d75c   ankane/pgvector:latest    "docker-entrypoint.s…"   2 weeks ago      Up 12 hours    0.0.0.0:5432->5432/tcp, :::5432->5432/tcp                                                                                                  pgvector
9e9de3dd5925   careywong/subweb:latest   "/docker-entrypoint.…"   6 weeks ago      Up 12 hours    0.0.0.0:58080->80/tcp, :::58080->80/tcp                                                                                                    subweb
135c04fb8903   nacos/nacos-server        "bin/docker-startup.…"   2 months ago     Up 12 hours    0.0.0.0:8848->8848/tcp, :::8848->8848/tcp, 0.0.0.0:9848-9849->9848-9849/tcp, :::9848-9849->9848-9849/tcp                                   nacos
a4f62467a17b   redis                     "docker-entrypoint.s…"   2 months ago     Up 12 hours    0.0.0.0:6379->6379/tcp, :::6379->6379/tcp                                                                                                  redis
0aab04fb09da   zookeeper                 "/docker-entrypoint.…"   2 months ago     Up 12 hours    2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, :::2181->2181/tcp, 8080/tcp                                                                    zookeeper
374d2a440886   rabbitmq                  "docker-entrypoint.s…"   2 months ago     Up 12 hours    4369/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp   rabbitmq
37c420bc27ec   mysql                     "docker-entrypoint.s…"   2 months ago     Up 12 hours    0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp                                                                                       mysql

使用https命令登陆,注意不是http登陆

https://127.0.0.1:9200/

进入容器获取用户名和密码

sunyuhua@sunyuhua-HKF-WXX:~$ docker exec -it es01 /bin/bash
elasticsearch@213c6e518a18:~$ ls
LICENSE.txt  NOTICE.txt  README.asciidoc  bin  config  data  jdk  lib  logs  modules  plugins
elasticsearch@213c6e518a18:~$ cd bin
elasticsearch@213c6e518a18:~/bin$ ks
bash: ks: command not found
elasticsearch@213c6e518a18:~/bin$ elasticsearch-reset-password -u elastic
WARNING: Owner of file [/usr/share/elasticsearch/config/users] used to be [root], but now is [elasticsearch]
WARNING: Owner of file [/usr/share/elasticsearch/config/users_roles] used to be [root], but now is [elasticsearch]
This tool will reset the password of the [elastic] user to an autogenerated value.
The password will be printed in the console.
Please confirm that you would like to continue [y/N]y


Password for the [elastic] user successfully reset.
New value: kLRzlNzzucGAofrS6xt7

用户名:elastic
密码:rNVYG5chf=HYUeH_Pjzh

在这里插入图片描述

安装kibana进行管理

sunyuhua@sunyuhua-HKF-WXX:~$ docker run \
--name kibana \
--net elastic \
-p 5601:5601 \
-idt kibana:8.2.2
Unable to find image 'kibana:8.2.2' locally
8.2.2: Pulling from library/kibana
d5fd17ec1767: Already exists 
0e13695e6282: Pull complete 
f4c86adffcb8: Pull complete 
37df8a7a2f1c: Pull complete 
605b30158b0c: Pull complete 
4f4fb700ef54: Pull complete 
8789a463d8bc: Pull complete 
6c1b4670a98a: Pull complete 
787921eb6497: Pull complete 
7833e8f6b5e0: Pull complete 
60937e7413ca: Pull complete 
a04fb33dd003: Pull complete 
5fcdf8cb4a0b: Pull complete 
929af379dbc3: Pull complete 
Digest: sha256:cf34801f36a2e79c834b3cdeb0a3463ff34b8d8588c3ccdd47212c4e0753f8a5
Status: Downloaded newer image for kibana:8.2.2
f073cde5c95817867db19ba5326db59c19b91a62eedd343149aa323b7e9924f8

浏览器登陆kibana

http://localhost:5601/app/integrations/browse

获取登陆需要的token

sunyuhua@sunyuhua-HKF-WXX:~$ docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
eyJ2ZXIiOiI4LjIuMiIsImFkciI6WyIxNzIuMjEuMC4yOjkyMDAiXSwiZmdyIjoiNzliNzZmZjQzYmJkOTRhNjYyNDY0YWU5ODY5ZjQzZDA4OTFlMjRjNTVlYWFlOTc5NjM5MjJkZjcxOTU3YTNkYiIsImtleSI6Ild2Ukxab3dCWW03dU9zZGx0WWxmOjU1UFplWXRMUzRXVFZKV2UydEw5MFEifQ==

获取登陆需要的验证码

sunyuhua@sunyuhua-HKF-WXX:~$ docker exec -it kibana bin/kibana-verification-code
Your verification code is:  944 164 

在这里插入图片描述

  • 12
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MonkeyKing.sun

对你有帮助的话,可以打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值