ElasticSearch with analysis-ik by Docker
需要快速部署一个带ik分词版本的elasticsearch-6.x环境。于是有了以下脚本,方便开发测试。
Dockerfile
1 2 3 4 5 6 7 8 9 10 |
FROM docker.elastic.co/elasticsearch/elasticsearch:6.2.4 MAINTAINER cppla <i@cpp.la> ADD elasticsearch /usr/share/elasticsearch/plugins/ik VOLUME /usr/share/elasticsearch/data VOLUME /usr/share/elasticsearch/logs EXPOSE 9200 |
一键拉起脚本elasticwithik
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
#!/bin/bash if cat /etc/sysctl.conf | grep "vm.max_map_count" > /dev/null 2>&1 then echo "vm.max_map_count already set!" else echo "vm.max_map_count=262144" >> /etc/sysctl.conf sysctl -p echo "vm.max_map_count set successed! " fi apt install unzip -y docker pull docker.elastic.co/elasticsearch/elasticsearch:6.2.4 wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip unzip elasticsearch-analysis-ik-6.2.4.zip docker build --tag=cppla/elasticwithik:latest . rm -rf elasticsearch rm -rf elasticsearch-analysis-ik-6.2.4.zip mkdir -p /data/elasticsearch chown -R 999:999 /data/elasticsearch chmod -R 777 /data/elasticsearch chmod -R 777 /data/elasticsearch/data chmod -R 777 /data/elasticsearch/logs docker run -d -ti --name=elasticwithik \ -p 9200:9200 \ -v /data/elasticsearch/data:/usr/share/elasticsearch/data \ -v /data/elasticsearch/logs:/usr/share/elasticsearch/logs \ --memory=4g \ --memory-swap=4g \ --ulimit memlock=-1:-1 \ --env "cluster.name=elasticwithik" \ --env "bootstrap.memory_lock=true" \ --env "ES_JAVA_OPTS=-Xms2g -Xmx2g" \ cppla/elasticwithik:latest echo "successd!" |
更简单的方式直接从仓库运行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# 修改vm.max_map_count echo "vm.max_map_count=262144" >> /etc/sysctl.conf sysctl -p # 拉取镜像 docker pull cppla/elasticwithik # 创建目录修改权限 mkdir -p /data/elasticsearch/data mkdir -p /data/elasticsearch/logs chmod -R 777 /data/elasticsearch # 运行elasitcsearch with ik docker run -d -ti --name=elasticwithik \ -p 9200:9200 \ -v /data/elasticsearch/data:/usr/share/elasticsearch/data \ -v /data/elasticsearch/logs:/usr/share/elasticsearch/logs \ --memory=4g \ --memory-swap=4g \ --ulimit memlock=-1:-1 \ --env "cluster.name=elasticwithik" \ --env "bootstrap.memory_lock=true" \ --env "ES_JAVA_OPTS=-Xms2g -Xmx2g" \ cppla/elasticwithik:latest |