1、docker镜像

1.1、镜像获取

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.2.3 

PS:本文基于基于elasticsearch:6.2.3

1.2、自制带有ik、pinyin分词的docker镜像

        进入容器,按照文档(ElaticSearch之中文、拼音分词插件安装)安装analysis-ik、pinyin插件,然后通过docker  commit创建自己的镜像,推至私有仓库,重复使用。

docker exec -it [容器Id] /bin/sh
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.3/elasticsearch-analysis-ik-6.2.3.zip 
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v6.2.3/elasticsearch-analysis-pinyin-6.2.3.zip  
docker commit [容器Id] harbor.suiyi.com.cn/component/elasticsearch-ik-pinyin:6.2.3

        该版本的镜像已推至docker  hub,可

docker pull jinyidong/es-ik-pinyin:6.2.3

2、文件挂载

        elasticsearch docker挂载要求相关目录及文件必须属于user(elasticsearch:1000)、group(elasticsearch:1000),建议放在home目录下,方便扩展。

         解决方案:宿主机执行

 sysctl -w vm.max_map_count=262144

2.1、yml文件挂载

-v /home/component/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml

# ======================== Elasticsearch Configuration =========================

# ---------------------------------- Cluster -----------------------------------
cluster.name: "docker-cluster"
#
# ------------------------------------ Node ------------------------------------

# ----------------------------------- Paths ------------------------------------

# ----------------------------------- Memory -----------------------------------

# ---------------------------------- Network -----------------------------------
network.host: 0.0.0.0
# --------------------------------- Discovery ----------------------------------
discovery.zen.minimum_master_nodes: 1
# ---------------------------------- Gateway -----------------------------------

xpack.license.self_generated.type: basic

2.2、data、log目录挂载

-v /home/component/elasticsearch/data/nodes:/usr/share/elasticsearch/data/nodes \
-v /home/component/elasticsearch/logs:/usr/share/elasticsearch/logs \

2.3、ik词库挂载

-v /home/component/elasticsearch/analysis-ik/custom:/usr/share/elasticsearch/config/analysis-ik/custom \
-v /home/component/elasticsearch/analysis-ik/IKAnalyzer.cfg.xml:/usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml \

2.4、Demo

docker run \
-p 9200:9200 \
-p 9300:9300 \
-v /home/component/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/component/elasticsearch/data/nodes:/usr/share/elasticsearch/data/nodes \
-v /home/component/elasticsearch/logs:/usr/share/elasticsearch/logs \
-v /home/component/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /home/component/elasticsearch/analysis-ik/custom:/usr/share/elasticsearch/config/analysis-ik/custom \
-v /home/component/elasticsearch/analysis-ik/IKAnalyzer.cfg.xml:/usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml \
****/component/elasticsearch-ik-pinyin:6.2.3

3、集群模式

        未完待续......


Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐