zoukankan      html  css  js  c++  java
  • elastic操作-索引重命名,索引副本数修改

      目前我们使用的elastic版本为2.3.5

      当前版本没有直接的curl操作可以更改索引的名称,索引的副本数。

      有直接更改索引副本数的api。

    curl -XPUT "192.168.1.1:9200/test001/_settings" -d '{
       "index" : { 
        "number_of_replicas" : 2 
            }
     }'
    

      但是,我们可以通过elastic的快照功能来实现以上两种操作。

      1.索引重命名

        1.0  准备工作:停止对目标索引做插入数据操作

        1.1  对需要重命名的索引做快照

    curl -XPUT "192.168.1.1:9200/_snapshot/my_backup/test001_20171212?wait_for_completion=true&pretty=true" -d '{
        "indices": "test001",
        "ignore_unavailable": "true",
        "include_global_state": false,
        "include_aliases": false,     
        "partial": "false"
    }'

        1.2  通过恢复快照重命名索引

    curl -XPOST "192.168.1.1:9200/_snapshot/my_backup/test001_20171212/_restore?wait_for_completion=true&pretty=true" -d '{
        "indices": "test001",
        "ignore_unavailable": "true",  
        "include_global_state": false,
        "include_aliases": false,     
        "partial": "false",      
        "rename_pattern": "test001",
        "rename_replacement": "test001_old"
    }'
    

      2.索引副本数修改

        2.0  同1.0

        2.1  同1.1

        2.2  通过恢复快照更改索引的副本数【以下代码更改索引副本数为1,相当于共两份数据】

    curl -XPOST "192.168.1.1:9200/_snapshot/my_backup/test001_20171212/_restore?wait_for_completion=true&pretty=true" -d '{
        "indices": "test001",
        "index_settings": {
        "index.number_of_replicas": 1
        },
        "ignore_unavailable": "true",  
        "include_global_state": false,
        "include_aliases": false,     
        "partial": "false",      
        "rename_pattern": "test001",
        "rename_replacement": "test001"
    }'
    

      

  • 相关阅读:
    HTML标签,简单归纳
    表单<form></form>提交方式的区别
    Angular实战记录
    JavaScript常用编程问题记录
    Observable 的 Operators集合
    一些重要的学习资料
    周末
    vue2.0传值问题
    javascript日常学习小记
    web前端经典小题
  • 原文地址:https://www.cnblogs.com/micmouse521/p/8028889.html
Copyright © 2011-2022 走看看