1. 程式人生 > >Kibana外掛的安裝(5.6.10版本)

Kibana外掛的安裝(5.6.10版本)

1 Kibana是什麼

Kibana是一個配合Elasticsearch使用的、開源的資料分析和視覺化平臺, 可以與Elasticsearch中儲存的索引文件進行互動.

使用Kibana能執行高階的資料分析, 並通過圖表、表格、地圖等形式顯示分析結果.

2 安裝並啟動Kibana

在安裝好單機版Elasticsearch的基礎上, 安裝Kibana外掛, 使用其UI介面進行後續的學習操作.

前提: JDK和Elasticsearch單機服務已成功配置部署.

2.1 準備安裝包

# 上傳安裝包至伺服器的/data/elk下: 
cd /data/elk
# 解壓安裝包: 
tar -zxf kibana-5.6.10-linux-x86_64.tar.gz
# 重新命名
mv kibana-5.6.10-linux-x86_64.tar.gz kibana

2.2 修改配置檔案

檔案位置: $kibana/config/kebana.yml:

# Kibana is served by a back end server. This setting specifies the port to use.
# Kibana是個後臺服務, 需要指定服務的IP地址和埠號. 預設值為5601. 
server.port: 5601

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect. # To allow connections from remote users, set this parameter to a non-loopback address. # 指定Kibana服務需要繫結的IP地址, 預設值為本地迴環地址"localhost". 若要允許遠端訪問, 就需要改為本地伺服器的IP地址. (127.0.0.1的作用等同於localhost, 可用ifconfig命令檢視本機的IPV4地址)
server.host: 10.0.20.50 # Enables you to specify a path to mount Kibana at if you are running behind a proxy. This only affects # the URLs generated by Kibana, your proxy is expected to remove the basePath value before forwarding requests # to Kibana. This setting cannot end in a slash. #server.basePath: "" # The maximum payload size in bytes for incoming server requests. #server.maxPayloadBytes: 1048576 # The Kibana server's name. This is used for display purposes. #server.name: "your-hostname" # The URL of the Elasticsearch instance to use for all your queries. # 需要監控的Elasticsearch服務的地址, 預設是本地迴環地址+9200埠 #elasticsearch.url: "http://localhost:9200" # When this setting's value is true Kibana uses the hostname specified in the server.host # setting. When the value of this setting is false, Kibana uses the hostname of the host # that connects to this Kibana instance. #elasticsearch.preserveHost: true # Kibana uses an index in Elasticsearch to store saved searches, visualizations and # dashboards. Kibana creates a new index if the index doesn't already exist. # Kibana在Elasticsearch中的索引 kibana.index: ".kibana"

2.3 啟動Kibana並驗證

  1. 啟動Kibana:

    cd /data/elk/kibana/bin
    # 前臺啟動, 不能關閉終端, 即阻塞式啟動, 不能執行其他操作. 此時可通過Ctrl + C終止服務. 
    ./kibana
    
    # 後臺啟動, 可退出終端, 若當前終端視窗關閉, 服務也將終止.
    nohup ./kibana &
    
    # 上述nohup命令將輸出追加到了nohup.out中, 為了直接檢視啟動情況, 可省去nohup命令: 
    # ./kibana &
    
  2. 瀏覽器檢查

    在瀏覽器訪問: http://10.0.20.50:6501, 出現如下介面, 說明啟動成功:

    Kibana啟動成功

    ![image-20181106085142639](/Users/healchow/Library/Application Support/typora-user-images/image-20181106085142639.png)

2.4 關閉Kibana服務

# 檢視node服務的程序id
[[email protected] bin]# ps aux | grep node
root     15653  3.7  1.0 1142400 88020 pts/0   Sl   04:21   0:07 ./../node/bin/node --no-warnings ./../src/cli
# kill掉 ./../src/cli 程序: 
[[email protected] bin]# kill -9 15653

或者: 關閉當前會話(即終端視窗), 服務也將終止.

3 Kibana功能測試

前往Dev Tools工具介面, 輸入如下命令並點選 [綠色的➡] 傳送請求:

GET _cluster/health

得到如下關於叢集健康狀況的JSON響應:

{
  "cluster_name": "elasticsearch", # 預設的叢集名稱
  "status": "yellow",              # 叢集健康狀態
  "timed_out": false,
  "number_of_nodes": 1,            # 叢集中的節點數
  "number_of_data_nodes": 1,       # 儲存資料的節點數
  "active_primary_shards": 1,      # 活躍的primary shard數
  "active_shards": 1,              # 活躍的shard數, 包括primary shard和replica shard
  "relocating_shards": 0,          # 當前正在從一個節點遷往其他節點的分片的數量, 通常是0.ES發現叢集不太均衡(如新增或下線一個節點), 該值會上漲
  "initializing_shards": 0,        # 剛建立的分片個數, 建立第一個索引時、節點重啟時, 會短暫處於此狀態(不應長期停留此狀態)
  "unassigned_shards": 1,          # 在叢集中存在, 卻又不能找到 -- 即未分配的副本
  "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": 50
}
  • 關於叢集的狀態status的值:

    1. green: 所有primary shard和replica shard都已成功分配, 叢集是100%可用的;

    2. yellow: 所有primary shard都已成功分配, 但至少有一個replica shard缺失. 此時叢集所有功能都正常使用, 資料不會丟失, 搜尋結果依然完整, 但叢集的可用性減弱. —— 需要及時處理的警告.

    3. red: 至少有一個primary shard(以及它的全部副本分片)缺失 —— 部分資料不能使用, 搜尋只能返回部分資料, 而分配到這個分配上的寫入請求會返回一個異常. 此時雖然可以執行部分功能, 但為了索引資料的完整性, 需要儘快修復叢集.

  • 關於叢集中節點數:

    使用 GET /_cat/nodes?v 檢視當前節點數:

    ip         heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
    10.0.20.50            9          54   1    0.03    0.02     0.00 mdi       *      jVSUBme
    
  • 關於未分配的分片:

    unassigned_shards: 已經在叢集狀態中存在、但在叢集裡又找不到的分片, 來源通常是未分配的副本. 比如: 一個有 5 分片和 1 副本的索引, 在單節點叢集上就會有 5 個未分配副本分片.

    如果叢集狀態是 red, 也會長期存在未分配分片(因為缺少主分片).

關於Kibana的詳細使用, 請參考接下來 通過Kibana外掛學習ES語法 的系列文章.