ITPub博客

首页 > 应用开发 > Java > ElasticSearch初探

ElasticSearch初探

原创 Java 作者:壹頁書 时间:2016-05-07 20:28:28 0 删除 编辑
初探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博客 ” ,链接:https://blog.itpub.net/29254281/viewspace-2095546/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 2016展望
请登录后发表评论 登录
全部评论

注册时间:2013-10-19

  • 博文量
    620
  • 访问量
    6340702