docker安装Elasticsearch:6.x + Kibana:6.x

文章写得有些懵懂, 请谅解!
安装Elasticsearch:6.4.2

docker pull elasticsearch:6.4.2

在启动Elasticsearch之前,需要配置系统中的线程数,否则报以下的错误:
# sysctl settings are defined through files in [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2]: 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
以CentOS7为例:

# 1.在cnetos虚拟机中,修改配置sysctl.conf
vi /etc/sysctl.conf
# 2.加入如下配置
vm.max_map_count=262144
# 3.启用配置
sysctl -p

然后启动Elasticsearch

docker run -p 9200:9200 -p 9300:9300 --name es -d elasticsearch:6.4.2

接着使用浏览器访问vmhost-ip:9200看到以下内容表示启动成功了

{
  name: "B61A5Gw",
  cluster_name: "docker-cluster",
  cluster_uuid: "VKtL4GQGR-W68xBCfSHgew",
    version: {
    number: "6.4.2",
    build_flavor: "default",
    build_type: "tar",
    build_hash: "04711c2",
    build_date: "2018-09-26T13:34:09.098244Z",
    build_snapshot: false,
    lucene_version: "7.4.0",
    minimum_wire_compatibility_version: "5.6.0",
    minimum_index_compatibility_version: "5.0.0"
  },
  tagline: "You Know, for Search"
}

运行Elasticsearch并拷贝相关文件

docker cp es:/usr/share/elasticsearch/data /root/es
cd /root/es
mkdir data && mv nodes data

docker stop es && docker rm es

注意: 下载ik时,需要与elasticsearch版本一致

# 运行并挂载相关文件目录
# ES_JAVA_OPTS="-Xms128m -Xmx128m" 根据你的虚拟机内存大小设置
docker run -p 9200:9200 -p 9300:9300 --name es -e ES_JAVA_OPTS="-Xms128m -Xmx128m" -v /root/es/plugins:/usr/share/elasticsearch/plugins -v /root/es/data:/usr/share/elasticsearch/data -d elasticsearch:6.4.2

# 接着
cd /root/es/plugins

# 下载ik
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.2/elasticsearch-analysis-ik-6.4.2.zip

# 解压elasticsearch-analysis-ik-6.4.2.zip 到ik文件中
unzip elasticsearch-analysis-ik-6.4.2.zip -d ik

# 删除 elasticsearch-analysis-ik-6.4.2.zip
rm -f  elasticsearch-analysis-ik-6.4.2.zip

# 重新启动elasticsearch 让 ik插件生效
docker restart es

# 浏览器再次访问9200确保重启没有报错

安装Kibana:6.4.2客户端工具

# 安装kibana
docker pull kibana:6.4.2

# 运行kibana, 指定elasticsearch:9200
# vmhost-ip表示你的虚拟机ip
docker run --name ik -e ELASTICSEARCH_URL=http://vmhost-ip:9200 -p 5601:5601 -d kibana:6.4.2

浏览器访问kibana端口5601出现以下界面就表示成功了


1593485131996.jpg

你可能感兴趣的:(docker安装Elasticsearch:6.x + Kibana:6.x)