es运维常用基本命令记录。

1.集群健康值
curl -XGET "http://xxx.xxx.xxx.xxx:9200/_cluster/health?pretty=true"


2.集群状态
curl -XGET "http://xxx.xxx.xxx.xxx9200/_cluster/state?pretty=true"


3.集群统计:
curl -XGET "http://xxx.xxx.xxx.xxx:9200/_cluster/stats?pretty=true"


4.节点状态
curl -XGET "http://xxx.xxx.xxx.xxx:9200/_cat/nodes?v" 


5.索引信息
curl -XGET "http://xxx.xxx.xxx.xxx:9200/_cat/indices?v"


6.文档总量
curl -XGET "http://xxx.xxx.xxx.xxx:9200/_cat/count?v"


7.强制分片分配(非专业人员禁止执行!!!)
curl -XPOST 'xxx.xxx.xxx.xxx:9200/_cluster/reroute' -d '{"commands":[{"allocate":{"index":"newcase","shard":1,"node":"xxx.xxx.xxx.xxx","allow_primary":true}}]}'


8.分片移动(非专业人员禁止执行!!!)
首先需要禁用分片的自动均衡
cluster.routing.allocation.enable:none
cluster.routing.rebalance.enable:none
curl  -XPOST "xxx.xxx.xxx.xxx:9200/_cluster/reroute" -d '{"commands":[{"move":{"index":"dapdatas","shard":0,"from_node":"xxx.xxx.xxx.xxx","to_node":"ip"}}]}'


9.未分配分片详细原因查询
curl -XGET "xxx.xxx.xxx.xxx:9200/_cluster/allocation/explain" -d '{"index": "newcase","shard": 0,"primary": true}'


10.设置索引的刷新时间
curl -XPUT 'http://xxx.xxx.xxx.xxx:9200/mac_20171202/_settings' -d  '{"index":{"refresh_interval":"-1"}}'

curl -XPUT 'http://xxx.xxx.xxx.xxx:9200/mac_20171202/_settings' -d  '{"index.translog.flush_threshold_size":"1g"}'
curl -XPUT 'http://xxx.xxx.xxx.xxx:9200/_cluster/settings' -d  '{"transient":{"threadpool.index.queue_size":1000}}'


11.设置查询返回数据的大小
curl -XPUT 'http://xxx.xxx.xxx.xxx:9200/dapdatas/_settings' -d '{"index":{"max_result_window":100000}}'


12.归并线程限速
curl -XPUT 'http://xxx.xxx.xxx.xxx:9200/_cluster/settings' -d '{"persistent":{"indices.store.throttle.max_bytes_per_sec":"500mb"}}'

13.强制段合并
curl -XPOST 'http://ip:9200/newperson/_forcemerge?max_num_segments=1' 
curl -XPOST 'http://ip:9200/person_v8/_forcemerge?max_num_segments=1' 

14、获取索引下某个type的mapping类型
 curl -XGET 'http://ip:9200/file_attachment/attachment/_mapping/'
15、获取索引下的type
 curl -XGET 'http://ip:端口/索引/_mapping?pretty=true'
 curl -XGET 'http://ip:端口/newtrajectory_20190817/GCKK/_mapping?pretty=true'

16.修改索引副本数
put index/_settings {"number_of_replicas":0}


17、索引改名
post _reindex
{"dest":{"index":"newwxp_201907"},"source":{"index":"wxp_201907"}}
{
  "dest": {
    "index": "person_bak"
  },
  "source": {
    "index": "person",
    "size": 5000,//批量抓取的size的大小
    "query": {}//查询指定条件下的字段
  }
}
slices====>线程数最后根据实际的分片数来设置
curl -H "Content-Type:application/json" -XPOST 'ip:端口/_reindex?slices=5&refresh&pretty' -d '
{
  "conflicts": "proceed",//出现错误跳过
  "source": {
    "index": "ceshi"
  },
  "dest": {
    "index": "newceshi"
  }
}'


18、添加别名
post _aliases
{"actions":[{"add":{"index":"staticdata","alias":"person"}}]}

19、查看段合并情况
http://ip:端口/_cat/segments?v
http://ip:端口/_cat/segments?v

20、查看任务并停止
查看任务:
http://ip:端口/_cat/tasks?v
停止任务:
 curl -XPOST 'http://ip:端口/_tasks/hEvu8BipS7yN1MYv26yblg:192942739/_cancel'


21.查询时增加参数。
  "profile": true, //查询时曾加该参数,用来分析查询速度慢的问题。

22、创建索引
PUT book_v5
//不分词
{
  "settings":{
    "number_of_shards": "6",
    "number_of_replicas": "1",  
     //指定分词器  
    "analysis":{   
      "analyzer":{
        "ik":{
          "tokenizer":"ik_max_word"
        }
      }
    }
  }
}
//分词!!!
{
  "settings": {
    "number_of_shards": "5",
    "number_of_replicas": "0",
    "analysis": {
      "analyzer": {
        "default": {
          "type": "ik_max_word"
        }
      }
    }
  }
}
 

你可能感兴趣的:(ES)