版本信息
docker版本信息
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7f2769b/1.13.1
Built: Sun Sep 15 14:06:47 2019
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7f2769b/1.13.1
Built: Sun Sep 15 14:06:47 2019
OS/Arch: linux/amd64
Experimental: false
elasticsearch版本信息
{
"name" : "master",
"cluster_name" : "sunce-es",
"cluster_uuid" : "qplO6_G6QsyGx1RBYC2z4g",
"version" : {
"number" : "7.4.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
"build_date" : "2019-10-28T20:40:44.881551Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
啟動elasticsearch鏡像
搜索elasticsearch鏡像
docker search elasticsearch
下載elasticsearch鏡像
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.4.2
創(chuàng)建elasticsearch掛載目錄
mkdir /opt/elasticsearch/data /opt/elasticsearch/config /opt/elasticsearch/plugins /opt/elasticsearch/logs
創(chuàng)建elasticsearch.yml內容如下
http.host: 0.0.0.0
##集群名稱 所有節(jié)點要相同
cluster.name: "sunce-es"
##本節(jié)點名稱
node.name: master
##作為master節(jié)點
node.master: true
##是否存儲數(shù)據
node.data: true
##設置可以訪問的ip 這里全部設置通過
network.host: 0.0.0.0
http.port: 9200
network.bind_host: 0.0.0.0
##設置單節(jié)點
discovery.type: single-node
啟動elasticsearch鏡像
docker run -d -p 9200:200 -p 9300:9300 --name es1
-v /etc/localtime:/etc/localtime
-v /opt/elasticsearch/config/elasticsearch.yml::/usr/share/elasticsearch/config/elasticsearch.yml
-v /opt/elasticsearch/data:/usr/share/elasticsearch/data
-v /opt/elasticsearch/plugins::/usr/share/elasticsearch/logs
-v /opt/elasticsearch/plugins:/usr/share/elasticsearch/plugins docker.elastic.co/elasticsearch/elasticsearch:7.4.2
下載ik中文分詞器
進入es命令行
docker exec -it es1 /bin/sh
進入bin目錄下
elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.4.2/elasticsearch-analysis-ik-7.4.2.zip
重新啟動容器elasticsearch鏡像
docker restart es1
常見問題
錯誤描述
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
錯誤解決
# 設置/etc/sysctl.conf:
vm.max_map_count=262144
# 執(zhí)行以下命令省核,可以立即生效
sysctl -w vm.max_map_count=262144
錯誤描述
the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
錯誤解決
# 設置elasticsearch.yml
discovery.type: single-node