ElasticSearch初探

壹頁書發表於2016-05-07
初探ElasticSearch

實驗環境
版本:2.3.2
五節點:
192.168.1.105
192.168.1.106
192.168.1.108
192.168.1.109
192.168.1.110

解壓elasticsearch-2.3.2.zip檔案之後,修改配置
elasticsearch.yml:
cluster.name: es_cluster
node.name: node_105
index.refresh_interval: 10s
network.host: 192.168.1.105
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping_timeout: 120s
discovery.zen.minimum_master_nodes: 3
client.transport.ping_timeout: 60s
discovery.zen.ping.unicast.hosts: ["192.168.1.105","192.168.1.106","192.168.1.108","192.168.1.109","192.168.1.110"]

然後修改bin/elasticsearch.in.sh 修改JVM堆記憶體大小


然後在5臺伺服器上啟動ES.安裝完成.

ES zen叢集發現的相關引數
多播:
discovery.zen.ping.multicast.group:多播請求地址,預設224.2.2.4
discovery.zen.ping.multicast.port:多播通訊埠,預設54328
discovery.zen.ping.multicast
.ttl:多播請求有效時間,預設3s
discovery.zen.ping.multicast.address:繫結地址,預設為null繫結到OS可見的所有網路介面
discovery.zen.ping.multicast.enabled:是否使用多播

單播:
discovery.zen.ping.unicast.host
s:叢集所有節點的IP地址和埠號

節點PING設定
discovery.zen.fd.ping_interval:節點相互PING的間隔,預設1s
discovery.zen.fd.ping_timeout:ping超時,預設30s
discovery.zen.fd.ping_retries:重試次數,預設為3


叢集管理API
1.檢視叢集健康度
http://192.168.1.105:9200/_cluster/health?pretty
{
  "cluster_name" : "es_cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 5,
  "number_of_data_nodes" : 5,
  "active_primary_shards" : 66,
  "active_shards" : 132,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "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" : 100.0
}
2.檢視索引,分片資訊
http://192.168.1.105:9200/_cluster/health?pretty&level=indices
或者
http://192.168.1.105:9200/_cluster/health?pretty&level=shards

返回結果
{
  "cluster_name" : "es_cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 5,
  "number_of_data_nodes" : 5,
  "active_primary_shards" : 66,
  "active_shards" : 132,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "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" : 100.0,
  "indices" : {
    "logstash-accesslog-2016.05.05" : {
      "status" : "green",
      "number_of_shards" : 5,
      "number_of_replicas" : 1,
      "active_primary_shards" : 5,
      "active_shards" : 10,
      "relocating_shards" : 0,
      "initializing_shards" : 0,
      "unassigned_shards" : 0
    },
    "logstash-accesslog-2016.05.06" : {
      "status" : "green",
      "number_of_shards" : 5,
      "number_of_replicas" : 1,
      "active_primary_shards" : 5,
      "active_shards" : 10,
      "relocating_shards" : 0,
      "initializing_shards" : 0,
      "unassigned_shards" : 0
    },
。。。

3.索引統計API
http://192.168.1.105:9200/logstash-accesslog-2016.05.05/_stats?pretty
{
  "_shards" : {
    "total" : 10,
    "successful" : 10,
    "failed" : 0
  },
  "_all" : {
    "primaries" : {
      "docs" : {
        "count" : 289330,
        "deleted" : 0
      },
      "store" : {
        "size_in_bytes" : 35480131,
        "throttle_time_in_millis" : 0
      },
      "indexing" : {
        "index_total" : 289330,
        "index_time_in_millis" : 168359,
        "index_current" : 0,
        "index_failed" : 0,
        "delete_total" : 0,
        "delete_time_in_millis" : 0,
        "delete_current" : 0,
        "noop_update_total" : 0,
        "is_throttled" : false,
        "throttle_time_in_millis" : 0
      },

4.節點狀態API
http://192.168.1.105:9200/_nodes?pretty
http://192.168.1.105:9200_nodes/node_105?pretty

5.節點統計API
http://192.168.1.105:9200/_nodes/node_105/stats?pretty

6.叢集狀態API
http://192.168.1.105:9200/_cluster/state?pretty

7.cat API
比如檢視索引情況
http://192.168.1.105:9200/_cat/indices?v


可以應用cat api檢視的資訊有
aliases 別名
allocation 分片分配和磁碟使用
count 索引文件個數
health 叢集健康度
indices 所有索引或者單個索引的資訊
master 當選主節點資訊
nodes 節點資訊
pending_tasks 等待執行的任務資訊
recovery 還原過程的檢視
thread_pool 執行緒池統計
shards 分片資訊.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29254281/viewspace-2095546/,如需轉載,請註明出處,否則將追究法律責任。