Elasticsearch配置與使用


Elasticsearch配置與使用

host ip
node1 192.168.79.103
node2 192.168.79.101

1、配置node1

  • 修改配置文件/etc/elasticsearch/elasticsearch.yml

[root@localhost elasticsearch]# grep -Ev "#|^$" elasticsearch.yml
cluster.name: myes
node.name: node1
path.data: /data/es-data
bootstrap.memory_lock: true
network.host: 192.168.79.103
http.port: 9200

注意:修改data目錄和log目錄后,需要給相應目錄授權。(yum安裝user為elasticsearch)

  • 配置目錄權限

chown -R elasticsearch.elasticsearch /data/es-data
  • 啟動

systemctl start elasticsearch
[root@localhost elasticsearch]# netstat -tnlp | grep 9200
tcp6       0      0 192.168.79.103:9200     :::*                    LISTEN      11271/java
  • head插件安裝

/usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head
訪問:
http://192.168.79.103:9200/_plugin/head/
  • kopf插件安裝

/usr/share/elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf
訪問:
http://192.168.79.103:9200/_plugin/kopf/

2、配置node2

  • 修改配置文件

[root@node1 elasticsearch]# grep -Ev "#|^$" elasticsearch.yml
cluster.name: myes
node.name: node2
path.data: /data/es-data
bootstrap.memory_lock: true
network.host: 192.168.79.101
http.port: 9200
  • 啟動

systemctl start elasticsearch
[root@localhost elasticsearch]# netstat -tnlp | grep 9200
tcp6       0      0 192.168.79.103:9200     :::*                    LISTEN      11271/java

3、監控api

[root@localhost plugins]# curl -XGET 'http://192.168.79.103:9200/_cluster/health?pretty=true'
{
  "cluster_name" : "myes",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "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
}

可監控其中的字段


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM