ElasticSearch查找磁盘空间使用情况

qyyhg6bp  于 2023-08-03  发布在  ElasticSearch
关注(0)|答案(8)|浏览(827)

如何找到Elastic Search用于索引的磁盘空间量?我目前正在本地运行它,我想看看我将旋转的虚拟机上需要多少磁盘空间。

2w3kk1z5

2w3kk1z51#

Elasticsearch的方法是使用_cat/shards并查看store列:

curl -XGET "http://localhost:9200/_cat/shards?v"

index              shard prirep state     docs   store ip            node
myindex_2014_12_19 2     r      STARTED  76661 415.6mb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 2     p      STARTED  76661 417.3mb 192.168.1.2 Frederick Slade
myindex_2014_12_19 2     r      STARTED  76661 416.9mb 192.168.1.3 Maverick
myindex_2014_12_19 0     r      STARTED  76984 525.9mb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 0     r      STARTED  76984   527mb 192.168.1.2 Frederick Slade
myindex_2014_12_19 0     p      STARTED  76984   526mb 192.168.1.3 Maverick
myindex_2014_12_19 3     r      STARTED    163 208.5kb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 3     p      STARTED    163 191.4kb 192.168.1.2 Frederick Slade
myindex_2014_12_19 3     r      STARTED    163 181.6kb 192.168.1.3 Maverick
myindex_2014_12_19 1     p      STARTED 424923   2.1gb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 1     r      STARTED 424923   2.1gb 192.168.1.2 Frederick Slade
myindex_2014_12_19 1     r      STARTED 424923   2.1gb 192.168.1.3 Maverick
myindex_2014_12_19 4     r      STARTED  81020 435.9mb 192.168.1.1 Georgianna Castleberry
myindex_2014_12_19 4     p      STARTED  81020 437.8mb 192.168.1.2 Frederick Slade
myindex_2014_12_19 4     r      STARTED  81020 437.8mb 192.168.1.3 Maverick

字符串
否则,在Linux中按文件夹查看空间使用用途:

du -hs /myelasticsearch/data/folder


或按文件系统查看空间:

df -h

tvokkenx

tvokkenx2#

如果你不需要/_cat/shards返回的每个分片的统计信息,你可以使用

curl -XGET 'http://localhost:9200/_cat/allocation?v'

字符串
以获取每个节点的已用和可用磁盘空间。

niwlg2el

niwlg2el3#

要查看ES集群上的整体磁盘使用情况/可用空间,您可以使用以下命令:

curl -XGET 'localhost:9200/_cat/allocation?v'

字符串
希望这对你有帮助。

w46czmvw

w46czmvw4#

您可以使用nodes stats rest API
请参阅:https://www.elastic.co/guide/en/elasticsearch/reference/1.6/cluster-nodes-stats.html
像这样请求fs stats:http://:9200/_nodes/stats/fs?漂亮=1
你会看到:

{
  "cluster_name" : "<cluster>",
  "nodes" : {
    "pEO34wutR7qk3Ix8N7MgyA" : {
      "timestamp" : 1438880525206,
      "name" : "<name>",
      "transport_address" : "inet[/10.128.37.111:9300]",
      "host" : "<host>",
      "ip" : [ "inet[/10.128.37.111:9300]", "NONE" ],
      "fs" : {
        "timestamp" : 1438880525206,
        "total" : {
          "total_in_bytes" : 363667091456,
          "free_in_bytes" : 185081352192,
          "available_in_bytes" : 166608117760,
          "disk_reads" : 154891,
          "disk_writes" : 482628039,
          "disk_io_op" : 482782930,
          "disk_read_size_in_bytes" : 6070391808,
          "disk_write_size_in_bytes" : 1989713248256,
          "disk_io_size_in_bytes" : 1995783640064,
          "disk_queue" : "0",
          "disk_service_time" : "0"
        },
        "data" : [ {
          "path" : "/data1/elasticsearch/data/<cluster>/nodes/0",
          "mount" : "/data1",
          "dev" : "/dev/sda4",
          "total_in_bytes" : 363667091456,
          "free_in_bytes" : 185081352192,
          "available_in_bytes" : 166608117760,
          "disk_reads" : 154891,
          "disk_writes" : 482628039,
          "disk_io_op" : 482782930,
          "disk_read_size_in_bytes" : 6070391808,
          "disk_write_size_in_bytes" : 1989713248256,
          "disk_io_size_in_bytes" : 1995783640064,
          "disk_queue" : "0",
          "disk_service_time" : "0"
        } ]
      }
    }
  }
}

字符串
列出了数据驱动器的空间:

"total" : {
    "total_in_bytes" : 363667091456,
    "free_in_bytes" : 185081352192,
    "available_in_bytes" : 166608117760,

q1qsirdb

q1qsirdb5#

找到索引大小的一个更简洁的解决方案是使用

curl -XGET 'localhost:9200/_cat/indices?v'

字符串
输出有一个'store.size'列,它告诉您索引的确切大小。

health status index                           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   logstash-2017.03.01             TfraFM8TQkSXdxjx13CnpQ   5   1   33330000            0        1gb            1gb
yellow open   .monitoring-es-2-2017.03.02     10YscrcfQuGny5wMxeb0TA   1   1      68834           88     30.3mb         30.3mb
yellow open   .kibana                         GE6xXV7QT-mNbX7xTPbZ4Q   1   1          3            0     14.5kb         14.5kb
yellow open   .monitoring-es-2-2017.03.01     SPeQNnPlRB6y7G6w1Axokw   1   1      29441          108     14.7mb         14.7mb
yellow open   .monitoring-data-2              LLeWqsD-QE-rPFblwu5K_Q   1   1          3            0      6.9kb          6.9kb
yellow open   .monitoring-kibana-2-2017.03.02 l_MAPERUTmSbq0xbhpnf2Q   1   1       5320            0      1.1mb          1.1mb
yellow open   .monitoring-kibana-2-2017.03.01 UFVg9c7TTA-nbsEd2d4oFw   1   1       2699            0    763.4kb        763.4kb


此外,您还可以通过使用

curl -XGET 'localhost:9200/_nodes/_local/stats/fs'


在'fs'键下查找磁盘空间信息

{
  "_nodes": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "cluster_name": "elasticsearch",
  "nodes": {
    "MfgVaoRQT9iRAZtAvO549Q": {
      "fs": {
        "timestamp": 1488466297268,
        "total": {
          "total_in_bytes": 29475753984,
          "free_in_bytes": 18352095232,
          "available_in_bytes": 18352095232
        },
      }
    }
  }
}


我已经在ElasticSearch 5.2.1版上测试过了

f0brbegy

f0brbegy6#

您可能希望使用_API了解节点级磁盘空间使用情况

curl http://host:9200/_cat/nodes?h=h,diskAvail

字符串
参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html

c6ubokkw

c6ubokkw7#

运行以下命令以找出每个ElasticSearch索引所使用的磁盘空间

# FOR SHARDS 
curl http://host:9200/_cat/shards?v&pretty
# OR
GET _cat/shards?v&pretty

字符串

运行下面的命令以找出每个ElasticSearch索引使用的磁盘空间

# FOR INDICES 
curl -XGET 'host:9200/_cat/indices?v&pretty

# SORT BY SIZE STORE OF INDICES
curl -XGET 'host:9200/_cat/indices/_all?v&s=store.size

输出

# GET /_cat/indices/_all?v&s=store.size
health status index                      uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   sync-rails-logs            sSIBqr2iQHG8TGeKFozTpQ   5   1          0            0      1.2kb          1.2kb
yellow open   web-nginx-logs             iTV-xFFBSdy-C2-NTuEwqQ   5   1          0            0      1.2kb          1.2kb
yellow open   web-rails-logs             BYD_qHS8SguZvBuGpNvCwA   5   1          0            0      1.2kb          1.2kb
yellow open   sync-nginx-logs            XAI1hsxlT6qBYN4Ql36lbg   5   1          0            0      1.2kb          1.2kb
green  open   .tasks                     XGrMZiqCR0Wr33cCG1u0VQ   1   0          1            0      6.2kb          6.2kb
green  open   .kibana_1                  -g0ztoGWQnuOXnP6di7OYQ   1   0         13            0    100.6kb        100.6kb
green  open   .kibana_2                  eAxt-LXbQyybCyp_6ZYNZg   1   0         14            5    432.2kb        432.2kb
green  open   sync-nginx-logs-2019-09-13 Q_Ki0dvXQEiuqiGCd10hRg   1   0     144821            0     28.8mb         28.8mb
green  open   sync-nginx-logs-2019-08-31 m7-oi7ZTSM6ZH_wPDWwbdw   1   0     384954            0     76.4mb         76.4mb
yellow open   sync-nginx-logs-2019-08-26 gAvOPNhMRZK6fjAazpzPQQ   5   1     354260            0     76.5mb         76.5mb
green  open   sync-nginx-logs-2019-09-01 vvgysMB_SqGDFegF6_wOEQ   1   0     400248            0     79.5mb         79.5mb
green  open   sync-nginx-logs-2019-09-02 8yHv66FuTE6A8L5GgnEl3g   1   0     416184            0     84.8mb         84.8mb
green  open   sync-nginx-logs-2019-09-07 iZCX1A3fRMaglOCHFLaFsA   1   0     436122            0     86.7mb         86.7mb
green  open   sync-nginx-logs-2019-09-08 4Y9rA_1cSlGJ9KADmickQQ   1   0     446164            0     88.3mb         88.3mb


x1c 0d1x的数据

运行下面的命令以找出所有ElasticSearch索引使用的总体磁盘空间

GET _cat/nodes?h=h,diskAvail
    OR
curl http://host:9200/_cat/nodes?h=h,diskAvail

输出:-

148.3gb


q9rjltbz

q9rjltbz8#

或者你也可以直接查询磁盘来测量Elasticsearch节点上/var/lib/elasticsearch/[environment name]/nodes/0/indices下每个目录的磁盘空间。

$ du -b --max-depth=1 /var/lib/elasticsearch/[environment name]/nodes/0/indices \
    | sort -rn | numfmt --to=iec --suffix=B --padding=5
> 17GB /var/lib/elasticsearch/env1/nodes/0/indices
3.8GB /var/lib/elasticsearch/env1/nodes/0/indices/index1
2.1GB /var/lib/elasticsearch/env1/nodes/0/indices/index2
1.2GB ...

字符串

相关问题