Skip to content

ElasticSearch-集群证书问题

集群证书不匹配

bash
exception caught on transport layer [Netty4TcpChannel{
  localAddress=/10.0.1.39:46410, remoteAddress=es02/10.0.1.38:9300, profile=default
  }], closing connection
PKIX path validation failed: ...: 
Path does not chain with any of the trust anchors"

解决方案:生成新证书,重新部署到每个节点即可。

bash
bin/elasticsearch-certutil cert -name transport-certs \
  -out config/elastic-certificates.p12 -pass "" --days 60 -s

常用命令

查看快照存储情况

bash
GET _snapshot/my_backup/snapshot_wxcp_2024/_status?human
json

查看索引分片分布

bash
GET /gupaoedu-wxcp-msg-2023*/_stats/store?human
json
{
  "_shards" : {
    "total" : 270,
    "successful" : 135,
    "failed" : 0
  },
  "_all" : {
    "primaries" : {
      "store" : {
        "size" : "13.4gb",
        "size_in_bytes" : 14493407105,
        "total_data_set_size" : "13.4gb",
        "total_data_set_size_in_bytes" : 14493407105,
        "reserved" : "0b",
        "reserved_in_bytes" : 0
      }
    },
    "total" : {
      "store" : {
        "size" : "13.4gb",
        "size_in_bytes" : 14493407105,
        "total_data_set_size" : "13.4gb",
        "total_data_set_size_in_bytes" : 14493407105,
        "reserved" : "0b",
        "reserved_in_bytes" : 0
      }
    }
  },
  "indices" : {
    "gupaoedu-wxcp-msg-2023-11-16" : {
      "uuid" : "jmFXQFccS6qUsKpcxScJbg",
      "primaries" : {
        "store" : {
          "size" : "151.9mb",
          "size_in_bytes" : 159331762,
          "total_data_set_size" : "151.9mb",
          "total_data_set_size_in_bytes" : 159331762,
          "reserved" : "0b",
          "reserved_in_bytes" : 0
        }
      },
      "total" : {
        "store" : {
          "size" : "151.9mb",
          "size_in_bytes" : 159331762,
          "total_data_set_size" : "151.9mb",
          "total_data_set_size_in_bytes" : 159331762,
          "reserved" : "0b",
          "reserved_in_bytes" : 0
        }
      }
    }
  }
}
bash
GET /_cat/shards?v

```bash [执行结果]
index                                                         shard prirep state       docs   store ip        node
.geoip_databases                                              0     p      STARTED       40  37.4mb 10.0.1.35 elasticsearch
.apm-agent-configuration                                      0     p      STARTED        0    226b 10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2024-09-19                                  0     p      STARTED    17069  13.2mb 10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2024-09-19                                  0     r      UNASSIGNED                         
.kibana-event-log-7.17.6-000001                               0     p      STARTED                  10.0.1.35 elasticsearch
.kibana_7.17.6_001                                            0     p      STARTED       49   4.8mb 10.0.1.35 elasticsearch
.async-search                                                 0     p      STARTED        8 735.9kb 10.0.1.35 elasticsearch
.ds-ilm-history-5-2025.04.25-000001                           0     p      STARTED                  10.0.1.35 elasticsearch
.kibana_security_session_1                                    0     p      STARTED                  10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2024-09-18                                  0     p      STARTED      203 225.7kb 10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2024-09-18                                  0     r      UNASSIGNED                         
.security-7                                                   0     p      STARTED       53   238kb 10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2024-09-20                                  0     p      STARTED    16578  12.8mb 10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2024-09-20                                  0     r      UNASSIGNED                         
.ds-.logs-deprecation.elasticsearch-default-2025.04.25-000001 0     p      STARTED                  10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2025-04-25                                  0     p      STARTED    16081  12.5mb 10.0.1.35 elasticsearch
gupaoedu-wxcp-msg-2025-04-25                                  0     r      UNASSIGNED                         
.apm-custom-link                                              0     p      STARTED        0    226b 10.0.1.35 elasticsearch
.kibana_task_manager_7.17.6_001                               0     p      STARTED       18   270kb 10.0.1.35 elasticsearch
bash
GET /_cat/allocation?v
json
shards disk.indices disk.used disk.avail disk.total disk.percent host      ip        node
    15       81.8mb    11.8gb     86.4gb     98.3gb           12 10.0.1.35 10.0.1.35 elasticsearch
     4                                                                               UNASSIGNED
bash
GET /_cluster/health?pretty
json
{
  "cluster_name" : "docker-cluster",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 15,
  "active_shards" : 15,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 4,
  "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" : 78.94736842105263
}
bash
GET /_cluster/stats?human&pretty
json
{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "AbcXLu0DReWxGcieXWh4tQ",
  "timestamp" : 1745576163105,
  "status" : "yellow",
  "indices" : {
    "count" : 15,
    "shards" : {
      "total" : 15,
      "primaries" : 15,
      "replication" : 0.0,
      "index" : {
        "shards" : {
          "min" : 1,
          "max" : 1,
          "avg" : 1.0
        },
        "primaries" : {
          "min" : 1,
          "max" : 1,
          "avg" : 1.0
        },
        "replication" : {
          "min" : 0.0,
          "max" : 0.0,
          "avg" : 0.0
        }
      }
    },
    "docs" : {
      "count" : 50119,
      "deleted" : 640
    },
    "store" : {
      "size" : "81.8mb",
      "size_in_bytes" : 85776485,
      "total_data_set_size" : "81.8mb",
      "total_data_set_size_in_bytes" : 85776485,
      "reserved" : "0b",
      "reserved_in_bytes" : 0
    },
    "fielddata" : {
      "memory_size" : "0b",
      "memory_size_in_bytes" : 0,
      "evictions" : 0
    },
    "query_cache" : {
      "memory_size" : "0b",
      "memory_size_in_bytes" : 0,
      "total_count" : 0,
      "hit_count" : 0,
      "miss_count" : 0,
      "cache_size" : 0,
      "cache_count" : 0,
      "evictions" : 0
    },
    "completion" : {
      "size" : "0b",
      "size_in_bytes" : 0
    },
    "segments" : {
      "count" : 48,
      "memory" : "163.5kb",
      "memory_in_bytes" : 167496,
      "terms_memory" : "109.9kb",
      "terms_memory_in_bytes" : 112608,
      "stored_fields_memory" : "23.3kb",
      "stored_fields_memory_in_bytes" : 23952,
      "term_vectors_memory" : "0b",
      "term_vectors_memory_in_bytes" : 0,
      "norms_memory" : "9.8kb",
      "norms_memory_in_bytes" : 10112,
      "points_memory" : "0b",
      "points_memory_in_bytes" : 0,
      "doc_values_memory" : "20.3kb",
      "doc_values_memory_in_bytes" : 20824,
      "index_writer_memory" : "262.9kb",
      "index_writer_memory_in_bytes" : 269246,
      "version_map_memory" : "278b",
      "version_map_memory_in_bytes" : 278,
      "fixed_bit_set" : "496b",
      "fixed_bit_set_memory_in_bytes" : 496,
      "max_unsafe_auto_id_timestamp" : -1,
      "file_sizes" : { }
    },
    "mappings" : {
      "field_types" : [
        {
          "name" : "boolean",
          "count" : 1,
          "index_count" : 1,
          "script_count" : 0
        },
        {
          "name" : "constant_keyword",
          "count" : 3,
          "index_count" : 1,
          "script_count" : 0
        },
        {
          "name" : "date",
          "count" : 16,
          "index_count" : 7,
          "script_count" : 0
        },
        {
          "name" : "float",
          "count" : 2,
          "index_count" : 1,
          "script_count" : 0
        },
        {
          "name" : "ip",
          "count" : 1,
          "index_count" : 1,
          "script_count" : 0
        },
        {
          "name" : "keyword",
          "count" : 92,
          "index_count" : 7,
          "script_count" : 0
        },
        {
          "name" : "long",
          "count" : 13,
          "index_count" : 6,
          "script_count" : 0
        },
        {
          "name" : "nested",
          "count" : 1,
          "index_count" : 1,
          "script_count" : 0
        },
        {
          "name" : "object",
          "count" : 26,
          "index_count" : 3,
          "script_count" : 0
        },
        {
          "name" : "text",
          "count" : 32,
          "index_count" : 7,
          "script_count" : 0
        },
        {
          "name" : "version",
          "count" : 1,
          "index_count" : 1,
          "script_count" : 0
        }
      ],
      "runtime_field_types" : [ ]
    },
    "analysis" : {
      "char_filter_types" : [ ],
      "tokenizer_types" : [ ],
      "filter_types" : [ ],
      "analyzer_types" : [ ],
      "built_in_char_filters" : [ ],
      "built_in_tokenizers" : [ ],
      "built_in_filters" : [ ],
      "built_in_analyzers" : [ ]
    },
    "versions" : [
      {
        "version" : "7.17.6",
        "index_count" : 15,
        "primary_shard_count" : 15,
        "total_primary_size" : "81.8mb",
        "total_primary_bytes" : 85776485
      }
    ]
  },
  "nodes" : {
    "count" : {
      "total" : 1,
      "coordinating_only" : 0,
      "data" : 1,
      "data_cold" : 1,
      "data_content" : 1,
      "data_frozen" : 1,
      "data_hot" : 1,
      "data_warm" : 1,
      "ingest" : 1,
      "master" : 1,
      "ml" : 1,
      "remote_cluster_client" : 1,
      "transform" : 1,
      "voting_only" : 0
    },
    "versions" : [
      "7.17.6"
    ],
    "os" : {
      "available_processors" : 8,
      "allocated_processors" : 8,
      "names" : [
        {
          "name" : "Linux",
          "count" : 1
        }
      ],
      "pretty_names" : [
        {
          "pretty_name" : "Ubuntu 20.04.4 LTS",
          "count" : 1
        }
      ],
      "architectures" : [
        {
          "arch" : "amd64",
          "count" : 1
        }
      ],
      "mem" : {
        "total" : "15.1gb",
        "total_in_bytes" : 16249937920,
        "free" : "6.4gb",
        "free_in_bytes" : 6877945856,
        "used" : "8.7gb",
        "used_in_bytes" : 9371992064,
        "free_percent" : 42,
        "used_percent" : 58
      }
    },
    "process" : {
      "cpu" : {
        "percent" : 0
      },
      "open_file_descriptors" : {
        "min" : 407,
        "max" : 407,
        "avg" : 407
      }
    },
    "jvm" : {
      "max_uptime" : "11.8m",
      "max_uptime_in_millis" : 713648,
      "versions" : [
        {
          "version" : "18.0.2",
          "vm_name" : "OpenJDK 64-Bit Server VM",
          "vm_version" : "18.0.2+9-61",
          "vm_vendor" : "Oracle Corporation",
          "bundled_jdk" : true,
          "using_bundled_jdk" : true,
          "count" : 1
        }
      ],
      "mem" : {
        "heap_used" : "221.6mb",
        "heap_used_in_bytes" : 232419840,
        "heap_max" : "4gb",
        "heap_max_in_bytes" : 4294967296
      },
      "threads" : 99
    },
    "fs" : {
      "total" : "98.3gb",
      "total_in_bytes" : 105620869120,
      "free" : "90.6gb",
      "free_in_bytes" : 97296113664,
      "available" : "86.4gb",
      "available_in_bytes" : 92877185024
    },
    "plugins" : [ ],
    "network_types" : {
      "transport_types" : {
        "security4" : 1
      },
      "http_types" : {
        "security4" : 1
      }
    },
    "discovery_types" : {
      "single-node" : 1
    },
    "packaging_types" : [
      {
        "flavor" : "default",
        "type" : "docker",
        "count" : 1
      }
    ],
    "ingest" : {
      "number_of_pipelines" : 2,
      "processor_stats" : {
        "date" : {
          "count" : 26621,
          "failed" : 0,
          "current" : 0,
          "time" : "238ms",
          "time_in_millis" : 238
        },
        "gsub" : {
          "count" : 0,
          "failed" : 0,
          "current" : 0,
          "time" : "0s",
          "time_in_millis" : 0
        },
        "script" : {
          "count" : 0,
          "failed" : 0,
          "current" : 0,
          "time" : "0s",
          "time_in_millis" : 0
        }
      }
    }
  }
}
bash
GET /_cat/nodes?v
bash
ip        heap.percent ram.percent cpu load_1m load_5m load_15m node.role   master name
10.0.1.35           57          58   0    0.00    0.20     0.28 cdfhilmrstw *      elasticsearch

人生感悟