论坛
Docker 安装 ES8 和 Kibana
程序员子悠@ziyou
27 个帖子
#1 · 2024年4月15日, 下午10:17
引用于 程序员子悠 在 2024年4月15日, 下午10:17https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
Docker 安装 ES8
安装 ES
# 创建一个单独的 es 网络 docker network create elastic # pull es 镜像 docker pull docker.elastic.co/elasticsearch/elasticsearch:8.12.2 # 启动 es,并且限制一下内存 docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.12.2
容器启动过后会出现下面的内容,这里会包含 elastic 的一个初始用户和密码,并且也会输出一个用于 kibana 链接的 token 在 30 分钟内有效。这个密码后期也可以重置,不过建议还是好好保存一下,避免麻烦。
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ 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`): oQuOvvZWZ_Yl*MP4Qdx+ ℹ️ HTTP CA certificate SHA-256 fingerprint: 069ac73fc5c8ad9d14aaa3a1d6c4ba92cbfebab0354254c5e1512855cfc34dbe ℹ️ 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): eyJ2ZXIiOiI4LjEyLjIiLCJhZHIiOlsiMTcyLjE5LjAuMjo5MjAwIl0sImZnciI6IjA2OWFjNzNmYzVjOGFkOWQxNGFhYTNhMWQ2YzRiYTkyY2JmZWJhYjAzNTQyNTRjNWUxNTEyODU1Y2ZjMzRkYmUiLCJrZXkiOiJLQ2o4VVk0QlZqTFJyVldaM3gwUzpXRkcxWHpuUVF5LURiVDU1a1BDT0NnIn0= ℹ️ 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): eyJ2ZXIiOiI4LjEyLjIiLCJhZHIiOlsiMTcyLjE5LjAuMjo5MjAwIl0sImZnciI6IjA2OWFjNzNmYzVjOGFkOWQxNGFhYTNhMWQ2YzRiYTkyY2JmZWJhYjAzNTQyNTRjNWUxNTEyODU1Y2ZjMzRkYmUiLCJrZXkiOiJLU2o4VVk0QlZqTFJyVldaM3gwWDpad1hEWWhuc1RPT2x4UjRzdHBmX013In0= If you're running in Docker, copy the enrollment token and run: `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.12.2` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
拷贝证书
因为 ES8 默认是开启了安全认证的,为了后续的方便,这里我们可以先把证书拷贝出来,放在一个地方,后期会用到。
docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .
验证集群
在证书所在目录下执行下面命令
curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200
如果返回如下信息,则表示集群配置成功
{ "name" : "82fa82574efc", "cluster_name" : "docker-cluster", "cluster_uuid" : "BC7jOUcjR-ut7toSNcOtkA", "version" : { "number" : "8.12.2", "build_flavor" : "default", "build_type" : "docker", "build_hash" : "48a287ab9497e852de30327444b0809e55d46466", "build_date" : "2024-02-19T10:04:32.774273190Z", "build_snapshot" : false, "lucene_version" : "9.9.2", "minimum_wire_compatibility_version" : "7.17.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" }
Docker 安装 Kibana
# 拉取镜像 docker pull docker.elastic.co/kibana/kibana:8.12.2 # 启动 kibana 并且跟 es 使用同一个网络 docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.12.2
启动过后,点击日志中的链接打开 5601 端口,输入上面的 token,即可,后续登录 kibana 的时候需要使用上面的 es 用户和密码。
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
Docker 安装 ES8
安装 ES
# 创建一个单独的 es 网络
docker network create elastic
# pull es 镜像
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.12.2
# 启动 es,并且限制一下内存
docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.12.2
容器启动过后会出现下面的内容,这里会包含 elastic 的一个初始用户和密码,并且也会输出一个用于 kibana 链接的 token 在 30 分钟内有效。这个密码后期也可以重置,不过建议还是好好保存一下,避免麻烦。
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ 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`):
oQuOvvZWZ_Yl*MP4Qdx+
ℹ️ HTTP CA certificate SHA-256 fingerprint:
069ac73fc5c8ad9d14aaa3a1d6c4ba92cbfebab0354254c5e1512855cfc34dbe
ℹ️ 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):
eyJ2ZXIiOiI4LjEyLjIiLCJhZHIiOlsiMTcyLjE5LjAuMjo5MjAwIl0sImZnciI6IjA2OWFjNzNmYzVjOGFkOWQxNGFhYTNhMWQ2YzRiYTkyY2JmZWJhYjAzNTQyNTRjNWUxNTEyODU1Y2ZjMzRkYmUiLCJrZXkiOiJLQ2o4VVk0QlZqTFJyVldaM3gwUzpXRkcxWHpuUVF5LURiVDU1a1BDT0NnIn0=
ℹ️ 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):
eyJ2ZXIiOiI4LjEyLjIiLCJhZHIiOlsiMTcyLjE5LjAuMjo5MjAwIl0sImZnciI6IjA2OWFjNzNmYzVjOGFkOWQxNGFhYTNhMWQ2YzRiYTkyY2JmZWJhYjAzNTQyNTRjNWUxNTEyODU1Y2ZjMzRkYmUiLCJrZXkiOiJLU2o4VVk0QlZqTFJyVldaM3gwWDpad1hEWWhuc1RPT2x4UjRzdHBmX013In0=
If you're running in Docker, copy the enrollment token and run:
`docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.12.2`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
拷贝证书
因为 ES8 默认是开启了安全认证的,为了后续的方便,这里我们可以先把证书拷贝出来,放在一个地方,后期会用到。
docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .
验证集群
在证书所在目录下执行下面命令
curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200
如果返回如下信息,则表示集群配置成功
{
"name" : "82fa82574efc",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "BC7jOUcjR-ut7toSNcOtkA",
"version" : {
"number" : "8.12.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "48a287ab9497e852de30327444b0809e55d46466",
"build_date" : "2024-02-19T10:04:32.774273190Z",
"build_snapshot" : false,
"lucene_version" : "9.9.2",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
Docker 安装 Kibana
# 拉取镜像
docker pull docker.elastic.co/kibana/kibana:8.12.2
# 启动 kibana 并且跟 es 使用同一个网络
docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.12.2
启动过后,点击日志中的链接打开 5601 端口,输入上面的 token,即可,后续登录 kibana 的时候需要使用上面的 es 用户和密码。
踩。0赞。0