一、es7 安裝
1、安裝好docker
不贅述
2、搜索鏡像
docker search elasticsearch
如果出現以下報錯
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
執行以下代碼
systemctl daemon-reload
sudo service docker restart
3、拉取鏡像(我這里拉取的是5.6版本的)
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.1.1
4、查看鏡像
[root@host1 bin]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.elastic.co/elasticsearch/elasticsearch 7.1.1 96dd1575de0f 2 months agoo
5、啟動鏡像(我在這里使用了 -e 限制內存大小 752be83a5396是上面查詢的鏡像ID)
docker run -d --name es -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms512m -Xmx512m"-e"discovery.type=single-node"docker.elastic.co/elasticsearch/elasticsearch:7.1.1
6、使用命令查看防火牆端口是否已經開放
firewall-cmd --list-port
如果結果中沒有看到9200和9300端口,需要開放這兩個端口,使用以下命令
7、開放相關端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=9300/tcp --permanent
重啟防火牆
firewall-cmd --reload
打開谷歌瀏覽器訪問
服務器IP:9200
出現以下內容
{
"name"
:
"bfc29f5a8f8c"
,
"cluster_name"
:
"docker-cluster"
,
"cluster_uuid"
:
"9dtJwBrNTwCHnbewPETxhw"
,
"version"
: {
"number"
:
"7.1.1"
,
"build_flavor"
:
"default"
,
"build_type"
:
"docker"
,
"build_hash"
:
"7a013de"
,
"build_date"
:
"2019-05-23T14:04:00.380842Z"
,
"build_snapshot"
:
false
,
"lucene_version"
:
"8.0.0"
,
"minimum_wire_compatibility_version"
:
"6.8.0"
,
"minimum_index_compatibility_version"
:
"6.0.0-beta1"
},
"tagline"
:
"You Know, for Search"
}
說明安裝成功
二、es界面管理工具elasticHD
docker run -p 9800:9800 -d --link elasticsearch:demo containerize/elastichd
三、Docker部署ik中文分詞插件
1、進入es容器內部,/plugins下新建ik文件夾
[root@iZwz99dhxbd6xwly17tb3bZ ~]# docker exec -it es /bin/bash
[root@970f612c5cac elasticsearch]# ls
LICENSE.txt NOTICE.txt README.textile bin config data lib logs modules plugins
[root@970f612c5cac elasticsearch]# cd plugins/
[root@970f612c5cac plugins]# mkdir ik
[root@970f612c5cac plugins]# ls
ik ingest-geoip ingest-user-agent
2、下載與es對應版本的ik壓縮包,並解壓
這一步有的人服務器不支持zip所以解壓不了。我是從電腦上解壓后弄成tar.gz文件上傳到服務器然后cp到容器內部對應文件夾下,命令 docker cp /tmp/elasticsearch-analysis-ik-7.1.1.tar.gz 40aeef081297:/usr/share/elasticsearch/plugins/tk
下載地址:https://github.com/medcl/elasticsearch-analysis-ik/releases
[root@970f612c5cac plugins]# cd ik
[root@970f612c5cac ik]# wget https:
//github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.1.1/elasticsearch-analysis-ik-7.1.1.zip
[root@970f612c5cac ik]# unzip elasticsearch-analysis-ik-7.1.1.zip
[root@970f612c5cac ik]# ls
commons-codec-1.9.jar elasticsearch-analysis-ik-6.3.2.jar plugin-descriptor.properties
commons-logging-1.2.jar httpclient-4.5.2.jar plugin-security.policy
config httpcore-4.4.4.jar
3、退出容器,重啟es容器
[root@970f612c5cac ik]# exit
exit
[root@iZwz99dhxbd6xwly17tb3bZ ~]# docker restart es
4、測試ik分詞插件,postman請求以下參數

ip:9200/_analyze?pretty=true
{
"analyzer": "ik_max_word",
"text": "這是我拷貝來的,我是不是很厲害"
}
注意analyzer這個單詞上下是不一樣的
感謝: https://www.cnblogs.com/hahahehexixihoho/p/11613524.html
