系列文章:【建議從第二章開始】html
【ELK】【docker】【elasticsearch】1. 使用Docker和Elasticsearch+ kibana 5.6.9 搭建全文本搜索引擎應用 集羣,安裝ik分詞器java
【ELK】【ElasticSearch】3.es入門基本操做linux
【ELK】4.spring boot 2.X集成ES spring-data-ES 進行CRUD操做 完整版+kibana管理ES的index操做git
【ELK】5.spring boot日誌集成ELK,搭建日誌系統github
【ELK】【docker】6.Elasticsearch 集羣啓動多節點 + 解決ES節點集羣狀態爲yellowspring
================================================================docker
使用Docker和Elasticsearch搭建全文本搜索引擎應用 集羣數據庫
ElasticSearch Head是集羣管理、數據可視化、增刪查改、查詢語句可視化工具express
kibana與ElasticSearch Head 功能類似。
本章以kibana爲例安裝。
================================================================
================================================================
https://dev.aliyun.com/search.html
直接輸入elasticsearch 查詢,查找docker認證的鏡像,查找最新版本進行拉取
docker pull elasticsearch:5.6.9
docker pull kibana:5.6.9
給es1-master.yml文件配置內容【完整配置介紹:http://www.javashuo.com/article/p-abphnppo-bk.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實例的數據實際存儲位置【概念區分:http://www.javashuo.com/article/p-xjnrlevg-ca.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集羣正常啓動,可使用了!!!
docker run -d -p 5601:5601 --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 5601:5601 --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": 4058, "ExitCode": 0, "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": 0, "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": "9200" } ], "9300/tcp": [ { "HostIp": "", "HostPort": "9300" } ] }, "RestartPolicy": { "Name": "always", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "shareable", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0, "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": 0, "Ports": { "9200/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "9200" } ], "9300/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "9300" } ] }, "SandboxKey": "/var/run/docker/netns/13dd60ea0562", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "ca85232ef162fc061abaf34a48c28e47cd5d13e142be531b6f96cf8e9dc6f2f0", "Gateway": "172.17.0.1", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "172.17.0.4", "IPPrefixLen": 16, "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": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:04", "DriverOpts": null } } } } ]
只要保證es(單實例或集羣服務)啓動沒有問題,而且kibana啓動配置的IP是容器的IP。就不會出現這個問題!!!
啓動成功頁面以下:
方法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.9.zip
刪除壓縮包
rm elasticsearch-analysis-ik-5.6.9.zip
退出容器
exit
重啓es容器
docker restart es1
查看啓動日誌
docker logs -f es1
插件加載成功
注意:方法2可能會出現重啓es後報錯
java.io.FileNotFoundException: /usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml (No such file or directory)
的問題
[2019-01-02T07:28:37,157][INFO ][o.w.a.d.Monitor ] try load config from /usr/share/elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml [2019-01-02T07:28:37,158][INFO ][o.w.a.d.Monitor ] try load config from /usr/share/elasticsearch/plugins/analysis-ik/config/IKAnalyzer.cfg.xml [2019-01-02T07:28:37,158][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:195) ~[?:1.8.0_171] at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[?:1.8.0_171] at org.wltea.analyzer.dic.Dictionary.<init>(Dictionary.java:110) ~[?:?] at org.wltea.analyzer.dic.Dictionary.initial(Dictionary.java:150) ~[?:?] at org.wltea.analyzer.cfg.Configuration.<init>(Configuration.java:40) ~[?:?] at org.elasticsearch.index.analysis.IkTokenizerFactory.<init>(IkTokenizerFactory.java:15) ~[?:?] at org.elasticsearch.index.analysis.IkTokenizerFactory.getIkSmartTokenizerFactory(IkTokenizerFactory.java:23) ~[?:?] at org.elasticsearch.index.analysis.AnalysisRegistry.buildMapping(AnalysisRegistry.java:361) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.index.analysis.AnalysisRegistry.buildTokenizerFactories(AnalysisRegistry.java:176) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.index.analysis.AnalysisRegistry.build(AnalysisRegistry.java:154) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.index.IndexService.<init>(IndexService.java:145) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.index.IndexModule.newIndexService(IndexModule.java:363) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.indices.IndicesService.createIndexService(IndicesService.java:448) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.indices.IndicesService.verifyIndexMetadata(IndicesService.java:481) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.gateway.Gateway.performStateRecovery(Gateway.java:135) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.gateway.GatewayService$1.doRun(GatewayService.java:229) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:674) [elasticsearch-5.6.9.jar:5.6.9] at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.6.9.jar:5.6.9] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_171] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_171] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171] [2019-01-02T07:28:37,176][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分詞器插件已經加載
===========================================================================================================
基本概念完整參考地址:http://www.javashuo.com/article/p-duoitlny-bd.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