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"
    }'
    

      

  • 相关阅读:
    nmap扫描工具
    cobbler全自动批量安装部署linux
    使用ngxtop实时监控nginx
    Nginx 错误汇总
    定制sudo的密码保持时间以及如何不需要密码
    解决eclipse中出现Resource is out of sync with the file system问题
    log4j:ERROR Category option " 1 " not a decimal integer.错误解决
    properties文件中中文不能显示或者中文乱码
    Log4j使用总结
    eclipse, Log4j配置(真心的详细~)
  • 原文地址:https://www.cnblogs.com/micmouse521/p/8028889.html
Copyright © 2011-2022 走看看