- 拉取Elcasticsearch鏡像
docker pull elasticsearch:5.6.8
- 調高JVM線程數
#編輯
vim /etc/sysctl.conf
#加入內容
vm.max_map_count=262144
#啓用配置
sysctl -p
- 新建ES01節點配置文件es01.yml
#ES01配置
cluster.name: elasticsearch-cluster
node.name: es-node-01
network.bind_host: 0.0.0.0
network.publish_host: 192.168.44.113
http.port: 9200
transport.tcp.port: 9300
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.44.113:9300","192.168.44.113:9301","192.168.44.113:9302"]
discovery.zen.minimum_master_nodes: 2
- 新建ES02節點配置文件es02.yml
#ES02配置
cluster.name: elasticsearch-cluster
node.name: es-node-02
network.bind_host: 0.0.0.0
network.publish_host: 192.168.44.113
http.port: 9201
transport.tcp.port: 9301
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.44.113:9300","192.168.44.113:9301","192.168.44.113:9302"]
discovery.zen.minimum_master_nodes: 2
- 新建ES03節點配置文件es03.yml
#ES03配置
cluster.name: elasticsearch-cluster
node.name: es-node-03
network.bind_host: 0.0.0.0
network.publish_host: 192.168.44.113
http.port: 9202
transport.tcp.port: 9302
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.ping.unicast.hosts: ["192.168.44.113:9300","192.168.44.113:9301","192.168.44.113:9302"]
discovery.zen.minimum_master_nodes: 2
- 分別啓動三臺節點
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -p 9200:9200 -p 9300:9300 -v /opt/es/es01.yml:/usr/share/elasticsearch/config/elasticsearch.yml --name ES01 -d 6c0bdf761f3b
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -p 9201:9201 -p 9301:9301 -v /opt/es/es02.yml:/usr/share/elasticsearch/config/elasticsearch.yml --name ES02 -d 6c0bdf761f3b
docker run -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -p 9202:9202 -p 9302:9302 -v /opt/es/es03.yml:/usr/share/elasticsearch/config/elasticsearch.yml --name ES03 -d 6c0bdf761f3b
- 測試是否搭建成功
http://192.168.44.113:9200/_cat/nodes?pretty
- 配置IK中文分詞器
- 資源鏈接:https://pan.baidu.com/s/1c6av35dAbP-EZCiARf_ujA 提取碼:2868
- 上傳elasticsearch-analysis-ik-5.6.8.zip至服務器
- 解壓至指定位置
unzip elasticsearch-analysis-ik-5.6.8.zip -d /opt/module/
- 拷貝ik-analyzer至ES容器中
#分貝爲ES節點配置ik-分詞器 docker cp /opt/module/ik-analyzer b8bc77952780:/usr/share/elasticsearch/plugins/ docker cp /opt/module/ik-analyzer 17fc09305869:/usr/share/elasticsearch/plugins/ docker cp /opt/module/ik-analyzer 07ece64fc7d8:/usr/share/elasticsearch/plugins/
- 重新啓動ES集羣
docker restart b8bc77952780 17fc09305869 07ece64fc7d8
- 測試ik分詞效果
http://192.168.44.113:9200/_analyze?analyzer=ik_smart&pretty=true&text=我愛你中國
- 拉取ES UI鏡像
#拉取
docker pull mobz/elasticsearch-head:5
- 啓動ES UI鏡像
#啓動
docker run -p 9520:9100 --name es-ui -d b19a5c98e43b
- 訪問ES的UI工具並鏈接ES集羣
#UI地址
http://192.168.44.113:9520/