Elasticsearch docker 安装

Install Elasticsearch with Docker | Elasticsearch Guide [8.14] | Elastic

Run Elasticsearch locally in Docker (without security) | Elasticsearch Guide [8.14] | Elastic

1、

复制代码
docker network create elastic

root@bigData02 \~\]# docker network create elastic 03dcafa73576b5a555a6f8a6014338e78efb6d647a65cf1621e0769a0f77df20 2、安装 `cosign` sudo yum update sudo yum install -y curl jq COSIGN_RELEASE=$(curl -Ls "https://api.github.com/repos/sigstore/cosign/releases/latest" \| jq -r .tag_name) curl -Ls https://github.com/sigstore/cosign/releases/download/${COSIGN_RELEASE}/cosign-linux-amd64 -o cosign 3、docker run --name es01 --net elastic -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.14.0 ![](https://img-blog.csdnimg.cn/direct/3d257bb0ae7649b2a4dd5de83e8efec5.png) ![](https://img-blog.csdnimg.cn/direct/915a5fcb6a0b48518d33bb47b9a45f94.png) docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana ![](https://img-blog.csdnimg.cn/direct/817f6e2e885e49fc8cd8d9df0877cdf1.png) export ELASTIC_PASSWORD="123456" docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt . ![](https://img-blog.csdnimg.cn/direct/b4e3378f48e54abda6e6b531f5a36954.png) curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200 ![](https://img-blog.csdnimg.cn/direct/26404ad0e1124e56a376a0bd9342451c.png) ##### Add more nodes docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node Start a new Elasticsearch container. docker run -e ENROLLMENT_TOKEN="\" --name es02 --net elastic -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.14.0 curl --cacert http_ca.crt -u elastic:$ELASTIC_PASSWORD https://localhost:9200/_cat/nodes 报了个未知错误 ------------------------------------------------------------------------------------------------------------------------------- 采用 docker-compose方式 手动下载 https://github.com/elastic/elasticsearch/blob/8.14/docs/reference/setup/install/docker/docker-compose.yml ![](https://img-blog.csdnimg.cn/direct/4ac72d7833154071ba77f90a9ad49695.png) 手动下载https://github.com/elastic/elasticsearch/blob/8.14/docs/reference/setup/install/docker/.env ![](https://img-blog.csdnimg.cn/direct/395d586618cd485b81c36d2331e9b179.png) pip install docker-compose (安装docker-compose) 异常 : ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips 26 Jan 2017'. pip uninstall urllib3 pip install urllib3==1.26.\* docker-compose up -d ![](https://img-blog.csdnimg.cn/direct/fb154e46ed3b42568bcbbc2d850ee166.png) ##### Run Kibana docker pull docker.elastic.co/kibana/kibana:8.14.0 wget https://artifacts.elastic.co/cosign.pub cosign verify --key cosign.pub docker.elastic.co/kibana/kibana:8.14.0 docker run --name kib01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.14.0 To regenerate the token, run: docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic ##### Remove containers (参考) # Remove the Elastic network docker network rm elastic # Remove Elasticsearch containers docker rm es01 docker rm es02 # Remove the Kibana container docker rm kib01 ---------------------------------------------------------------------------------------------------------------------------- 普通安装方式 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.14.0-linux-x86_64.tar.gz wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.14.0-linux-x86_64.tar.gz.sha512 yum install perl-Digest-SHA shasum -a 512 -c elasticsearch-8.14.0-linux-x86_64.tar.gz.sha512 ![](https://img-blog.csdnimg.cn/direct/f651a7f4662c48c7b5853b29862f9512.png) ``` tar -xzf elasticsearch-8.14.0-linux-x86_64.tar.gz ``` ``` cd elasticsearch-8.14.0/ ``` ![](https://img-blog.csdnimg.cn/direct/56083625cda34dd1807dbe3e069f4adf.png) export ES_HOME=/opt/dockerinstall/esinstall/elasticsearch-8.14.0 ![](https://img-blog.csdnimg.cn/direct/a18723c4d6924a01a2bccda92fa34cd8.png) ![](https://img-blog.csdnimg.cn/direct/905be95f057b4e82bd7b99af0b682da8.png) ![](https://img-blog.csdnimg.cn/direct/f9508080c79448d5ba40000e26aeef1d.png) su es ./bin/elasticsearch ![](https://img-blog.csdnimg.cn/direct/b9c43aa40dac4dd28b45667558299e8d.png) received plaintext http traffic on an https channel, closing connection ES8 默认开启了 ssl 认证,导致无法访问 9200 端口 elasticsearch.yml 配置:xpack.security.enabled: 把 true 改成 false 重新启动 ./bin/elasticsearch curl -X GET "localhost:9200/?pretty" ![](https://img-blog.csdnimg.cn/direct/19ab1c95e98848859cb81cae7bbd0bd8.png) #### Run as a daemon ./bin/elasticsearch -d -p pid ![](https://img-blog.csdnimg.cn/direct/e0b83a5412224ac1b6b775c2f47b0c68.png) Elasticsearch 8.x环境中获得类似Head插件的功能,最推荐的方式是使用Kibana Dev Tools 安装kibana [Download Kibana Free \| Get Started Now \| Elastic](https://www.elastic.co/cn/downloads/kibana?spm=5176.28103460.0.0.49e33da2EQpsD9 "Download Kibana Free | Get Started Now | Elastic") 参考:[如何在 Linux,MacOS 及 Windows 上进行安装 Elasticsearch_macos安装es-CSDN博客](https://elasticstack.blog.csdn.net/article/details/99413578 "如何在 Linux,MacOS 及 Windows 上进行安装 Elasticsearch_macos安装es-CSDN博客") tar -xvf kibana-8.14.0-linux-x86_64.tar.gz ![](https://img-blog.csdnimg.cn/direct/be8a130b683d45c68e96e620dc8af77c.png) ![](https://img-blog.csdnimg.cn/direct/ccd79cde454847ecba90ded0df76b32a.png) elasticsearch.hosts: \["http://localhost:9200"

./bin/kibana --allow-root

后台运行:

nohup ./bin/kibana --allow-root &

安装插件:

./bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.14.0

插件地址:https://release.infinilabs.com/analysis-ik/stable/elasticsearch-analysis-ik-8.14.0.zip

停止ES

root@bigData02 elasticsearch-8.14.0\]# cat pid 129355 \[root@bigData02 elasticsearch-8.14.0\]# kill -SIGTERM 129355 su es ./bin/elasticsearch -d -p pid ![](https://img-blog.csdnimg.cn/direct/3feea912cd1744d9a74b08ea9ad3fd88.png) # Welcome to the Dev Tools Console! # # You can use Console to explore the Elasticsearch API. See the Elasticsearch API reference to learn more: # https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html # # Here are a few examples to get you started. PUT _template/content_erp_nlp_help { "index_patterns": [ "content_vector*" ], "settings": { "analysis": { "analyzer": { "my_ik_analyzer": { "type": "ik_smart" } } }, "number_of_shards": 1 }, "mappings": { "properties": { "id": { "type": "long" }, "content": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart" }, "content_vector": { "type": "dense_vector", "similarity": "cosine", "index": true, "dims": 768, "element_type": "float", "index_options": { "type": "hnsw", "m": 16, "ef_construction": 128 } }, "content_answer": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart" }, "title": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart" }, "param": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart" }, "type": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_smart" } } } } # Create an index PUT /my-index # Add a document to my-index POST /my-index/_doc { "id": "park_rocky-mountain", "title": "Rocky Mountain", "description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra." } # Perform a search in my-index GET /my-index/_search?q="rocky mountain"

相关推荐
努力的IT小胖子6 分钟前
Docker 镜像下载太慢?手把手教你修改镜像源,速度起飞!
后端·docker·容器
有谁看见我的剑了?1 小时前
docker 运行时权限和 Linux 能力了解
linux·docker·容器
敖云岚2 小时前
【那些年踩过的坑】Docker换源加速详细教程(截至2025年4月)
运维·docker·容器
TracyCoder1232 小时前
ElasticSearch深入解析(三):Elasticsearch 7的安装与配置、Kibana安装
大数据·elasticsearch·jenkins
柳如烟@2 小时前
Docker安装ES :确保 Kibana 正确连接 Elasticsearch
运维·数据库·elasticsearch·docker·容器·kibana
weisian1513 小时前
云原生--核心组件-容器篇-2-认识下Docker(三大核心之镜像,容器,仓库)
docker·云原生·容器
南棱笑笑生4 小时前
20250426在ubuntu20.04.2系统上打包NanoPi NEO开发板的FriendlyCore系统刷机eMMC的固件
大数据·elasticsearch·搜索引擎
weisian1514 小时前
云原生--核心组件-容器篇-3-Docker核心之-镜像
docker·云原生·容器
大米☋7 小时前
Docker-高级使用
linux·运维·docker·容器·centos
Anarkh_Lee14 小时前
Neo4j在win下安装教程(docker环境)
docker·容器·neo4j