docker安装elasticsearch7

 

一、创建网络

 

docker network create -d bridge my_network

 

二、拉取elasticsearch镜像

 

docker pull elasticsearch:7.1.1

 

三、创建elasticsearch容器

 

docker run -it \
-p 9200:9200 \
-p 9300:9300 \
--name elasticsearch \
--net my_network \
-e ES_JAVA_OPTS="-Xms1g -Xmx1g" \
-e "discovery.type=single-node" \
-e LANG=C.UTF-8 \
-e LC_ALL=C.UTF-8 \
elasticsearch:7.1.1

 

四、修改配置elasticsearch.yml

 

讲容器内的配置文件复制到本机

docker cp elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml Downloads/es

 

修改elasticsearch.yml

cluster.name: "docker-cluster"
network.host: 0.0.0.0

discovery.seed_hosts: ["127.0.0.1", "[::1]"]
# cluster.initial_master_nodes: ["node-1"]

 

把配置文件上传到容器内

docker cp Downloads/es/elasticsearch.yml  elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml 

 

五、安装在线安装IK分词器

进入容器执行

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip

 

六、重启容器

docker restart elasticsearch

 

七、访问测试是否成功

http://127.0.0.1:9200/

 

posted @ 2024-08-16 14:01  程序员小艺  阅读(36)  评论(0编辑  收藏  举报