系列文章:【建议从第二章开始】
【ELK】【docker】【elasticsearch】1. 使用Docker和Elasticsearch+ kibana 5.6.9 搭建全文本搜索引擎应用 集群,安装ik分词器
【ELK】【ElasticSearch】3.es入门基本操作
【ELK】4.spring boot 2.X集成ES spring-data-ES 进行CRUD操作 完整版+kibana管理ES的index操作
【ELK】5.spring boot日志集成ELK,搭建日志系统
【ELK】【docker】6.Elasticsearch 集群启动多节点 + 解决ES节点集群状态为yellow
================================================================
使用Docker和Elasticsearch搭建全文本搜索引擎应用 集群
ElasticSearch Head是集群管理、数据可视化、增删查改、查询语句可视化工具
kibana与ElasticSearch Head 功能相似。
本章以kibana为例安装。
================================================================
在同一台centos7服务器上搭建
================================================================
1.阿里云docker查看镜像版本
https://dev.aliyun.com/search.html
直接输入elasticsearch 查询,查找docker认证的镜像,查找最新版本进行拉取
2.拉取elasticsearch镜像
docker pull elasticsearch:5.6.9
3.拉取kibana 插件【elasticSearch的可视化工具】【注意在阿里云docker查看镜像版本】的镜像
docker pull kibana:5.6.9
4.创建elasticSearch目录,在目录下分别创建es1-master.yml文件和es2.yml配置文件【用于挂载即将要启动的es实例,也就是docker容器启动以后实际使用的配置文件】【概念区分地址:https://www.cnblogs.com/sxdcgaq8080/p/10031169.html】
给es1-master.yml文件配置内容【完整配置介绍:https://www.cnblogs.com/sxdcgaq8080/p/10031744.html】
#es1 所有[K: V]V前面要加上空格,标点用英文
#集群名称 所有节点要相同
cluster.name: sxdEsCluster
#本节点名称
node.name: es1
#指定该节点是否有资格被选举成为master节点,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master
node.master: true
#是否存储数据
node.data: true
#针对node.master 和 node.data 属性设置,
#[如果为了减少master节点的选举时间,可以将有master节点资格的节点不存储数据,也就是node.master: true和node.data: false]
#[同理,就需要另外没有master资格的节点仅用于存储数据,也就是node.master: false和node.data: true]
# 可以让head插件 开启跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
#network.host 属性代表同时设置 network.publish_host 参数和 network.bind_host参数
#一般network.host 属性设置为0.0.0.0或者节点所在的实际IP
network.host: 0.0.0.0
#如果仅启动一个es实例,不需要做集群,则下面的几个参数注释掉即可,仅使用上面的属性即可
#本属性默认值为1,不设置集群的情况下,此参数也设置为1 即可。
#如果集群成功,则此参数的值=(集群中所有有资格选举为master的节点数/2)+1
discovery.zen.minimum_master_nodes: 2
#设置集群中自动发现其它节点时ping连接超时时间,默认为3秒,对于比较差的网络环境可以高点的值来防止自动发现时出错
discovery.zen.ping_timeout: 120s
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
#注意,如果是在不同IP下创建的es节点,这里的IP就填写的是宿主机的对外IP
#如果是在同一个IP下创建了多个docker容器es实例,则这里的IP就填写的是docker容器,也就是es实例自己的对其他容器所暴露的IP,而不是他们所在的宿主机的IP
discovery.zen.ping.unicast.hosts: ["127.0.0.1","172.17.0.2:9200","172.17.0.3:9201","172.17.0.2:9300","172.17.0.3:9301"]
回车 进去 i进入编辑状态 粘贴上面的文本 修改对应的名称和IP esc退出编辑模式 :wq保存并退出
同理,创建并编辑es2.yml配置文件【如果不做集群,仅使用上面的es1.yml配置即可,不用设置es2.yml,也不用启动es2】
#es2 所有[K: V]V前面要加上空格,标点用英文
#集群名称 所有节点要相同
cluster.name: sxdEsCluster
#本节点名称
node.name: es2
#指定该节点是否有资格被选举成为master节点,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master
node.master: true
#是否存储数据
node.data: true
# 可以让head插件 开启跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
#同时设置 network.publish_host 参数和 network.bind_host参数
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping_timeout: 120s
discovery.zen.ping.unicast.hosts: ["127.0.0.1","172.17.0.2:9200","172.17.0.3:9201","172.17.0.2:9300","172.17.0.3:9301"]
#因为在同一个IP下设置集群,所以需要设置端口与默认不同。如果不在同一个IP下增加es实例去加入集群,就不需要下面的这些特别指定端口的参数
transport.tcp.port: 9301
http.port: 9201
接着, 分别创建主节点的数据目录es1_data和结点2的数据目录 es2_data,用于挂载docker实例的数据实际存储位置【概念区分:https://www.cnblogs.com/sxdcgaq8080/p/10031169.html】
5.分别启动节点1 和 节点2【关于运行命令的参数说明以及意义 https://www.cnblogs.com/sxdcgaq8080/p/10031169.html】
启动主节点
docker run -d --name es1 -p 9200:9200 -p 9300:9300 --restart=always -v /apps/elasticSearch/es1-master.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /apps/elasticSearch/es1_data:/usr/share/elasticsearch/data elasticsearch:5.6.9
查看es1实例的是否启动成功:
curl http://localhost:9200
或者可以通过: 查看容器启动的日志
从日志可以看出来,集群配置中要求的是两个主节点,但是只找到一个主节点。
docker logs -f es1
访问地址查看本节点是否启动正常:
http://192.168.92.130:9200/_nodes
{
"_nodes":{
"total":1,
"successful":1,
"failed":0
},
"cluster_name":"sxdEsCluster",
"nodes":{
"HVIejJKzSKmiw0_QIMxRZQ":{
"name":"es1",
"transport_address":"172.17.0.2:9300",
"host":"172.17.0.2",
"ip":"172.17.0.2",
"version":"5.6.9",
"build_hash":"877a590",
"total_indexing_buffer":213876736,
"roles":[
"master",
"data",
"ingest"
],
"settings":{
"cluster":{
"name":"sxdEsCluster"
},
"node":{
"data":"true",
"name":"es1",
"master":"true"
},
"path":{
"logs":"/usr/share/elasticsearch/logs",
"home":"/usr/share/elasticsearch"
},
"discovery":{
"zen":{
"minimum_master_nodes":"2",
"ping":{
"unicast":{
"hosts":[
"127.0.0.1",
"172.17.0.2:9200",
"172.17.0.3:9201",
"172.17.0.2:9300",
"172.17.0.3:9301"
]
}
},
"ping_timeout":"120s"
}
},
"client":{
"type":"node"
},
"http":{
"type":{
"default":"netty4"
},
"cors":{
"allow-origin":"*",
"enabled":"true"
}
},
"transport":{
"type":{
"default":"netty4"
}
},
"network":{
"host":"0.0.0.0"
}
},
"os":{
"refresh_interval_in_millis":1000,
"name":"Linux",
"arch":"amd64",
"version":"3.10.0-862.11.6.el7.x86_64",
"available_processors":1,
"allocated_processors":1
},
"process":{
"refresh_interval_in_millis":1000,
"id":1,
"mlockall":false
},
"jvm":{
"pid":1,
"version":"1.8.0_171",
"vm_name":"OpenJDK 64-Bit Server VM",
"vm_version":"25.171-b11",
"vm_vendor":"Oracle Corporation",
"start_time_in_millis":1543482230302,
"mem":{
"heap_init_in_bytes":2147483648,
"heap_max_in_bytes":2138767360,
"non_heap_init_in_bytes":2555904,
"non_heap_max_in_bytes":0,
"direct_max_in_bytes":2138767360
},
"gc_collectors":[
"ParNew",
"ConcurrentMarkSweep"
],
"memory_pools":[
"Code Cache",
"Metaspace",
"Compressed Class Space",
"Par Eden Space",
"Par Survivor Space",
"CMS Old Gen"
],
"using_compressed_ordinary_object_pointers":"true",
"input_arguments":[
"-Xms2g",
"-Xmx2g",
"-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=75",
"-XX:+UseCMSInitiatingOccupancyOnly",
"-XX:+AlwaysPreTouch",
"-Xss1m",
"-Djava.awt.headless=true",
"-Dfile.encoding=UTF-8",
"-Djna.nosys=true",
"-Djdk.io.permissionsUseCanonicalPath=true",
"-Dio.netty.noUnsafe=true",
"-Dio.netty.noKeySetOptimization=true",
"-Dio.netty.recycler.maxCapacityPerThread=0",
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",
"-Dlog4j.skipJansi=true",
"-XX:+HeapDumpOnOutOfMemoryError",
"-Des.path.home=/usr/share/elasticsearch"
]
},
"thread_pool":{
"force_merge":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"fetch_shard_started":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"listener":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"index":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"refresh":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"generic":{
"type":"scaling",
"min":4,
"max":128,
"keep_alive":"30s",
"queue_size":-1
},
"warmer":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"search":{
"type":"fixed",
"min":2,
"max":2,
"queue_size":1000
},
"flush":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"fetch_shard_store":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"management":{
"type":"scaling",
"min":1,
"max":5,
"keep_alive":"5m",
"queue_size":-1
},
"get":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":1000
},
"bulk":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"snapshot":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
}
},
"transport":{
"bound_address":[
"0.0.0.0:9300"
],
"publish_address":"172.17.0.2:9300",
"profiles":{ }
},
"http":{
"bound_address":[
"0.0.0.0:9200"
],
"publish_address":"172.17.0.2:9200",
"max_content_length_in_bytes":104857600
},
"plugins":[ ],
"modules":[
{
"name":"aggs-matrix-stats",
"version":"5.6.9",
"description":"Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
"classname":"org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin",
"has_native_controller":false
},
{
"name":"ingest-common",
"version":"5.6.9",
"description":"Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
"classname":"org.elasticsearch.ingest.common.IngestCommonPlugin",
"has_native_controller":false
},
{
"name":"lang-expression",
"version":"5.6.9",
"description":"Lucene expressions integration for Elasticsearch",
"classname":"org.elasticsearch.script.expression.ExpressionPlugin",
"has_native_controller":false
},
{
"name":"lang-groovy",
"version":"5.6.9",
"description":"Groovy scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.groovy.GroovyPlugin",
"has_native_controller":false
},
{
"name":"lang-mustache",
"version":"5.6.9",
"description":"Mustache scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.mustache.MustachePlugin",
"has_native_controller":false
},
{
"name":"lang-painless",
"version":"5.6.9",
"description":"An easy, safe and fast scripting language for Elasticsearch",
"classname":"org.elasticsearch.painless.PainlessPlugin",
"has_native_controller":false
},
{
"name":"parent-join",
"version":"5.6.9",
"description":"This module adds the support parent-child queries and aggregations",
"classname":"org.elasticsearch.join.ParentJoinPlugin",
"has_native_controller":false
},
{
"name":"percolator",
"version":"5.6.9",
"description":"Percolator module adds capability to index queries and query these queries by specifying documents",
"classname":"org.elasticsearch.percolator.PercolatorPlugin",
"has_native_controller":false
},
{
"name":"reindex",
"version":"5.6.9",
"description":"The Reindex module adds APIs to reindex from one index to another or update documents in place.",
"classname":"org.elasticsearch.index.reindex.ReindexPlugin",
"has_native_controller":false
},
{
"name":"transport-netty3",
"version":"5.6.9",
"description":"Netty 3 based transport implementation",
"classname":"org.elasticsearch.transport.Netty3Plugin",
"has_native_controller":false
},
{
"name":"transport-netty4",
"version":"5.6.9",
"description":"Netty 4 based transport implementation",
"classname":"org.elasticsearch.transport.Netty4Plugin",
"has_native_controller":false
}
],
"ingest":{
"processors":[
{
"type":"append"
},
{
"type":"convert"
},
{
"type":"date"
},
{
"type":"date_index_name"
},
{
"type":"dot_expander"
},
{
"type":"fail"
},
{
"type":"foreach"
},
{
"type":"grok"
},
{
"type":"gsub"
},
{
"type":"join"
},
{
"type":"json"
},
{
"type":"kv"
},
{
"type":"lowercase"
},
{
"type":"remove"
},
{
"type":"rename"
},
{
"type":"script"
},
{
"type":"set"
},
{
"type":"sort"
},
{
"type":"split"
},
{
"type":"trim"
},
{
"type":"uppercase"
}
]
}
}
}
}
可以看到 本节点启动是正常的。
可以通过命令查看集群是否启动正常
curl '192.168.92.130:9200/_cluster/health?pretty'
因为上面的配置中设置集群中最少要有两个主节点,discovery.zen.minimum_master_nodes: 2
另一个节点未启动的情况下,检测集群健康发现异常
启动es2节点
docker run -d --name es2 -p 9201:9201 -p 9301:9301 --restart=always -v /apps/elasticSearch/es2.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /apps/elasticSearch/es2_data:/usr/share/elasticsearch/data elasticsearch:5.6.9
查看容器启动情况
docker ps -a
查看集群启动情况:
curl '192.168.92.130:9201/_cluster/health?pretty'
稍等一会再输入一次查看
可以看到集群启动成功,状态是green.
节点数量是2个,数据存储节点数量也是2个
status
字段提供一个综合的指标来表示集群的的服务状况。三种颜色各自的含义:
颜色 | 意义 |
---|---|
green |
所有主要分片和复制分片都可用 |
yellow |
所有主要分片可用,但不是所有复制分片都可用 |
red |
不是所有的主要分片都可用 |
此时可以再通过地址访问,查看节点的启动情况:
http://192.168.92.130:9200/_nodes
{
"_nodes":{
"total":2,
"successful":2,
"failed":0
},
"cluster_name":"sxdEsCluster",
"nodes":{
"kJv6SNk8S9auyBEXoAbhCw":{
"name":"es2",
"transport_address":"172.17.0.3:9301",
"host":"172.17.0.3",
"ip":"172.17.0.3",
"version":"5.6.9",
"build_hash":"877a590",
"total_indexing_buffer":213876736,
"roles":[
"master",
"data",
"ingest"
],
"settings":{
"cluster":{
"name":"sxdEsCluster"
},
"node":{
"data":"true",
"name":"es2",
"master":"true"
},
"path":{
"logs":"/usr/share/elasticsearch/logs",
"home":"/usr/share/elasticsearch"
},
"discovery":{
"zen":{
"minimum_master_nodes":"2",
"ping":{
"unicast":{
"hosts":[
"127.0.0.1",
"172.17.0.2:9200",
"172.17.0.3:9201",
"172.17.0.2:9300",
"172.17.0.3:9301"
]
}
},
"ping_timeout":"120s"
}
},
"client":{
"type":"node"
},
"http":{
"type":{
"default":"netty4"
},
"port":"9201",
"cors":{
"allow-origin":"*",
"enabled":"true"
}
},
"transport":{
"tcp":{
"port":"9301"
},
"type":{
"default":"netty4"
}
},
"network":{
"host":"0.0.0.0"
}
},
"os":{
"refresh_interval_in_millis":1000,
"name":"Linux",
"arch":"amd64",
"version":"3.10.0-862.11.6.el7.x86_64",
"available_processors":1,
"allocated_processors":1
},
"process":{
"refresh_interval_in_millis":1000,
"id":1,
"mlockall":false
},
"jvm":{
"pid":1,
"version":"1.8.0_171",
"vm_name":"OpenJDK 64-Bit Server VM",
"vm_version":"25.171-b11",
"vm_vendor":"Oracle Corporation",
"start_time_in_millis":1543483639872,
"mem":{
"heap_init_in_bytes":2147483648,
"heap_max_in_bytes":2138767360,
"non_heap_init_in_bytes":2555904,
"non_heap_max_in_bytes":0,
"direct_max_in_bytes":2138767360
},
"gc_collectors":[
"ParNew",
"ConcurrentMarkSweep"
],
"memory_pools":[
"Code Cache",
"Metaspace",
"Compressed Class Space",
"Par Eden Space",
"Par Survivor Space",
"CMS Old Gen"
],
"using_compressed_ordinary_object_pointers":"true",
"input_arguments":[
"-Xms2g",
"-Xmx2g",
"-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=75",
"-XX:+UseCMSInitiatingOccupancyOnly",
"-XX:+AlwaysPreTouch",
"-Xss1m",
"-Djava.awt.headless=true",
"-Dfile.encoding=UTF-8",
"-Djna.nosys=true",
"-Djdk.io.permissionsUseCanonicalPath=true",
"-Dio.netty.noUnsafe=true",
"-Dio.netty.noKeySetOptimization=true",
"-Dio.netty.recycler.maxCapacityPerThread=0",
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",
"-Dlog4j.skipJansi=true",
"-XX:+HeapDumpOnOutOfMemoryError",
"-Des.path.home=/usr/share/elasticsearch"
]
},
"thread_pool":{
"force_merge":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"fetch_shard_started":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"listener":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"index":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"refresh":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"generic":{
"type":"scaling",
"min":4,
"max":128,
"keep_alive":"30s",
"queue_size":-1
},
"warmer":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"search":{
"type":"fixed",
"min":2,
"max":2,
"queue_size":1000
},
"flush":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"fetch_shard_store":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"management":{
"type":"scaling",
"min":1,
"max":5,
"keep_alive":"5m",
"queue_size":-1
},
"get":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":1000
},
"bulk":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"snapshot":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
}
},
"transport":{
"bound_address":[
"0.0.0.0:9301"
],
"publish_address":"172.17.0.3:9301",
"profiles":{ }
},
"http":{
"bound_address":[
"0.0.0.0:9201"
],
"publish_address":"172.17.0.3:9201",
"max_content_length_in_bytes":104857600
},
"plugins":[ ],
"modules":[
{
"name":"aggs-matrix-stats",
"version":"5.6.9",
"description":"Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
"classname":"org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin",
"has_native_controller":false
},
{
"name":"ingest-common",
"version":"5.6.9",
"description":"Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
"classname":"org.elasticsearch.ingest.common.IngestCommonPlugin",
"has_native_controller":false
},
{
"name":"lang-expression",
"version":"5.6.9",
"description":"Lucene expressions integration for Elasticsearch",
"classname":"org.elasticsearch.script.expression.ExpressionPlugin",
"has_native_controller":false
},
{
"name":"lang-groovy",
"version":"5.6.9",
"description":"Groovy scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.groovy.GroovyPlugin",
"has_native_controller":false
},
{
"name":"lang-mustache",
"version":"5.6.9",
"description":"Mustache scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.mustache.MustachePlugin",
"has_native_controller":false
},
{
"name":"lang-painless",
"version":"5.6.9",
"description":"An easy, safe and fast scripting language for Elasticsearch",
"classname":"org.elasticsearch.painless.PainlessPlugin",
"has_native_controller":false
},
{
"name":"parent-join",
"version":"5.6.9",
"description":"This module adds the support parent-child queries and aggregations",
"classname":"org.elasticsearch.join.ParentJoinPlugin",
"has_native_controller":false
},
{
"name":"percolator",
"version":"5.6.9",
"description":"Percolator module adds capability to index queries and query these queries by specifying documents",
"classname":"org.elasticsearch.percolator.PercolatorPlugin",
"has_native_controller":false
},
{
"name":"reindex",
"version":"5.6.9",
"description":"The Reindex module adds APIs to reindex from one index to another or update documents in place.",
"classname":"org.elasticsearch.index.reindex.ReindexPlugin",
"has_native_controller":false
},
{
"name":"transport-netty3",
"version":"5.6.9",
"description":"Netty 3 based transport implementation",
"classname":"org.elasticsearch.transport.Netty3Plugin",
"has_native_controller":false
},
{
"name":"transport-netty4",
"version":"5.6.9",
"description":"Netty 4 based transport implementation",
"classname":"org.elasticsearch.transport.Netty4Plugin",
"has_native_controller":false
}
],
"ingest":{
"processors":[
{
"type":"append"
},
{
"type":"convert"
},
{
"type":"date"
},
{
"type":"date_index_name"
},
{
"type":"dot_expander"
},
{
"type":"fail"
},
{
"type":"foreach"
},
{
"type":"grok"
},
{
"type":"gsub"
},
{
"type":"join"
},
{
"type":"json"
},
{
"type":"kv"
},
{
"type":"lowercase"
},
{
"type":"remove"
},
{
"type":"rename"
},
{
"type":"script"
},
{
"type":"set"
},
{
"type":"sort"
},
{
"type":"split"
},
{
"type":"trim"
},
{
"type":"uppercase"
}
]
}
},
"HVIejJKzSKmiw0_QIMxRZQ":{
"name":"es1",
"transport_address":"172.17.0.2:9300",
"host":"172.17.0.2",
"ip":"172.17.0.2",
"version":"5.6.9",
"build_hash":"877a590",
"total_indexing_buffer":213876736,
"roles":[
"master",
"data",
"ingest"
],
"settings":{
"cluster":{
"name":"sxdEsCluster"
},
"node":{
"data":"true",
"name":"es1",
"master":"true"
},
"path":{
"logs":"/usr/share/elasticsearch/logs",
"home":"/usr/share/elasticsearch"
},
"discovery":{
"zen":{
"minimum_master_nodes":"2",
"ping":{
"unicast":{
"hosts":[
"127.0.0.1",
"172.17.0.2:9200",
"172.17.0.3:9201",
"172.17.0.2:9300",
"172.17.0.3:9301"
]
}
},
"ping_timeout":"120s"
}
},
"client":{
"type":"node"
},
"http":{
"type":{
"default":"netty4"
},
"cors":{
"allow-origin":"*",
"enabled":"true"
}
},
"transport":{
"type":{
"default":"netty4"
}
},
"network":{
"host":"0.0.0.0"
}
},
"os":{
"refresh_interval_in_millis":1000,
"name":"Linux",
"arch":"amd64",
"version":"3.10.0-862.11.6.el7.x86_64",
"available_processors":1,
"allocated_processors":1
},
"process":{
"refresh_interval_in_millis":1000,
"id":1,
"mlockall":false
},
"jvm":{
"pid":1,
"version":"1.8.0_171",
"vm_name":"OpenJDK 64-Bit Server VM",
"vm_version":"25.171-b11",
"vm_vendor":"Oracle Corporation",
"start_time_in_millis":1543482230302,
"mem":{
"heap_init_in_bytes":2147483648,
"heap_max_in_bytes":2138767360,
"non_heap_init_in_bytes":2555904,
"non_heap_max_in_bytes":0,
"direct_max_in_bytes":2138767360
},
"gc_collectors":[
"ParNew",
"ConcurrentMarkSweep"
],
"memory_pools":[
"Code Cache",
"Metaspace",
"Compressed Class Space",
"Par Eden Space",
"Par Survivor Space",
"CMS Old Gen"
],
"using_compressed_ordinary_object_pointers":"true",
"input_arguments":[
"-Xms2g",
"-Xmx2g",
"-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=75",
"-XX:+UseCMSInitiatingOccupancyOnly",
"-XX:+AlwaysPreTouch",
"-Xss1m",
"-Djava.awt.headless=true",
"-Dfile.encoding=UTF-8",
"-Djna.nosys=true",
"-Djdk.io.permissionsUseCanonicalPath=true",
"-Dio.netty.noUnsafe=true",
"-Dio.netty.noKeySetOptimization=true",
"-Dio.netty.recycler.maxCapacityPerThread=0",
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",
"-Dlog4j.skipJansi=true",
"-XX:+HeapDumpOnOutOfMemoryError",
"-Des.path.home=/usr/share/elasticsearch"
]
},
"thread_pool":{
"force_merge":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"fetch_shard_started":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"listener":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"index":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"refresh":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"generic":{
"type":"scaling",
"min":4,
"max":128,
"keep_alive":"30s",
"queue_size":-1
},
"warmer":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"search":{
"type":"fixed",
"min":2,
"max":2,
"queue_size":1000
},
"flush":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"fetch_shard_store":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"management":{
"type":"scaling",
"min":1,
"max":5,
"keep_alive":"5m",
"queue_size":-1
},
"get":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":1000
},
"bulk":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"snapshot":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
}
},
"transport":{
"bound_address":[
"0.0.0.0:9300"
],
"publish_address":"172.17.0.2:9300",
"profiles":{ }
},
"http":{
"bound_address":[
"0.0.0.0:9200"
],
"publish_address":"172.17.0.2:9200",
"max_content_length_in_bytes":104857600
},
"plugins":[ ],
"modules":[
{
"name":"aggs-matrix-stats",
"version":"5.6.9",
"description":"Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
"classname":"org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin",
"has_native_controller":false
},
{
"name":"ingest-common",
"version":"5.6.9",
"description":"Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
"classname":"org.elasticsearch.ingest.common.IngestCommonPlugin",
"has_native_controller":false
},
{
"name":"lang-expression",
"version":"5.6.9",
"description":"Lucene expressions integration for Elasticsearch",
"classname":"org.elasticsearch.script.expression.ExpressionPlugin",
"has_native_controller":false
},
{
"name":"lang-groovy",
"version":"5.6.9",
"description":"Groovy scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.groovy.GroovyPlugin",
"has_native_controller":false
},
{
"name":"lang-mustache",
"version":"5.6.9",
"description":"Mustache scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.mustache.MustachePlugin",
"has_native_controller":false
},
{
"name":"lang-painless",
"version":"5.6.9",
"description":"An easy, safe and fast scripting language for Elasticsearch",
"classname":"org.elasticsearch.painless.PainlessPlugin",
"has_native_controller":false
},
{
"name":"parent-join",
"version":"5.6.9",
"description":"This module adds the support parent-child queries and aggregations",
"classname":"org.elasticsearch.join.ParentJoinPlugin",
"has_native_controller":false
},
{
"name":"percolator",
"version":"5.6.9",
"description":"Percolator module adds capability to index queries and query these queries by specifying documents",
"classname":"org.elasticsearch.percolator.PercolatorPlugin",
"has_native_controller":false
},
{
"name":"reindex",
"version":"5.6.9",
"description":"The Reindex module adds APIs to reindex from one index to another or update documents in place.",
"classname":"org.elasticsearch.index.reindex.ReindexPlugin",
"has_native_controller":false
},
{
"name":"transport-netty3",
"version":"5.6.9",
"description":"Netty 3 based transport implementation",
"classname":"org.elasticsearch.transport.Netty3Plugin",
"has_native_controller":false
},
{
"name":"transport-netty4",
"version":"5.6.9",
"description":"Netty 4 based transport implementation",
"classname":"org.elasticsearch.transport.Netty4Plugin",
"has_native_controller":false
}
],
"ingest":{
"processors":[
{
"type":"append"
},
{
"type":"convert"
},
{
"type":"date"
},
{
"type":"date_index_name"
},
{
"type":"dot_expander"
},
{
"type":"fail"
},
{
"type":"foreach"
},
{
"type":"grok"
},
{
"type":"gsub"
},
{
"type":"join"
},
{
"type":"json"
},
{
"type":"kv"
},
{
"type":"lowercase"
},
{
"type":"remove"
},
{
"type":"rename"
},
{
"type":"script"
},
{
"type":"set"
},
{
"type":"sort"
},
{
"type":"split"
},
{
"type":"trim"
},
{
"type":"uppercase"
}
]
}
}
}
}
通过另一个实例的端口访问查看:
http://192.168.92.130:9201/_nodes
{
"_nodes":{
"total":2,
"successful":2,
"failed":0
},
"cluster_name":"sxdEsCluster",
"nodes":{
"kJv6SNk8S9auyBEXoAbhCw":{
"name":"es2",
"transport_address":"172.17.0.3:9301",
"host":"172.17.0.3",
"ip":"172.17.0.3",
"version":"5.6.9",
"build_hash":"877a590",
"total_indexing_buffer":213876736,
"roles":[
"master",
"data",
"ingest"
],
"settings":{
"cluster":{
"name":"sxdEsCluster"
},
"node":{
"data":"true",
"name":"es2",
"master":"true"
},
"path":{
"logs":"/usr/share/elasticsearch/logs",
"home":"/usr/share/elasticsearch"
},
"discovery":{
"zen":{
"minimum_master_nodes":"2",
"ping":{
"unicast":{
"hosts":[
"127.0.0.1",
"172.17.0.2:9200",
"172.17.0.3:9201",
"172.17.0.2:9300",
"172.17.0.3:9301"
]
}
},
"ping_timeout":"120s"
}
},
"client":{
"type":"node"
},
"http":{
"type":{
"default":"netty4"
},
"port":"9201",
"cors":{
"allow-origin":"*",
"enabled":"true"
}
},
"transport":{
"tcp":{
"port":"9301"
},
"type":{
"default":"netty4"
}
},
"network":{
"host":"0.0.0.0"
}
},
"os":{
"refresh_interval_in_millis":1000,
"name":"Linux",
"arch":"amd64",
"version":"3.10.0-862.11.6.el7.x86_64",
"available_processors":1,
"allocated_processors":1
},
"process":{
"refresh_interval_in_millis":1000,
"id":1,
"mlockall":false
},
"jvm":{
"pid":1,
"version":"1.8.0_171",
"vm_name":"OpenJDK 64-Bit Server VM",
"vm_version":"25.171-b11",
"vm_vendor":"Oracle Corporation",
"start_time_in_millis":1543483639872,
"mem":{
"heap_init_in_bytes":2147483648,
"heap_max_in_bytes":2138767360,
"non_heap_init_in_bytes":2555904,
"non_heap_max_in_bytes":0,
"direct_max_in_bytes":2138767360
},
"gc_collectors":[
"ParNew",
"ConcurrentMarkSweep"
],
"memory_pools":[
"Code Cache",
"Metaspace",
"Compressed Class Space",
"Par Eden Space",
"Par Survivor Space",
"CMS Old Gen"
],
"using_compressed_ordinary_object_pointers":"true",
"input_arguments":[
"-Xms2g",
"-Xmx2g",
"-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=75",
"-XX:+UseCMSInitiatingOccupancyOnly",
"-XX:+AlwaysPreTouch",
"-Xss1m",
"-Djava.awt.headless=true",
"-Dfile.encoding=UTF-8",
"-Djna.nosys=true",
"-Djdk.io.permissionsUseCanonicalPath=true",
"-Dio.netty.noUnsafe=true",
"-Dio.netty.noKeySetOptimization=true",
"-Dio.netty.recycler.maxCapacityPerThread=0",
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",
"-Dlog4j.skipJansi=true",
"-XX:+HeapDumpOnOutOfMemoryError",
"-Des.path.home=/usr/share/elasticsearch"
]
},
"thread_pool":{
"force_merge":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"fetch_shard_started":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"listener":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"index":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"refresh":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"generic":{
"type":"scaling",
"min":4,
"max":128,
"keep_alive":"30s",
"queue_size":-1
},
"warmer":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"search":{
"type":"fixed",
"min":2,
"max":2,
"queue_size":1000
},
"flush":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"fetch_shard_store":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"management":{
"type":"scaling",
"min":1,
"max":5,
"keep_alive":"5m",
"queue_size":-1
},
"get":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":1000
},
"bulk":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"snapshot":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
}
},
"transport":{
"bound_address":[
"0.0.0.0:9301"
],
"publish_address":"172.17.0.3:9301",
"profiles":{ }
},
"http":{
"bound_address":[
"0.0.0.0:9201"
],
"publish_address":"172.17.0.3:9201",
"max_content_length_in_bytes":104857600
},
"plugins":[ ],
"modules":[
{
"name":"aggs-matrix-stats",
"version":"5.6.9",
"description":"Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
"classname":"org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin",
"has_native_controller":false
},
{
"name":"ingest-common",
"version":"5.6.9",
"description":"Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
"classname":"org.elasticsearch.ingest.common.IngestCommonPlugin",
"has_native_controller":false
},
{
"name":"lang-expression",
"version":"5.6.9",
"description":"Lucene expressions integration for Elasticsearch",
"classname":"org.elasticsearch.script.expression.ExpressionPlugin",
"has_native_controller":false
},
{
"name":"lang-groovy",
"version":"5.6.9",
"description":"Groovy scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.groovy.GroovyPlugin",
"has_native_controller":false
},
{
"name":"lang-mustache",
"version":"5.6.9",
"description":"Mustache scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.mustache.MustachePlugin",
"has_native_controller":false
},
{
"name":"lang-painless",
"version":"5.6.9",
"description":"An easy, safe and fast scripting language for Elasticsearch",
"classname":"org.elasticsearch.painless.PainlessPlugin",
"has_native_controller":false
},
{
"name":"parent-join",
"version":"5.6.9",
"description":"This module adds the support parent-child queries and aggregations",
"classname":"org.elasticsearch.join.ParentJoinPlugin",
"has_native_controller":false
},
{
"name":"percolator",
"version":"5.6.9",
"description":"Percolator module adds capability to index queries and query these queries by specifying documents",
"classname":"org.elasticsearch.percolator.PercolatorPlugin",
"has_native_controller":false
},
{
"name":"reindex",
"version":"5.6.9",
"description":"The Reindex module adds APIs to reindex from one index to another or update documents in place.",
"classname":"org.elasticsearch.index.reindex.ReindexPlugin",
"has_native_controller":false
},
{
"name":"transport-netty3",
"version":"5.6.9",
"description":"Netty 3 based transport implementation",
"classname":"org.elasticsearch.transport.Netty3Plugin",
"has_native_controller":false
},
{
"name":"transport-netty4",
"version":"5.6.9",
"description":"Netty 4 based transport implementation",
"classname":"org.elasticsearch.transport.Netty4Plugin",
"has_native_controller":false
}
],
"ingest":{
"processors":[
{
"type":"append"
},
{
"type":"convert"
},
{
"type":"date"
},
{
"type":"date_index_name"
},
{
"type":"dot_expander"
},
{
"type":"fail"
},
{
"type":"foreach"
},
{
"type":"grok"
},
{
"type":"gsub"
},
{
"type":"join"
},
{
"type":"json"
},
{
"type":"kv"
},
{
"type":"lowercase"
},
{
"type":"remove"
},
{
"type":"rename"
},
{
"type":"script"
},
{
"type":"set"
},
{
"type":"sort"
},
{
"type":"split"
},
{
"type":"trim"
},
{
"type":"uppercase"
}
]
}
},
"HVIejJKzSKmiw0_QIMxRZQ":{
"name":"es1",
"transport_address":"172.17.0.2:9300",
"host":"172.17.0.2",
"ip":"172.17.0.2",
"version":"5.6.9",
"build_hash":"877a590",
"total_indexing_buffer":213876736,
"roles":[
"master",
"data",
"ingest"
],
"settings":{
"cluster":{
"name":"sxdEsCluster"
},
"node":{
"data":"true",
"name":"es1",
"master":"true"
},
"path":{
"logs":"/usr/share/elasticsearch/logs",
"home":"/usr/share/elasticsearch"
},
"discovery":{
"zen":{
"minimum_master_nodes":"2",
"ping":{
"unicast":{
"hosts":[
"127.0.0.1",
"172.17.0.2:9200",
"172.17.0.3:9201",
"172.17.0.2:9300",
"172.17.0.3:9301"
]
}
},
"ping_timeout":"120s"
}
},
"client":{
"type":"node"
},
"http":{
"type":{
"default":"netty4"
},
"cors":{
"allow-origin":"*",
"enabled":"true"
}
},
"transport":{
"type":{
"default":"netty4"
}
},
"network":{
"host":"0.0.0.0"
}
},
"os":{
"refresh_interval_in_millis":1000,
"name":"Linux",
"arch":"amd64",
"version":"3.10.0-862.11.6.el7.x86_64",
"available_processors":1,
"allocated_processors":1
},
"process":{
"refresh_interval_in_millis":1000,
"id":1,
"mlockall":false
},
"jvm":{
"pid":1,
"version":"1.8.0_171",
"vm_name":"OpenJDK 64-Bit Server VM",
"vm_version":"25.171-b11",
"vm_vendor":"Oracle Corporation",
"start_time_in_millis":1543482230302,
"mem":{
"heap_init_in_bytes":2147483648,
"heap_max_in_bytes":2138767360,
"non_heap_init_in_bytes":2555904,
"non_heap_max_in_bytes":0,
"direct_max_in_bytes":2138767360
},
"gc_collectors":[
"ParNew",
"ConcurrentMarkSweep"
],
"memory_pools":[
"Code Cache",
"Metaspace",
"Compressed Class Space",
"Par Eden Space",
"Par Survivor Space",
"CMS Old Gen"
],
"using_compressed_ordinary_object_pointers":"true",
"input_arguments":[
"-Xms2g",
"-Xmx2g",
"-XX:+UseConcMarkSweepGC",
"-XX:CMSInitiatingOccupancyFraction=75",
"-XX:+UseCMSInitiatingOccupancyOnly",
"-XX:+AlwaysPreTouch",
"-Xss1m",
"-Djava.awt.headless=true",
"-Dfile.encoding=UTF-8",
"-Djna.nosys=true",
"-Djdk.io.permissionsUseCanonicalPath=true",
"-Dio.netty.noUnsafe=true",
"-Dio.netty.noKeySetOptimization=true",
"-Dio.netty.recycler.maxCapacityPerThread=0",
"-Dlog4j.shutdownHookEnabled=false",
"-Dlog4j2.disable.jmx=true",
"-Dlog4j.skipJansi=true",
"-XX:+HeapDumpOnOutOfMemoryError",
"-Des.path.home=/usr/share/elasticsearch"
]
},
"thread_pool":{
"force_merge":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"fetch_shard_started":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"listener":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":-1
},
"index":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"refresh":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"generic":{
"type":"scaling",
"min":4,
"max":128,
"keep_alive":"30s",
"queue_size":-1
},
"warmer":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"search":{
"type":"fixed",
"min":2,
"max":2,
"queue_size":1000
},
"flush":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
},
"fetch_shard_store":{
"type":"scaling",
"min":1,
"max":2,
"keep_alive":"5m",
"queue_size":-1
},
"management":{
"type":"scaling",
"min":1,
"max":5,
"keep_alive":"5m",
"queue_size":-1
},
"get":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":1000
},
"bulk":{
"type":"fixed",
"min":1,
"max":1,
"queue_size":200
},
"snapshot":{
"type":"scaling",
"min":1,
"max":1,
"keep_alive":"5m",
"queue_size":-1
}
},
"transport":{
"bound_address":[
"0.0.0.0:9300"
],
"publish_address":"172.17.0.2:9300",
"profiles":{ }
},
"http":{
"bound_address":[
"0.0.0.0:9200"
],
"publish_address":"172.17.0.2:9200",
"max_content_length_in_bytes":104857600
},
"plugins":[ ],
"modules":[
{
"name":"aggs-matrix-stats",
"version":"5.6.9",
"description":"Adds aggregations whose input are a list of numeric fields and output includes a matrix.",
"classname":"org.elasticsearch.search.aggregations.matrix.MatrixAggregationPlugin",
"has_native_controller":false
},
{
"name":"ingest-common",
"version":"5.6.9",
"description":"Module for ingest processors that do not require additional security permissions or have large dependencies and resources",
"classname":"org.elasticsearch.ingest.common.IngestCommonPlugin",
"has_native_controller":false
},
{
"name":"lang-expression",
"version":"5.6.9",
"description":"Lucene expressions integration for Elasticsearch",
"classname":"org.elasticsearch.script.expression.ExpressionPlugin",
"has_native_controller":false
},
{
"name":"lang-groovy",
"version":"5.6.9",
"description":"Groovy scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.groovy.GroovyPlugin",
"has_native_controller":false
},
{
"name":"lang-mustache",
"version":"5.6.9",
"description":"Mustache scripting integration for Elasticsearch",
"classname":"org.elasticsearch.script.mustache.MustachePlugin",
"has_native_controller":false
},
{
"name":"lang-painless",
"version":"5.6.9",
"description":"An easy, safe and fast scripting language for Elasticsearch",
"classname":"org.elasticsearch.painless.PainlessPlugin",
"has_native_controller":false
},
{
"name":"parent-join",
"version":"5.6.9",
"description":"This module adds the support parent-child queries and aggregations",
"classname":"org.elasticsearch.join.ParentJoinPlugin",
"has_native_controller":false
},
{
"name":"percolator",
"version":"5.6.9",
"description":"Percolator module adds capability to index queries and query these queries by specifying documents",
"classname":"org.elasticsearch.percolator.PercolatorPlugin",
"has_native_controller":false
},
{
"name":"reindex",
"version":"5.6.9",
"description":"The Reindex module adds APIs to reindex from one index to another or update documents in place.",
"classname":"org.elasticsearch.index.reindex.ReindexPlugin",
"has_native_controller":false
},
{
"name":"transport-netty3",
"version":"5.6.9",
"description":"Netty 3 based transport implementation",
"classname":"org.elasticsearch.transport.Netty3Plugin",
"has_native_controller":false
},
{
"name":"transport-netty4",
"version":"5.6.9",
"description":"Netty 4 based transport implementation",
"classname":"org.elasticsearch.transport.Netty4Plugin",
"has_native_controller":false
}
],
"ingest":{
"processors":[
{
"type":"append"
},
{
"type":"convert"
},
{
"type":"date"
},
{
"type":"date_index_name"
},
{
"type":"dot_expander"
},
{
"type":"fail"
},
{
"type":"foreach"
},
{
"type":"grok"
},
{
"type":"gsub"
},
{
"type":"join"
},
{
"type":"json"
},
{
"type":"kv"
},
{
"type":"lowercase"
},
{
"type":"remove"
},
{
"type":"rename"
},
{
"type":"script"
},
{
"type":"set"
},
{
"type":"sort"
},
{
"type":"split"
},
{
"type":"trim"
},
{
"type":"uppercase"
}
]
}
}
}
}
OK,此时,es集群正常启动,可以使用了!!!
6.启动kibana
docker run -d -p : --name kibana --link es1:elasticsearch -e ELASTICSEARCH_URL=http://172.17.0.4:9200 kibana:5.6.9
--link elasticSearch启动容器的名称:elasticsearch
-e ELASTICSEARCH_URL=http://172.17.0.4:9200 即 -e ELASTICSEARCH_URL=http://es容器的实际IP,而不是宿主机的IP:9200
启动后访问:【Kibana官方中文用户手册】
http://192.168.92.130:5601/status
如果没有问题,直接跳过这两个问题看启动成功页面。
问题1:
解决方法:
修改index pattern 为*
选择Time Filter field name
为第一个[i don't select ......]
然后Create
点击Discover
即可看到数据页面
问题2:
启动kibana后发现status是red
解决方法:
出现这种问题,一定是es实例,也就是es的docker容器启动出现可问题。
可能是集群没有发现主节点,或者是IP并没有配置正确。
因为文章最开始就说明了,是在同一台centos7服务器上搭建的!!!!!
所以,
1》》首先,按照上面的步骤,重新启动es实例。可以只启动一个,也可以启动集群。【启动集群的话,需要保证curl '192.168.92.130:9201/_cluster/health?pretty' 获取到的state是green,集群中节点数量需要和你启动的节点个数,类型对应上】
2》》启动kibana的命令
docker run -d -p : --name kibana --link es1:elasticsearch -e ELASTICSEARCH_URL=http://172.17.0.4:9200 kibana:5.6.9
IP地址需要配置正确,是es容器的对外IP,不是宿主机的IP或者localhost其他的都不行。
查看容器信息的命令:
在最后的IpAddress可以看到容器的ip
docker inspect es1
[root@centos7 elasticSearch]# docker inspect es1
[
{
"Id": "6fb1eec093f956f567811e4625c43e3d9b67536cb369a9ecd2b2edc6a241e9d6",
"Created": "2019-01-02T06:40:16.074743745Z",
"Path": "/docker-entrypoint.sh",
"Args": [
"elasticsearch"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": ,
"ExitCode": ,
"Error": "",
"StartedAt": "2019-01-02T06:40:16.709955379Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:5c1e1ecfe33a0c36387d02d145ae5d526d525c2a582b25b4c57efd92ea4b7150",
"ResolvConfPath": "/var/lib/docker/containers/6fb1eec093f956f567811e4625c43e3d9b67536cb369a9ecd2b2edc6a241e9d6/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/6fb1eec093f956f567811e4625c43e3d9b67536cb369a9ecd2b2edc6a241e9d6/hostname",
"HostsPath": "/var/lib/docker/containers/6fb1eec093f956f567811e4625c43e3d9b67536cb369a9ecd2b2edc6a241e9d6/hosts",
"LogPath": "/var/lib/docker/containers/6fb1eec093f956f567811e4625c43e3d9b67536cb369a9ecd2b2edc6a241e9d6/6fb1eec093f956f567811e4625c43e3d9b67536cb369a9ecd2b2edc6a241e9d6-json.log",
"Name": "/es1",
"RestartCount": ,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/apps/elasticSearch/es1-master.yml:/usr/share/elasticsearch/config/elasticsearch.yml",
"/apps/elasticSearch/es1_data:/usr/share/elasticsearch/data"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"9200/tcp": [
{
"HostIp": "",
"HostPort": ""
}
],
"9300/tcp": [
{
"HostIp": "",
"HostPort": ""
}
]
},
"RestartPolicy": {
"Name": "always",
"MaximumRetryCount":
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": ,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": ,
"Runtime": "runc",
"ConsoleSize": [
, ],
"Isolation": "",
"CpuShares": ,
"Memory": ,
"NanoCpus": ,
"CgroupParent": "",
"BlkioWeight": ,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": ,
"CpuQuota": ,
"CpuRealtimePeriod": ,
"CpuRealtimeRuntime": ,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DiskQuota": ,
"KernelMemory": ,
"MemoryReservation": ,
"MemorySwap": ,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": ,
"Ulimits": null,
"CpuCount": ,
"CpuPercent": ,
"IOMaximumIOps": ,
"IOMaximumBandwidth": ,
"MaskedPaths": [
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/asound",
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/114eea2ec7c661e884a9facf89a5290d3810d3f9fe58773864dee2493e7f4841-init/diff:/var/lib/docker/overlay2/8060e8c919d3d142b96273ed1c011db88c12118dd6e99817a84e2056fc1eab8e/diff:/var/lib/docker/overlay2/a1e589afaf70da5c8811955aec318c45082af34786cbfc4623a1dd5148726e56/diff:/var/lib/docker/overlay2/dd7ba2d1c538455542fc6f52047a12639d38a325d9f1220e874fc6e204ad2fff/diff:/var/lib/docker/overlay2/f6214e33ccdce407ea5d30695ababf3b2bd28220728ddc0848baf8fdc5a96222/diff:/var/lib/docker/overlay2/2b7a8e48db54b5601e2774d2cccdecdf34b8be9d87fedbc6c561343759731a25/diff:/var/lib/docker/overlay2/d6085ec13ad199da1f14382cbaa7d1907385677e6070117ed3b0a806b6a82713/diff:/var/lib/docker/overlay2/67b6479831bf8feccf2bee2f15de2b5ccdaed74e2d42d44f98724a4c52af609a/diff:/var/lib/docker/overlay2/9b62a67ab74fcf808473fb76f8d74bd947766387b0c63ff8d144ae8cf2541c83/diff:/var/lib/docker/overlay2/2450c333257946e6baf3968190fb14e0ad6c508932e86eacf3193395bfa37cdd/diff:/var/lib/docker/overlay2/55134eff079e19a7f5a69073d1e1fc25ac5e47254a0bc2ca8ea6f291b029771f/diff:/var/lib/docker/overlay2/3dadce2050e8b3c80e95ff4bdb2260e5b42c7dcc5a74bcad72cfc047e4e109e3/diff:/var/lib/docker/overlay2/71f2bcbc914bc115fea4836af61b3aeea8aff082997962563f2f5aa3a058ae77/diff:/var/lib/docker/overlay2/b9092ddab1c9366b4ae660b4c7b69cfd4db9fe0a03b78c77198017b68c928b2b/diff:/var/lib/docker/overlay2/1b2eb5228b80824ba3bdb3495b3b15ca060b2154f6c57fdbe9891846449fe11b/diff:/var/lib/docker/overlay2/e766d9e1b56b98a05dbcc86f0a0aa49036f66aafcdaedacd0e8f24c2be9ace87/diff",
"MergedDir": "/var/lib/docker/overlay2/114eea2ec7c661e884a9facf89a5290d3810d3f9fe58773864dee2493e7f4841/merged",
"UpperDir": "/var/lib/docker/overlay2/114eea2ec7c661e884a9facf89a5290d3810d3f9fe58773864dee2493e7f4841/diff",
"WorkDir": "/var/lib/docker/overlay2/114eea2ec7c661e884a9facf89a5290d3810d3f9fe58773864dee2493e7f4841/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/apps/elasticSearch/es1-master.yml",
"Destination": "/usr/share/elasticsearch/config/elasticsearch.yml",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/apps/elasticSearch/es1_data",
"Destination": "/usr/share/elasticsearch/data",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "6fb1eec093f9",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"9200/tcp": {},
"9300/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/share/elasticsearch/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"JAVA_HOME=/docker-java-home/jre",
"JAVA_VERSION=8u171",
"JAVA_DEBIAN_VERSION=8u171-b11-1~deb9u1",
"CA_CERTIFICATES_JAVA_VERSION=20170531+nmu1",
"GOSU_VERSION=1.10",
"ELASTICSEARCH_VERSION=5.6.9",
"ELASTICSEARCH_DEB_VERSION=5.6.9"
],
"Cmd": [
"elasticsearch"
],
"ArgsEscaped": true,
"Image": "elasticsearch:5.6.9",
"Volumes": {
"/usr/share/elasticsearch/data": {}
},
"WorkingDir": "/usr/share/elasticsearch",
"Entrypoint": [
"/docker-entrypoint.sh"
],
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "13dd60ea0562a1b86ca0e7e708e0e7e92de1e9b9b472ef102490dbcedc0c54a7",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": ,
"Ports": {
"9200/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": ""
}
],
"9300/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": ""
}
]
},
"SandboxKey": "/var/run/docker/netns/13dd60ea0562",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "ca85232ef162fc061abaf34a48c28e47cd5d13e142be531b6f96cf8e9dc6f2f0",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": ,
"IPAddress": "172.17.0.4",
"IPPrefixLen": ,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:04",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "b942e48bda56ff9923d3e4b6b33ce9cfbdce24abde1fd34764b86c69d61f2d82",
"EndpointID": "ca85232ef162fc061abaf34a48c28e47cd5d13e142be531b6f96cf8e9dc6f2f0",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": ,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": ,
"MacAddress": "02:42:ac:11:00:04",
"DriverOpts": null
}
}
}
}
]
只要保证es(单实例或集群服务)启动没有问题,并且kibana启动配置的IP是容器的IP。就不会出现这个问题!!!
启动成功页面如下:
7.安装ik分词器到es中
方法1:【推荐使用方法1】
首先进入es1容器中
sudo docker exec -it es1 /bin/bash
进入插件目录
cd plugins/
下载ik插件【注意版本问题】
wget http://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.9/elasticsearch-analysis-ik-5.6.9.zip
解压
unzip elasticsearch-analysis-ik-5.6..zip
删除压缩包
rm elasticsearch-analysis-ik-5.6..zip
退出容器
exit
重启es容器
docker restart es1
查看启动日志
docker logs -f es1
插件加载成功
方法2:
注意:方法2可能会出现重启es后报错
java.io.FileNotFoundException: /usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml (No such file or directory)
的问题
[--02T07::,][INFO ][o.w.a.d.Monitor ] try load config from /usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml
[--02T07::,][INFO ][o.w.a.d.Monitor ] try load config from /usr/share/elasticsearch/plugins/analysis-ik/config/IKAnalyzer.cfg.xml
[--02T07::,][ERROR][o.w.a.d.Monitor ] ik-analyzer
java.io.FileNotFoundException: /usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml (No such file or directory)
at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_171]
at java.io.FileInputStream.open(FileInputStream.java:) ~[?:1.8.0_171]
at java.io.FileInputStream.<init>(FileInputStream.java:) ~[?:1.8.0_171]
at org.wltea.analyzer.dic.Dictionary.<init>(Dictionary.java:) ~[?:?]
at org.wltea.analyzer.dic.Dictionary.initial(Dictionary.java:) ~[?:?]
at org.wltea.analyzer.cfg.Configuration.<init>(Configuration.java:) ~[?:?]
at org.elasticsearch.index.analysis.IkTokenizerFactory.<init>(IkTokenizerFactory.java:) ~[?:?]
at org.elasticsearch.index.analysis.IkTokenizerFactory.getIkSmartTokenizerFactory(IkTokenizerFactory.java:) ~[?:?]
at org.elasticsearch.index.analysis.AnalysisRegistry.buildMapping(AnalysisRegistry.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.index.analysis.AnalysisRegistry.buildTokenizerFactories(AnalysisRegistry.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.index.analysis.AnalysisRegistry.build(AnalysisRegistry.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.index.IndexService.<init>(IndexService.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.index.IndexModule.newIndexService(IndexModule.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.indices.IndicesService.createIndexService(IndicesService.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.indices.IndicesService.verifyIndexMetadata(IndicesService.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.gateway.Gateway.performStateRecovery(Gateway.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.gateway.GatewayService$.doRun(GatewayService.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:) [elasticsearch-5.6..jar:5.6.]
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:) [elasticsearch-5.6..jar:5.6.]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:) [?:1.8.0_171]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:) [?:1.8.0_171]
at java.lang.Thread.run(Thread.java:) [?:1.8.0_171]
[--02T07::,][ERROR][o.w.a.d.Monitor ] /usr/share/elasticsearch/plugins/analysis-ik/config/main.dic (No such file or directory)
java.io.FileNotFoundException: /usr/share/elasticsearch/plugins/analysis-ik/config/main.dic (No such file or directory)
首先进入es的docker容器中
docker exec -it es1 /bin/bash
解释:docker exec -it es容器名称 /bin/bash
可以看到有plugins目录,插件目录,此时里面为空
然后将ik分词器安装到es容器中
键入命令:【注意对应es的版本,ik官网:https://github.com/medcl/elasticsearch-analysis-ik】
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.9/elasticsearch-analysis-ik-5.6.9.zip
如下:
安装完成后,退出重启容器即可
查看启动日志可以看到ik分词器插件已经加载
===========================================================================================================
基本概念完整参考地址:https://www.cnblogs.com/sxdcgaq8080/p/10207262.html
一些基本概念:
Node 与 Cluster
ElasticSearch 本质上是一个分布式数据库,允许多台服务器协同工作,每台服务器可以运行多个 Elastic 实例。
单个 Elastic 实例称为一个节点(node)。一组节点构成一个集群(cluster)。
Index[对应数据库的概念]
Elastic 数据管理的顶层单位就叫做 Index(索引)。它是单个数据库的同义词。每个 Index (即数据库)的名字必须是小写。
Type[对应数据表的概念]
Document[对应行的概念]
Index 里面单条的记录称为 Document(文档)。许多条 Document 构成了一个 Index。
Document 使用 JSON 格式表示
同一个 Index 里面的 Document,不要求有相同的结构(scheme),但是最好保持相同,这样有利于提高搜索效率。
Fields[对应列的概念]
每个文档可以包含多个字段(fields,对应于“列”)
===========================================================================================================
参考地址:http://dockone.io/article/3655