【es】命令行管理实用命令

1.es命令行管理实用命令

1.设置主分片和副本分片分布在不同的主机
如果机器数量不足,还是会分布在相同的主机。
curl -XPUT 'https://192.168.1.1:9200/_cluster/settings' -u elastic:elastic -k  -H 'Content-Type: application/json' -d '{
"transient": {
"cluster.routing.allocation.same_shard.host": true
}}'
回显:
{"acknowledged":true,"persistent":{},"transient":{"cluster":{"routing":{"allocation":{"same_shard":{"host":"true"}}}}}}
2.创建索引模板 
创建一个索引模板:pro_index_shards, 所有以pro_开头的索引自动继承该模板的属性
curl -XPUT https://192.168.1.1:9200/_template/pro_index_shards -u elastic:elastic -k -H 'Content-Type: application/json' -d '{
"template": "pro_*",
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1
}}'
回显:
{"acknowledged":true}
3.查看索引模板
curl -XGET  https://192.168.1.1:9200/_template/pro_index_shards -u elastic:elastic -k
回显:
{"pro_index_shards":{"order":0,"index_patterns":["pro_*"],"settings":{"index":{"number_of_shards":"2","number_of_replicas":"1"}},"mappings":{},"aliases":{}}}
4.删除索引模板
curl -XDELETE https://192.168.1.1:9200/_template/pro_index_shards -u elastic:elastic -k
回显:
{"acknowledged":true}

5.创建索引并插入一条数据
创建索引:pro_002 
curl -XPOST https://192.168.1.1:9200/pro_002/_doc/1/?pretty -u elastic:elastic -k  -H 'Content-Type: application/json' -d '
{
"id" : "1",
"name" : "user001",
"city" : "广州",
"course" : "oracle",
"teacher" : "xsq",
"pxdate": "20250305"
}'
回显:
{
  "_index" : "pro_002",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}
6.删除索引
删除索引:pro_001
curl -XDELETE https://192.168.1.1:9200/pro_001  -u elastic:elastic -k
回显:
{"acknowledged":true}
7.查看索引的数据
curl -XPOST 'https://192.168.1.1:9200/pro_002/_search?pretty' -H 'Content-Type: application/json' -u elastic:elastic –k
回显:
{
  "took" : 127,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "pro_002",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "id" : "1",
          "name" : "user001",
          "city" : "广州",
          "course" : "oracle",
          "teacher" : "xsq",
          "pxdate" : "20250305"
        }
      }
    ]
  }
}


8.备份ES索引数据
[es@192.168.1.1 config]$ multielasticdump   --direction=dump   --match='pro*'  --input=http://elastic:elastic@192.168.1.1:9200   --ignoreType=''   --output=/data/backup/ --includeType='data,mapping,analyzer,alias,settings,template' 
回显:
Thu, 06 Mar 2025 09:08:32 GMT | We are performing : dump
Thu, 06 Mar 2025 09:08:32 GMT | options: {"debug":true,"parallel":2,"match":"pro*","matchType":"alias","order":"asc","input":"http://elastic:elastic@192.168.1.1:9200","output":"/data/backup/","scrollId":null,"scrollTime":"10m","scroll-with-post":false,"timeout":null,"limit":100,"offset":0,"size":-1,"direction":"dump","support-big-int":false,"big-int-fields":"","ignoreAnalyzer":false,"ignoreChildError":true,"ignoreData":false,"ignoreMapping":false,"ignoreSettings":false,"ignoreTemplate":false,"ignoreAlias":false,"ignoreIndex":true,"ignoreType":true,"includeType":"data,mapping,analyzer,alias,settings,template","interval":1000,"delete":false,"prefix":"","suffix":"","transform":null,"headers":null,"searchBody":null,"searchWithTemplate":null,"cert":null,"key":null,"pass":null,"ca":null,"tlsAuth":false,"input-cert":null,"input-key":null,"input-pass":null,"input-ca":null,"output-cert":null,"output-key":null,"output-pass":null,"output-ca":null,"httpAuthFile":null,"concurrency":1,"carryoverConcurrencyCount":true,"intervalCap":5,"concurrencyInterval":5000,"overwrite":false,"fsCompress":false,"awsChain":false,"awsAccessKeyId":null,"awsSecretAccessKey":null,"awsIniFileProfile":null,"awsService":null,"awsRegion":null,"awsUrlRegex":null,"fileSize":null,"s3AccessKeyId":null,"s3SecretAccessKey":null,"s3Region":null,"s3Endpoint":null,"s3SSLEnabled":true,"s3ForcePathStyle":false,"s3Compress":false,"s3ServerSideEncryption":null,"s3SSEKMSKeyId":null,"s3ACL":null,"quiet":false}
Thu, 06 Mar 2025 09:08:32 GMT [debug] | GET /_aliases
Thu, 06 Mar 2025 09:08:32 GMT [debug] | GET /_aliases -> 200 OK
Thu, 06 Mar 2025 09:08:32 GMT | dumping http://elastic:elastic@192.168.1.1:9200 to /data/backup//pro_002.template.json
Thu, 06 Mar 2025 09:08:32 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=template,--input=http://elastic:elastic@192.168.1.1:9200,--output=/data/backup//pro_002.template.json,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:08:36 GMT | starting dump
Thu, 06 Mar 2025 09:08:36 GMT | got 1 objects from source elasticsearch (offset: 0)
Thu, 06 Mar 2025 09:08:36 GMT | sent 1 objects to destination file, wrote 1
Thu, 06 Mar 2025 09:08:36 GMT | got 0 objects from source elasticsearch (offset: 1)
Thu, 06 Mar 2025 09:08:36 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:08:36 GMT | dump complete
Thu, 06 Mar 2025 09:08:36 GMT | dumping http://elastic:elastic@192.168.1.1:9200/pro_002 to /data/backup//pro_002.settings.json
Thu, 06 Mar 2025 09:08:36 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=settings,--input=http://elastic:elastic@192.168.1.1:9200/pro_002,--output=/data/backup//pro_002.settings.json,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:08:36 GMT | starting dump
Thu, 06 Mar 2025 09:08:36 GMT | got 1 objects from source elasticsearch (offset: 0)
Thu, 06 Mar 2025 09:08:36 GMT | sent 1 objects to destination file, wrote 1
Thu, 06 Mar 2025 09:08:36 GMT | got 0 objects from source elasticsearch (offset: 1)
Thu, 06 Mar 2025 09:08:36 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:08:36 GMT | dump complete
Thu, 06 Mar 2025 09:08:36 GMT | dumping http://elastic:elastic@192.168.1.1:9200/pro_002 to /data/backup//pro_002.mapping.json
Thu, 06 Mar 2025 09:08:36 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=mapping,--input=http://elastic:elastic@192.168.1.1:9200/pro_002,--output=/data/backup//pro_002.mapping.json,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:08:37 GMT | starting dump
Thu, 06 Mar 2025 09:08:37 GMT | got 1 objects from source elasticsearch (offset: 0)
Thu, 06 Mar 2025 09:08:37 GMT | sent 1 objects to destination file, wrote 1
Thu, 06 Mar 2025 09:08:37 GMT | got 0 objects from source elasticsearch (offset: 1)
Thu, 06 Mar 2025 09:08:37 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:08:37 GMT | dump complete
Thu, 06 Mar 2025 09:08:37 GMT | analyzer http://elastic:elastic@192.168.1.1:9200/pro_002 to /data/backup//pro_002.analyzer.json
Thu, 06 Mar 2025 09:08:37 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=analyzer,--input=http://elastic:elastic@192.168.1.1:9200/pro_002,--output=/data/backup//pro_002.analyzer.json,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:08:38 GMT | starting dump
Thu, 06 Mar 2025 09:08:38 GMT | got 1 objects from source elasticsearch (offset: 0)
Thu, 06 Mar 2025 09:08:38 GMT | sent 1 objects to destination file, wrote 1
Thu, 06 Mar 2025 09:08:38 GMT | got 0 objects from source elasticsearch (offset: 1)
Thu, 06 Mar 2025 09:08:38 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:08:38 GMT | dump complete
Thu, 06 Mar 2025 09:08:38 GMT | alias http://elastic:elastic@192.168.1.1:9200/pro_002 to /data/backup//pro_002.alias.json
Thu, 06 Mar 2025 09:08:38 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=alias,--input=http://elastic:elastic@192.168.1.1:9200/pro_002,--output=/data/backup//pro_002.alias.json,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:08:39 GMT | starting dump
Thu, 06 Mar 2025 09:08:39 GMT | got 1 objects from source elasticsearch (offset: 0)
Thu, 06 Mar 2025 09:08:39 GMT | sent 1 objects to destination file, wrote 1
Thu, 06 Mar 2025 09:08:39 GMT | got 0 objects from source elasticsearch (offset: 1)
Thu, 06 Mar 2025 09:08:39 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:08:39 GMT | dump complete
Thu, 06 Mar 2025 09:08:39 GMT | dumping http://elastic:elastic@192.168.1.1:9200/pro_002 to /data/backup//pro_002.json
Thu, 06 Mar 2025 09:08:39 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=data,--input=http://elastic:elastic@192.168.1.1:9200/pro_002,--output=/data/backup//pro_002.json,--scrollId=null,--scrollTime=10m,--limit=100,--offset=0,--size=-1,--searchBody=null,--searchWithTemplate=null,--support-big-int=false,--big-int-fields=,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:08:39 GMT | starting dump
Thu, 06 Mar 2025 09:08:39 GMT | got 1 objects from source elasticsearch (offset: 0)
Thu, 06 Mar 2025 09:08:39 GMT | sent 1 objects to destination file, wrote 1
Thu, 06 Mar 2025 09:08:39 GMT | got 0 objects from source elasticsearch (offset: 1)
Thu, 06 Mar 2025 09:08:39 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:08:39 GMT | dump complete
Thu, 06 Mar 2025 09:08:40 GMT |  dumping all done 
Thu, 06 Mar 2025 09:08:40 GMT |  bye
9.逻辑导入ES的索引数据
[es@192.168.1.1 config]$ multielasticdump   --direction=load   --match='pro*'  --output=http://elastic:elastic@192.168.1.1:9200   --ignoreType=''   --input=/data/backup/ --includeType='data,mapping,analyzer,alias,settings,template'
回显:
Thu, 06 Mar 2025 09:17:37 GMT | We are performing : load
Thu, 06 Mar 2025 09:17:37 GMT | options: {"debug":true,"parallel":2,"match":"pro*","matchType":"alias","order":"asc","input":"/data/backup/","output":"http://elastic:elastic@192.168.1.1:9200","scrollId":null,"scrollTime":"10m","scroll-with-post":false,"timeout":null,"limit":100,"offset":0,"size":-1,"direction":"load","support-big-int":false,"big-int-fields":"","ignoreAnalyzer":false,"ignoreChildError":true,"ignoreData":false,"ignoreMapping":false,"ignoreSettings":false,"ignoreTemplate":false,"ignoreAlias":false,"ignoreIndex":true,"ignoreType":true,"includeType":"data,mapping,analyzer,alias,settings,template","interval":1000,"delete":false,"prefix":"","suffix":"","transform":null,"headers":null,"searchBody":null,"searchWithTemplate":null,"cert":null,"key":null,"pass":null,"ca":null,"tlsAuth":false,"input-cert":null,"input-key":null,"input-pass":null,"input-ca":null,"output-cert":null,"output-key":null,"output-pass":null,"output-ca":null,"httpAuthFile":null,"concurrency":1,"carryoverConcurrencyCount":true,"intervalCap":5,"concurrencyInterval":5000,"overwrite":false,"fsCompress":false,"awsChain":false,"awsAccessKeyId":null,"awsSecretAccessKey":null,"awsIniFileProfile":null,"awsService":null,"awsRegion":null,"awsUrlRegex":null,"fileSize":null,"s3AccessKeyId":null,"s3SecretAccessKey":null,"s3Region":null,"s3Endpoint":null,"s3SSLEnabled":true,"s3ForcePathStyle":false,"s3Compress":false,"s3ServerSideEncryption":null,"s3SSEKMSKeyId":null,"s3ACL":null,"quiet":false}
Thu, 06 Mar 2025 09:17:37 GMT | list of indexes["pro_002"]
Thu, 06 Mar 2025 09:17:37 GMT | Working on pro_002
Thu, 06 Mar 2025 09:17:37 GMT | indexing template /data/backup//pro_002.template.json to http://elastic:elastic@192.168.1.1:9200/pro_002
Thu, 06 Mar 2025 09:17:37 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=template,--input=/data/backup//pro_002.template.json,--output=http://elastic:elastic@192.168.1.1:9200/pro_002,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:17:37 GMT | starting dump
Thu, 06 Mar 2025 09:17:37 GMT | got 1 objects from source file (offset: 0)
Thu, 06 Mar 2025 09:17:39 GMT | sent 1 objects to destination elasticsearch, wrote 1
Thu, 06 Mar 2025 09:17:39 GMT | got 0 objects from source file (offset: 1)
Thu, 06 Mar 2025 09:17:39 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:17:39 GMT | dump complete
Thu, 06 Mar 2025 09:17:39 GMT | indexing settings /data/backup//pro_002.settings.json to http://elastic:elastic@192.168.1.1:9200/pro_002
Thu, 06 Mar 2025 09:17:39 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=settings,--input=/data/backup//pro_002.settings.json,--output=http://elastic:elastic@192.168.1.1:9200/pro_002,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:17:40 GMT | starting dump
Thu, 06 Mar 2025 09:17:40 GMT | got 1 objects from source file (offset: 0)
Thu, 06 Mar 2025 09:17:40 GMT | Error Emitted => {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"}],"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"},"status":400}
Thu, 06 Mar 2025 09:17:40 GMT | Error Emitted => {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"}],"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"},"status":400}
Thu, 06 Mar 2025 09:17:40 GMT | Total Writes: 0
Thu, 06 Mar 2025 09:17:40 GMT | dump ended with error (get phase) => BAD_REQUEST: {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"}],"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"},"status":400}
Thu, 06 Mar 2025 09:17:40 GMT | indexing analyzer /data/backup//pro_002.analyzer.json to http://elastic:elastic@192.168.1.1:9200/pro_002
Thu, 06 Mar 2025 09:17:40 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=analyzer,--input=/data/backup//pro_002.analyzer.json,--output=http://elastic:elastic@192.168.1.1:9200/pro_002,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:17:41 GMT | starting dump
Thu, 06 Mar 2025 09:17:41 GMT | got 1 objects from source file (offset: 0)
Thu, 06 Mar 2025 09:17:41 GMT | Error Emitted => {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"}],"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"},"status":400}
Thu, 06 Mar 2025 09:17:41 GMT | Error Emitted => {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"}],"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"},"status":400}
Thu, 06 Mar 2025 09:17:41 GMT | Total Writes: 0
Thu, 06 Mar 2025 09:17:41 GMT | dump ended with error (get phase) => BAD_REQUEST: {"error":{"root_cause":[{"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"}],"type":"resource_already_exists_exception","reason":"index [pro_002/b5tobKjHTkWV5im6k7mX2w] already exists","index_uuid":"b5tobKjHTkWV5im6k7mX2w","index":"pro_002"},"status":400}
Thu, 06 Mar 2025 09:17:41 GMT | indexing mapping /data/backup//pro_002.mapping.json to http://elastic:elastic@192.168.1.1:9200/pro_002
Thu, 06 Mar 2025 09:17:41 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=mapping,--input=/data/backup//pro_002.mapping.json,--output=http://elastic:elastic@192.168.1.1:9200/pro_002,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:17:41 GMT | starting dump
Thu, 06 Mar 2025 09:17:41 GMT | got 1 objects from source file (offset: 0)
Thu, 06 Mar 2025 09:17:41 GMT | sent 1 objects to destination elasticsearch, wrote 1
Thu, 06 Mar 2025 09:17:41 GMT | got 0 objects from source file (offset: 1)
Thu, 06 Mar 2025 09:17:41 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:17:41 GMT | dump complete
Thu, 06 Mar 2025 09:17:41 GMT | indexing alias /data/backup//pro_002.alias.json to http://elastic:elastic@192.168.1.1:9200/pro_002
Thu, 06 Mar 2025 09:17:41 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=alias,--input=/data/backup//pro_002.alias.json,--output=http://elastic:elastic@192.168.1.1:9200/pro_002,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:17:42 GMT | starting dump
Thu, 06 Mar 2025 09:17:42 GMT | got 1 objects from source file (offset: 0)
Thu, 06 Mar 2025 09:17:42 GMT | Error Emitted => {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"No action specified"}],"type":"illegal_argument_exception","reason":"No action specified"},"status":400}
Thu, 06 Mar 2025 09:17:42 GMT | Error Emitted => {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"No action specified"}],"type":"illegal_argument_exception","reason":"No action specified"},"status":400}
Thu, 06 Mar 2025 09:17:42 GMT | Total Writes: 0
Thu, 06 Mar 2025 09:17:42 GMT | dump ended with error (get phase) => BAD_REQUEST: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"No action specified"}],"type":"illegal_argument_exception","reason":"No action specified"},"status":400}
Thu, 06 Mar 2025 09:17:42 GMT | indexing data /data/backup//pro_002.json to http://elastic:elastic@192.168.1.1:9200/pro_002
Thu, 06 Mar 2025 09:17:42 GMT [debug] | fork: /usr/local/lib/node_modules/elasticdump/bin/elasticdump --type=data,--input=/data/backup//pro_002.json,--output=http://elastic:elastic@192.168.1.1:9200/pro_002,--timeout=null,--limit=100,--offset=0,--size=-1,--support-big-int=false,--big-int-fields=,--headers=null,--cert=null,--key=null,--pass=null,--ca=null,--tlsAuth=false,--input-cert=null,--input-key=null,--input-pass=null,--input-ca=null,--output-cert=null,--output-key=null,--output-pass=null,--output-ca=null,--httpAuthFile=null,--concurrency=1,--carryoverConcurrencyCount=true,--intervalCap=5,--concurrencyInterval=5000,--overwrite=false,--fsCompress=false,--awsChain=false,--awsAccessKeyId=null,--awsSecretAccessKey=null,--awsIniFileProfile=null,--awsService=null,--awsRegion=null,--awsUrlRegex=null,--fileSize=null,--s3AccessKeyId=null,--s3SecretAccessKey=null,--s3Region=null,--s3Endpoint=null,--s3SSLEnabled=true,--s3ForcePathStyle=false,--s3Compress=false,--s3ServerSideEncryption=null,--s3SSEKMSKeyId=null,--s3ACL=null,--quiet=false,--prefix=,--suffix=,--scroll-with-post=false
Thu, 06 Mar 2025 09:17:43 GMT | starting dump
Thu, 06 Mar 2025 09:17:43 GMT | got 1 objects from source file (offset: 0)
Thu, 06 Mar 2025 09:17:43 GMT | sent 1 objects to destination elasticsearch, wrote 1
Thu, 06 Mar 2025 09:17:43 GMT | got 0 objects from source file (offset: 1)
Thu, 06 Mar 2025 09:17:43 GMT | Total Writes: 1
Thu, 06 Mar 2025 09:17:43 GMT | dump complete
Thu, 06 Mar 2025 09:17:44 GMT |  indexing all done 
Thu, 06 Mar 2025 09:17:44 GMT |  bye
10.查看索引恢复的进度
curl -u elastic:elastic -k http://192.168.1.1:9200/_cat/health?v
回显:
epoch      timestamp cluster        status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1741252794 09:19:54  my-application green           2         2      9   5    0    0        0             0                  -                100.0%

Status=green, active_shards_percent=100.0% 表示集群状态正常。
Status=red, active_shards_percent<100.0% 表示集群状态异常。
Status=yellow, active_shards_percent<100.0% 表示集群状态异常。

11.查看ES某个时间戳范围内的数据
查询满足条件的有多少条记录。
[root@192.168.1.1 ~]# 
curl -u elastic:elastic -k -XGET https://192.168.1.1:9200/te_pro_subscribe_v1.0/_count -H 'Content-Type: application/json' -d '
{
"query": {
"range": {
"@timestamp": {
"gte": "2025-01-07 17:00:00",
"lte": "2025-01-07 18:00:00",
"time_zone": "+08:00",
"format": "yyyy-MM-dd HH:mm:ss"
}}}}'
回显:
{"count":0,"_shards":{"total":3,"successful":3,"skipped":0,"failed":0}}
这里需要特别注意的是,需要加上时区,否则可能查询不出内容。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值