ElasticSearch--集群搭建(十二 )

一、集群規(guī)劃

搭建一個(gè)集群我們需要考慮如下幾個(gè)問(wèn)題:

  1. 我們需要多大規(guī)模的集群?

需要從以下兩個(gè)方面考慮:
1.1 當(dāng)前的數(shù)據(jù)量有多大?數(shù)據(jù)增長(zhǎng)情況如何?
1.2 你的機(jī)器配置如何?cpu、多大內(nèi)存、多大硬盤(pán)容量?
推算的依據(jù):
ES JVM heap 最大可以設(shè)置32G 。
30G heap 大概能處理的數(shù)據(jù)量 10 T。如果內(nèi)存很大如128G,可在一臺(tái)機(jī)器上運(yùn)行多個(gè)ES節(jié)點(diǎn)實(shí)例。

備注:集群規(guī)劃滿足當(dāng)前數(shù)據(jù)規(guī)模+適量增長(zhǎng)規(guī)模即可,后續(xù)可按需擴(kuò)展。

兩類應(yīng)用場(chǎng)景:
A. 用于構(gòu)建業(yè)務(wù)搜索功能模塊,且多是垂直領(lǐng)域的搜索。數(shù)據(jù)量級(jí)幾千萬(wàn)到數(shù)十億級(jí)別。一般2-4臺(tái)機(jī)器的規(guī)模。
B. 用于大規(guī)模數(shù)據(jù)的實(shí)時(shí)OLAP(聯(lián)機(jī)處理分析),經(jīng)典的如ELK Stack,數(shù)據(jù)規(guī)??赡苓_(dá)到千億或更多。幾十到上百節(jié)點(diǎn)的規(guī)模。

  1. 集群中的節(jié)點(diǎn)角色如何分配?
    節(jié)點(diǎn)角色:Master
    node.master: true 節(jié)點(diǎn)可以作為主節(jié)點(diǎn)
    DataNode 數(shù)據(jù)節(jié)點(diǎn)
    node.data: true 默認(rèn)是數(shù)據(jù)節(jié)點(diǎn)。
    Coordinate node 協(xié)調(diào)節(jié)點(diǎn)
    如果僅擔(dān)任協(xié)調(diào)節(jié)點(diǎn),將上兩個(gè)配置設(shè)為false。

說(shuō)明:
一個(gè)節(jié)點(diǎn)可以充當(dāng)一個(gè)或多個(gè)角色,默認(rèn)三個(gè)角色都有
協(xié)調(diào)節(jié)點(diǎn):一個(gè)節(jié)點(diǎn)只作為接收請(qǐng)求、轉(zhuǎn)發(fā)請(qǐng)求到其他節(jié)點(diǎn)、匯總各個(gè)節(jié)點(diǎn)返回?cái)?shù)據(jù)等功能的節(jié)點(diǎn)。就叫協(xié)調(diào)節(jié)點(diǎn)

如何分配:
A. 小規(guī)模集群,不需嚴(yán)格區(qū)分。
B. 中大規(guī)模集群(十個(gè)以上節(jié)點(diǎn)),應(yīng)考慮單獨(dú)的角色充當(dāng)。特別并發(fā)查詢量大,查詢的合并量大,可以增加獨(dú)立的協(xié)調(diào)節(jié)點(diǎn)。角色分開(kāi)的好處是分工分開(kāi),不互影響。如不會(huì)因協(xié)調(diào)角色負(fù)載過(guò)高而影響數(shù)據(jù)節(jié)點(diǎn)的能力。

  1. 如何避免腦裂問(wèn)題?

腦裂問(wèn)題:
一個(gè)集群中只有一個(gè)A主節(jié)點(diǎn),A主節(jié)點(diǎn)因?yàn)樾枰幚淼臇|西太多或者網(wǎng)絡(luò)過(guò)于繁忙,從而導(dǎo)致其他從節(jié)點(diǎn)ping不通A主節(jié)點(diǎn),這樣其他從節(jié)點(diǎn)就會(huì)認(rèn)為A主節(jié)點(diǎn)不可用了,就會(huì)重新選出一個(gè)新的主節(jié)點(diǎn)B。過(guò)了一會(huì)A主節(jié)點(diǎn)恢復(fù)正常了,這樣就出現(xiàn)了兩個(gè)主節(jié)點(diǎn),導(dǎo)致一部分?jǐn)?shù)據(jù)來(lái)源于A主節(jié)點(diǎn),另外一部分?jǐn)?shù)據(jù)來(lái)源于B主節(jié)點(diǎn),出現(xiàn)數(shù)據(jù)不一致問(wèn)題,這就是腦裂。

盡量避免腦裂,需要添加最小數(shù)量的主節(jié)點(diǎn)配置:
discovery.zen.minimum_master_nodes: (有master資格節(jié)點(diǎn)數(shù)/2) + 1
這個(gè)參數(shù)控制的是,選舉主節(jié)點(diǎn)時(shí)需要看到最少多少個(gè)具有master資格的活節(jié)點(diǎn),才能進(jìn)行選舉。官方的推薦值是(N/2)+1,其中N是具有master資格的節(jié)點(diǎn)的數(shù)量。

常用做法(中大規(guī)模集群):

  1. Master 和 dataNode 角色分開(kāi),配置奇數(shù)個(gè)master,如3

  2. 單播發(fā)現(xiàn)機(jī)制,配置master資格節(jié)點(diǎn):
    discovery.zen.ping.multicast.enabled: false —— 關(guān)閉多播發(fā)現(xiàn)機(jī)制,默認(rèn)是關(guān)閉的
    discovery.zen.ping.unicast.hosts: ["master1", "master2", "master3"] —— 配置單播發(fā)現(xiàn)的主節(jié)點(diǎn)ip地址,其他從節(jié)點(diǎn)要加入進(jìn)來(lái),就得去詢問(wèn)單播發(fā)現(xiàn)機(jī)制里面配置的主節(jié)點(diǎn)我要加入到集群里面了,主節(jié)點(diǎn)同意以后才能加入,然后主節(jié)點(diǎn)再通知集群中的其他節(jié)點(diǎn)有新節(jié)點(diǎn)加入

  3. 配置選舉發(fā)現(xiàn)數(shù),及延長(zhǎng)ping master的等待時(shí)長(zhǎng)
    discovery.zen.ping_timeout: 30(默認(rèn)值是3秒)——其他節(jié)點(diǎn)ping主節(jié)點(diǎn)多久時(shí)間沒(méi)有響應(yīng)就認(rèn)為主節(jié)點(diǎn)不可用了
    discovery.zen.minimum_master_nodes: 2 —— 選舉主節(jié)點(diǎn)時(shí)需要看到最少多少個(gè)具有master資格的活節(jié)點(diǎn),才能進(jìn)行選舉

  4. 索引應(yīng)該設(shè)置多少個(gè)分片?
    說(shuō)明:分片數(shù)指定后不可變,除非重索引。
    分片對(duì)應(yīng)的存儲(chǔ)實(shí)體是什么?
      存儲(chǔ)的實(shí)體是索引
    分片是不是越多越好?
      不是
    ??每個(gè)分片本質(zhì)上就是一個(gè)Lucene索引, 因此會(huì)消耗相應(yīng)的文件句柄, 內(nèi)存和CPU資源。
    ??每個(gè)搜索請(qǐng)求會(huì)調(diào)度到索引的每個(gè)分片中. 如果分片分散在不同的節(jié)點(diǎn)倒是問(wèn)題不太. 但當(dāng)分片開(kāi)始競(jìng)爭(zhēng)相同的硬件資源時(shí), 性能便會(huì)逐步下降。
    ??ES使用詞頻統(tǒng)計(jì)來(lái)計(jì)算相關(guān)性. 當(dāng)然這些統(tǒng)計(jì)也會(huì)分配到各個(gè)分片上. 如果在大量分片上只維護(hù)了很少的數(shù)據(jù), 則將導(dǎo)致最終的文檔相關(guān)性較差。
    分片多有什么影響?
      分片多浪費(fèi)存儲(chǔ)空間、占用資源、影響性能。

分片設(shè)置的可參考原則:
??ElasticSearch推薦的最大JVM堆空間是30~32G, 所以把你的分片最大容量限制為30GB, 然后再對(duì)分片數(shù)量做合理估算. 例如, 你認(rèn)為你的數(shù)據(jù)能達(dá)到200GB, 推薦你最多分配7到8個(gè)分片。
??在開(kāi)始階段, 一個(gè)好的方案是根據(jù)你的節(jié)點(diǎn)數(shù)量按照1.5~3倍的原則來(lái)創(chuàng)建分片. 例如,如果你有3個(gè)節(jié)點(diǎn), 則推薦你創(chuàng)建的分片數(shù)最多不超過(guò)9(3x3)個(gè)。當(dāng)性能下降時(shí),增加節(jié)點(diǎn),ES會(huì)平衡分片的放置。
??對(duì)于基于日期的索引需求, 并且對(duì)索引數(shù)據(jù)的搜索場(chǎng)景非常少. 也許這些索引量將達(dá)到成百上千, 但每個(gè)索引的數(shù)據(jù)量只有1GB甚至更小. 對(duì)于這種類似場(chǎng)景, 建議只需要為索引分配1個(gè)分片。如日志管理就是一個(gè)日期的索引需求,日期索引會(huì)很多,但每個(gè)索引存放的日志數(shù)據(jù)量就很少。

  1. 分片應(yīng)該設(shè)置幾個(gè)副本?
    說(shuō)明:副本數(shù)是可以隨時(shí)調(diào)整的!
    副本的用途是什么?
      備份數(shù)據(jù)保證高可用數(shù)據(jù)不丟失,高并發(fā)的時(shí)候參與數(shù)據(jù)查詢。
    針對(duì)它的用途,我們?cè)撊绾卧O(shè)置它的副本數(shù)?
      一般一個(gè)分片有1-2個(gè)副本即可保證高可用。
    集群規(guī)模沒(méi)變的情況下副本過(guò)多會(huì)有什么影響?
      副本多浪費(fèi)存儲(chǔ)空間、占用資源、影響性能。

副本設(shè)置基本原則:
??為保證高可用,副本數(shù)設(shè)置為2即可。要求集群至少要有3個(gè)節(jié)點(diǎn),來(lái)分開(kāi)存放主分片、副本。
??如發(fā)現(xiàn)并發(fā)量大時(shí),查詢性能會(huì)下降,可增加副本數(shù),來(lái)提升并發(fā)查詢能力。
注意:新增副本時(shí)主節(jié)點(diǎn)會(huì)自動(dòng)協(xié)調(diào),然后拷貝數(shù)據(jù)到新增的副本節(jié)點(diǎn)

二、集群搭建

  1. 3臺(tái)服務(wù)器
主機(jī)名 IP
node1 192.168.77.130
node2 192.168.77.131
node3 192.168.77.132
  1. 分別安裝ES
    沒(méi)有說(shuō)明,以下操作均指所有節(jié)點(diǎn)。
# 修改主機(jī)名
[root@localhost ~]# vi /etc/hosts
192.168.77.130 node1
192.168.77.131 node2
192.168.77.132 node3

# 軟件安裝
[root@node2 ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.3.tar.gz
# 解壓文件
[root@node2 ~]# tar -xzf elasticsearch-6.4.3.tar.gz -C /usr/local/
# 切換目錄
[root@node2 ~]# cd /usr/local/elasticsearch-6.4.3

  1. 修改3臺(tái)服務(wù)器下ES的配置(組成集群)
    elasticsearch的config目錄,修改elasticsearch.yml的配置
network.host: 0.0.0.0
http.port: 9200 
transport.tcp.port: 9300

配置說(shuō)明:
1)IP訪問(wèn)限制、默認(rèn)端口修改9200
IP訪問(wèn)限制可以限定具體的IP訪問(wèn)服務(wù)器,這有一定的安全過(guò)濾作用。

network.host: 0.0.0.0

如果設(shè)置成0.0.0.0則是不限制任何IP訪問(wèn)。一般在生產(chǎn)的服務(wù)器可能會(huì)限定幾臺(tái)IP,通常用于管理使用。
es實(shí)例的默認(rèn)端口號(hào)9200:

http.port: 9200 
transport.tcp.port: 9300

??這里的9300是集群內(nèi)部通訊使用的端口,這個(gè)也可以修改掉。因?yàn)檫B接集群的方式有兩種,通過(guò)扮演集群node也是可以進(jìn)入集群的,所以還是安全起見(jiàn),修改掉默認(rèn)的端口。
說(shuō)明:記得修改安裝了ES的3臺(tái)虛擬機(jī)(三個(gè)節(jié)點(diǎn))的相同配置,要不然節(jié)點(diǎn)之間無(wú)法建立連接工作,也會(huì)報(bào)錯(cuò)。

  1. 集群發(fā)現(xiàn)IP列表、node、cluster名稱
    ??修改集群節(jié)點(diǎn)IP地址,這樣可以讓集群在規(guī)定的幾個(gè)節(jié)點(diǎn)之間工作。
    ??elasticsearch,默認(rèn)是使用自動(dòng)發(fā)現(xiàn)IP機(jī)制。就是在當(dāng)前網(wǎng)段內(nèi),只要能被自動(dòng)感知到的IP就能自動(dòng)加入到集群中。這有好處也有壞處。好處就是自動(dòng)化了,當(dāng)你的es集群需要云化的時(shí)候就會(huì)非常方便。但是也會(huì)帶來(lái)一些不穩(wěn)定的情況,如,master的選舉問(wèn)題、數(shù)據(jù)復(fù)制問(wèn)題。
    ??導(dǎo)致master選舉的因素之一就是集群有節(jié)點(diǎn)進(jìn)入。當(dāng)數(shù)據(jù)復(fù)制發(fā)生的時(shí)候也會(huì)影響集群,因?yàn)橐鰯?shù)據(jù)平衡復(fù)制和冗余。這里面可以獨(dú)立master集群,剔除master集群的數(shù)據(jù)節(jié)點(diǎn)能力。
    ??固定列表的IP發(fā)現(xiàn)有兩種配置方式,一種是互相依賴發(fā)現(xiàn),一種是全量發(fā)現(xiàn)。
    依賴發(fā)現(xiàn):
    在192.168.77.130的elasticsearch中配置成:
# 192.168.77.130 配置
discovery.zen.ping.unicast.hosts: [ "192.168.77.131:9300","192.168.77.132:9300" ]
cluster.name: xtsz-cluster 
node.name: node-1
# 192.168.77.131 配置
discovery.zen.ping.unicast.hosts: [ "192.168.77.130:9300","192.168.77.132:9300" ]
cluster.name: xtsz-cluster 
node.name: node-2
# 192.168.77.132 配置
discovery.zen.ping.unicast.hosts: [ "192.168.77.130:9300","192.168.77.131:9300" ]
cluster.name: xtsz-cluster 
node.name: node-3

讓它去發(fā)現(xiàn)131,132的機(jī)器,以此內(nèi)推,完成剩下的131和132機(jī)器的配置。
配置下集群名稱,就是你當(dāng)前節(jié)點(diǎn)所在集群的名稱,這有助于你規(guī)劃你的集群。集群中的所有節(jié)點(diǎn)的集群名稱必須一樣,只有集群名稱一樣才能組成一個(gè)邏輯集群。

# 所有主機(jī)
cluster.name: xtsz-cluster 

配置你當(dāng)前節(jié)點(diǎn)的名稱:

node.name: node-1

??以此類推,完成另外兩個(gè)節(jié)點(diǎn)的配置。cluster.name的名稱必須保持一樣。然后分別設(shè)置node.name。
說(shuō)明:
??這里搭建的是一個(gè)簡(jiǎn)單的集群,沒(méi)有做集群節(jié)點(diǎn)角色的區(qū)分,所以3個(gè)節(jié)點(diǎn)默認(rèn)的角色有主節(jié)點(diǎn)、數(shù)據(jù)節(jié)點(diǎn)、協(xié)調(diào)節(jié)點(diǎn)
選舉ES主節(jié)點(diǎn)的邏輯:
??選舉的大概邏輯,它會(huì)根據(jù)分片的數(shù)據(jù)的前后新鮮程度來(lái)作為選舉的一個(gè)重要邏輯。(日志、數(shù)據(jù)、時(shí)間都會(huì)作為集群master全局的重要指標(biāo))
??因?yàn)榭紤]到數(shù)據(jù)一致性問(wèn)題,當(dāng)然是用最新的數(shù)據(jù)節(jié)點(diǎn)作為master,然后進(jìn)行新數(shù)據(jù)的復(fù)制和刷新其他node。

三、集群管理

  1. 創(chuàng)建用戶es并設(shè)置密碼
# 所有節(jié)點(diǎn)
[root@node2 elasticsearch-6.4.3]# adduser es
[root@node2 elasticsearch-6.4.3]# passwd es
更改用戶 es 的密碼 。
新的 密碼:
重新輸入新的 密碼:
passwd:所有的身份驗(yàn)證令牌已經(jīng)成功更新。

# 添加所有者
[root@node2 elasticsearch-6.4.3]# chown -R es:es /usr/local/elasticsearch-6.4.3

  1. 啟動(dòng)集群
# 所有節(jié)點(diǎn)使用es用戶啟動(dòng)
[root@node2 elasticsearch-6.4.3]# su es
[es@node2 elasticsearch-6.4.3]$ ./bin/elasticsearch

  1. 安裝head插件
# 啟動(dòng)head插件
[root@node1 elasticsearch-head]# npm run start

> elasticsearch-head@0.0.0 start /usr/local/elasticsearch-6.4.3/elasticsearch-head
> grunt server

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

http://192.168.77.130:9100/

啟動(dòng)head

  1. 監(jiān)控API
    http://192.168.77.130:9200/_cat
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
/_cat/indices/{index}
/_cat/segments
/_cat/segments/{index}
/_cat/count
/_cat/count/{index}
/_cat/recovery
/_cat/recovery/{index}
/_cat/health
/_cat/pending_tasks
/_cat/aliases
/_cat/aliases/{alias}
/_cat/thread_pool
/_cat/thread_pool/{thread_pools}
/_cat/plugins
/_cat/fielddata
/_cat/fielddata/{fields}
/_cat/nodeattrs
/_cat/repositories
/_cat/snapshots/{repository}
/_cat/templates

四、Kibana

  1. node01服務(wù)器安裝Kibana
# 下載
[root@localhost ~]# wget https://artifacts.elastic.co/downloads/kibana/kibana-6.4.3-linux-x86_64.tar.gz

# 解壓
[root@localhost ~]# tar -zxvf kibana-6.4.3-linux-x86_64.tar.gz -C /usr/local/

# Kibana配置
[root@node1 kibana-6.4.3-linux-x86_64]# vi config/kibana.yml 
# Kibana配置
# 綁定的端口號(hào)
server.port: 5601
# 綁定的ip
server.host: "192.168.77.130"

# 啟動(dòng)
[root@node1 kibana-6.4.3-linux-x86_64]# ./bin/kibana

  1. 瀏覽訪問(wèn)
    http://192.168.77.130:5601
    點(diǎn)擊: Monitoring


    查看節(jié)點(diǎn)

    節(jié)點(diǎn)查看

五、x-apck 安裝配置

  1. 安裝請(qǐng)參考《數(shù)據(jù)可視化--Kibana(六)》
  2. 配置SSL并啟用x-apck(所有節(jié)點(diǎn))
    所有節(jié)點(diǎn)的x-pack都要注冊(cè)或破解。
# node1節(jié)點(diǎn),生成證書(shū)
 # 默認(rèn)直接點(diǎn)擊進(jìn)行下一步,密碼也可以不輸,全部回車(chē)
[root@node1 elasticsearch-6.4.3]#  ./bin/elasticsearch-certutil ca

 # 默認(rèn)直接點(diǎn)擊進(jìn)行下一步,密碼也可以不輸,全部回車(chē)
[root@node1 elasticsearch-6.4.3]# ./bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12


# 這時(shí)在es目錄下會(huì)生成elastic-certificates.p12、elastic-stack-ca.p12
[root@node1 elasticsearch-6.4.3]# ls *p12
elastic-certificates.p12  elastic-stack-ca.p12

# 創(chuàng)建目錄
[root@node1 elasticsearch-6.4.3]# mkdir config/certs/
# 拷貝證書(shū)到nod1配置目錄
[root@node1 elasticsearch-6.4.3]# cp elastic-certificates.p12 config/certs/

# 復(fù)制文件到node2與node3
[root@node1 elasticsearch-6.4.3]# scp elastic-certificates.p12 root@192.168.77.131:/usr/local/elasticsearch-6.4.3/config/certs

# 復(fù)制文件到node3
[root@node1 elasticsearch-6.4.3]# scp elastic-certificates.p12 root@node3:/usr/local/elasticsearch-6.4.3/config/certs

# 更改文件所有者
[es@node3 elasticsearch-6.4.3]$ su root
密碼:
[root@node3 elasticsearch-6.4.3]#  chown -R es:es /usr/local/elasticsearch-6.4.3/

# 所有節(jié)點(diǎn)添加配置
[root@node1 elasticsearch-6.4.3]# vi config/elasticsearch.yml 
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

# 重啟所有節(jié)點(diǎn)ES
[es@node1 elasticsearch-6.4.3]$ ./bin/elasticsearch
[es@node2 elasticsearch-6.4.3]$ ./bin/elasticsearch
[es@node3 elasticsearch-6.4.3]$ ./bin/elasticsearch

六、常見(jiàn)問(wèn)題

  1. nested: IOException[沒(méi)有到主機(jī)的路由
    關(guān)閉防火墻
[root@node2 elasticsearch-6.4.3]# systemctl stop firewalld
[root@node2 elasticsearch-6.4.3]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
  1. elasticsearch unassigned錯(cuò)誤解決
    http://192.168.77.130:9200/_cluster/health?pretty
    結(jié)果:
{
  "cluster_name" : "xtsz-cluster",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 29,
  "active_shards" : 53,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 5,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 91.37931034482759
}

其中:
"unassigned_shards" : 5,
http://192.168.77.130:9200/_cat/shards

pinyin_index                    1 p STARTED         0    261b 192.168.77.130 node-1
pinyin_index                    1 r UNASSIGNED                               
pinyin_index                    2 p STARTED         1   3.6kb 192.168.77.130 node-1
pinyin_index                    2 r UNASSIGNED                               
pinyin_index                    3 p STARTED         1   3.5kb 192.168.77.130 node-1
pinyin_index                    3 r UNASSIGNED                               
pinyin_index                    4 p STARTED         0    261b 192.168.77.130 node-1
pinyin_index                    4 r UNASSIGNED                               
pinyin_index                    0 p STARTED         0    261b 192.168.77.130 node-1
pinyin_index                    0 r UNASSIGNED     

刪除此節(jié)點(diǎn)。
逐個(gè)修復(fù)每一個(gè)節(jié)點(diǎn)分片數(shù)據(jù), 改:index、shard、node。

POST '192.168.77.130:9200/_cluster/reroute
  1. Caused by: javax.net.ssl.SSLException: Received close_notify during handshake

  2. Caused by: org.elasticsearch.ElasticsearchSecurityException: missing authentication token for action [cluster:monitor/nodes/stats[n]]
    證書(shū)問(wèn)題,請(qǐng)注冊(cè)所有ES并將node1的證書(shū)復(fù)制到其它節(jié)點(diǎn)的config/certs目錄下。

  3. Generating a random key for xpack.security.encryptionKey.
    在配置文件kibana.yml中添加【xpack.reporting.encryptionKey】屬性

xpack.reporting.encryptionKey: "a_random_string"
xpack.security.encryptionKey: "something_at_least_32_characters"
  1. [plugin:xpack_main@6.4.3] Status changed from yellow to red - Authentication Exception
    配置文件kibana.yml中需要加入以下配置:
# x-pack自動(dòng)生成或設(shè)置的elastic賬號(hào)密碼
elasticsearch.username: "elastic"
elasticsearch.password: "OYOPqdXjk1k6EHqhSpR6"

  1. [warning][security] Session cookies will be transmitted over insecure connections. This is not recommended.
    需要配置kibana的SSL。
    server.ssl.enabled
    默認(rèn)值: “false” 對(duì)到瀏覽器端的請(qǐng)求啟用 SSL,設(shè)為 true 時(shí), server.ssl.certificate 和 server.ssl.key 也要設(shè)置。
# 啟用ssl
server.ssl.enabled: true
server.ssl.certificate: /etc/ssl/server.crt
server.ssl.key: /etc/ssl/server.key
# 設(shè)置 Elasticsearch URL 指定使用 HTTPS 協(xié)議
elasticsearch.url: "https://192.168.77.130:9200"

# Elasticsearch 使用了自簽名證書(shū)
# 默認(rèn)值: full 控制證書(shū)的認(rèn)證,可用的值有 none 、 certificate 、 full 。 full 執(zhí)行主機(jī)名驗(yàn)證,certificate 不執(zhí)行主機(jī)名驗(yàn)證。
elasticsearch.ssl.verificationMode: certificate
# 指定用于 Elasticsearch 實(shí)例的 PEM 證書(shū)文件路徑。
server.ssl.certificateAuthorities: ["/usr/local/kibana-6.4.3-linux-x86_64/config/certs/elastic-certificates.p12"]

elasticsearch.ssl.verificationMode不是必須的,默認(rèn)為full, 因?yàn)樯勺C書(shū)的時(shí)候沒(méi)有加入 dns, ip 等,這里 需要禁用verify host, 不然會(huì)報(bào)錯(cuò)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容