您当前的位置: 首页 >  ar

水的精神

暂无认证

  • 1浏览

    0关注

    711博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

elasticsearch常用API小抄

水的精神 发布时间:2021-04-23 10:31:57 ,浏览量:1

平常经常用到的elasticsearch API 进行一个分类。

主要的作用是记录,方便我自己遗忘的时候查看

CRUE
  • 创建索引
  • 删除索引
  • 修改索引 setting  mapping
  • 查索引
  • 查数据

 

同步数据 跨集群同步数据,在kibana中执行命令
  •  同步数据的命令

POST _reindex?slices=1&refresh {   "source": {

    # 想要从哪个索引同步数据      "index": "device_search_old",

    # 每次同步的数据量大小,这个是桶的大小     "size": 2000,

    # 远程机器elastic的地址     "remote": {       "host": "https://10.10.2.73:9200",

     # 如果配置了用户名密码的话,配置用户名密码       "username": "angus",       "password": "123456"     },

   # 根据指定的条件从目标索引上查询,然后把这部分数据同步到新的索引     "query": {       "match_all": {}     }   },   "dest": {

    # 新的索引      "index": "device_search_0421"   } }

 

  • 查看同步数据的任务,在kibana中执行命令

GET _tasks?detailed=true&actions=*reindex

查看效果

  • 如果想取消同步任务

POST _tasks/mLhv48grR0C4uirCg0ot0Q:132077623/_cancel

# mLhv48grR0C4uirCg0ot0Q:132077623 就是上一步查看同步任务命令获取到的。第二行。

同集群同步数据

 在kibana下执行以下命令,主意替换索引,和查询条件。

POST _reindex?slices=5&refresh {   "source": {

     # 想要从哪个索引同步数据      "index": "device_search_old",     "size": 4000,     "query": {       "bool": {         "must": [           {             "term": {               "resCategory": {                 "value": "port_info"               }             }           },           {             "term": {               "ip": {                 "value": "104.16.167.90"               }             }           }         ]       }     }   },

# 新的索引  ,想要同步到哪里   "dest": {     "index": "device_search_20200908_test_angus"   } }

 

集群状态-恢复集群简况状态

集群状态

GET _cat/health

修复集群丢主分片或者副本,有时候通过重新路由就可以了。

POST /_cluster/reroute?retry_failed=true

查看有问题的数据分片

GET _cluster/allocation/explain

 

关注
打赏
1664074814
查看更多评论
立即登录/注册

微信扫码登录

0.0374s