docker指南系列之部署elasticsearch

版本信息

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

创建elasticsearch挂载目录

mkdir /opt/elasticsearch/data /opt/elasticsearch/config /opt/elasticsearch/plugins /opt/elasticsearch/logs

创建elasticsearch.yml内容如下

http.host: 0.0.0.0
##集群名称 所有节点要相同
cluster.name: "sunce-es"
##本节点名称
node.name: master
##作为master节点
node.master: true
##是否存储数据
node.data: true
##设置可以访问的ip 这里全部设置通过
network.host: 0.0.0.0
http.port: 9200
network.bind_host: 0.0.0.0
##设置单节点
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

# 执行以下命令,可以立即生效
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

你可能感兴趣的:(docker指南系列之部署elasticsearch)