背景
elasticsearch7.9 不包含ik,pinying, jieba (结巴)3个插件,需要制作成一个标准的镜像
资源准备
- elasticsearch 7.9:docker pull elasticsearch: 7.9.0
- 结巴分词插件:https://github.com/sing1ee/elasticsearch-jieba-plugin (用7.4.2版本,7.9.0版本构建失败,7.17.0目前构建失败)
- pingying插件: https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.9.0/elasticsearch-analysis-pinyin-7.9.0.zip
- ik插件: https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.0/elasticsearch-analysis-ik-7.9.0.zip
制作过程
docker pull elasticsearch:7.9.0
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms512m -Xmx512m" --name es7.9-2 -d elasticsearch:7.9.0
git clone https://github.com/sing1ee/elasticsearch-jieba-plugin
git checkout 7.4.2
wget https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.9.0/elasticsearch-analysis-pinyin-7.9.0.zip
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.0/elasticsearch-analysis-ik-7.9.0.zip
#安装jdk
yum install java-1.8.0-openjdk-devel
# /etc/profile文件中增加:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
export PATH=$JAVA_HOME/bin:$PATH
#安装gradle
wget https://services.gradle.org/distributions/gradle-5.6.2-bin.zip
unzip gradle-5.6.2-bin.zip
mv gradle-5.6 /opt/
# /etc/profile文件中增加:
export GRADLE_HOME=/opt/gradle-5.6
export PATH=$PATH:$GRADLE_HOME/bin
source /etc/profile
unzip elasticsearch-analysis-pinyin-7.9.0.zip
unzip elasticsearch-analysis-ik-7.9.0.zip
cd elasticsearch-jieba-plugin
./gradlew clean pz
docker cp <3个插件目录> <容器id>:/usr/share/elasticsearch/plugins/
docker commit <容器id> harbor.host.com/library/elasticsearch:7.9.0
docker push harbor.host.com/library/elasticsearch:7.9.0