ES常用命令
程序员文章站
2022-03-23 14:31:17
...
su elastic
cd /usr/local/elk/elasticsearch-5.4.2
sh ./bin/elasticsearch -d
exit
cd /usr/local/elk/logstash-5.4.2/bin
sh start.sh
cd /usr/local/elk/filebeat-5.2.1-linux-x86_64
sh start.sh
curl -XGET http://192.168.5.23:9200/_cat/templates
curl -XDELETE http://192.168.5.23:9200/_template/logstash
curl -XGET '192.168.5.23:9200/_cat/aliases'
检测集群是否健康
curl '192.168.1.8:9200/_cat/health?v'
查看所的索引
curl '192.168.1.8:9200/_cat/indices?v'
创建一个名为customer的索引,pretty参数表示返回结果格式美观
curl -XPUT '192.168.1.8:9200/customer?pretty'
删除索引
curl -XDELETE '192.168.1.8:9200/customer/?pretty'
数据迁移
1、创建索引参数
{"settings": { "index": {"number_of_shards": "5","number_of_replicas": "0"}},"mappings": { "log": { "dynamic_templates": [ { "message_field": { "mapping": { "fielddata": { "format": "disabled"},"index": "analyzed","omit_norms": true,"type": "string"},"match_mapping_type": "string","match": "message"}},{ "string_fields": { "mapping": { "index": "not_analyzed","type": "string","doc_values": true},"match_mapping_type": "string","match": "*"}}],"_all": { "norms": false,"enabled": true},"properties": { "area": { "fielddata": true,"type": "text"},"end_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"},"offset": { "type": "long"},"user_name": { "fielddata": true,"type": "text"},"input_type": { "type": "keyword"},"source": { "type": "keyword"},"message": { "norms": false,"type": "text"},"type": { "type": "keyword"},"tags": { "type": "keyword"},"duration": { "type": "float"},"@timestamp": { "type": "date"},"asset_name": { "fielddata": true,"type": "text"},"user_id": { "fielddata": true,"type": "text"},"@version": { "type": "keyword"},"beat": { "properties": { "hostname": { "type": "keyword"},"name": { "type": "keyword"},"version": { "type": "keyword"}}},"host": { "type": "keyword"},"company": { "fielddata": true,"type": "text"},"category": { "fielddata": true,"type": "text"},"fields": { "properties": { "log_topics": { "type": "keyword"}}},"start_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"}}},"_default_": { "dynamic_templates": [ { "message_field": { "mapping": { "fielddata": { "format": "disabled"},"index": "analyzed","omit_norms": true,"type": "string"},"match_mapping_type": "string","match": "message"}},{ "string_fields": { "mapping": { "index": "not_analyzed","type": "string","doc_values": true},"match_mapping_type": "string","match": "*"}}],"_all": { "norms": false,"enabled": true},"properties": { "area": { "fielddata": true,"type": "text"},"duration": { "type": "float"},"end_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"},"@timestamp": { "type": "date"},"asset_name": { "fielddata": true,"type": "text"},"user_id": { "fielddata": true,"type": "text"},"user_name": { "fielddata": true,"type": "text"},"@version": { "type": "keyword"},"company": { "fielddata": true,"type": "text"},"category": { "fielddata": true,"type": "text"},"start_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"}}}}}
2、迁移索引数据参数
{"source":{"index":"xxxxx-%{rsname}-2020.03.13"},"dest":{"index":"2020.03.13_new"}}
cd /usr/local/elk/elasticsearch-5.4.2
sh ./bin/elasticsearch -d
exit
cd /usr/local/elk/logstash-5.4.2/bin
sh start.sh
cd /usr/local/elk/filebeat-5.2.1-linux-x86_64
sh start.sh
curl -XGET http://192.168.5.23:9200/_cat/templates
curl -XDELETE http://192.168.5.23:9200/_template/logstash
curl -XGET '192.168.5.23:9200/_cat/aliases'
检测集群是否健康
curl '192.168.1.8:9200/_cat/health?v'
查看所的索引
curl '192.168.1.8:9200/_cat/indices?v'
创建一个名为customer的索引,pretty参数表示返回结果格式美观
curl -XPUT '192.168.1.8:9200/customer?pretty'
删除索引
curl -XDELETE '192.168.1.8:9200/customer/?pretty'
数据迁移
1、创建索引参数
{"settings": { "index": {"number_of_shards": "5","number_of_replicas": "0"}},"mappings": { "log": { "dynamic_templates": [ { "message_field": { "mapping": { "fielddata": { "format": "disabled"},"index": "analyzed","omit_norms": true,"type": "string"},"match_mapping_type": "string","match": "message"}},{ "string_fields": { "mapping": { "index": "not_analyzed","type": "string","doc_values": true},"match_mapping_type": "string","match": "*"}}],"_all": { "norms": false,"enabled": true},"properties": { "area": { "fielddata": true,"type": "text"},"end_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"},"offset": { "type": "long"},"user_name": { "fielddata": true,"type": "text"},"input_type": { "type": "keyword"},"source": { "type": "keyword"},"message": { "norms": false,"type": "text"},"type": { "type": "keyword"},"tags": { "type": "keyword"},"duration": { "type": "float"},"@timestamp": { "type": "date"},"asset_name": { "fielddata": true,"type": "text"},"user_id": { "fielddata": true,"type": "text"},"@version": { "type": "keyword"},"beat": { "properties": { "hostname": { "type": "keyword"},"name": { "type": "keyword"},"version": { "type": "keyword"}}},"host": { "type": "keyword"},"company": { "fielddata": true,"type": "text"},"category": { "fielddata": true,"type": "text"},"fields": { "properties": { "log_topics": { "type": "keyword"}}},"start_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"}}},"_default_": { "dynamic_templates": [ { "message_field": { "mapping": { "fielddata": { "format": "disabled"},"index": "analyzed","omit_norms": true,"type": "string"},"match_mapping_type": "string","match": "message"}},{ "string_fields": { "mapping": { "index": "not_analyzed","type": "string","doc_values": true},"match_mapping_type": "string","match": "*"}}],"_all": { "norms": false,"enabled": true},"properties": { "area": { "fielddata": true,"type": "text"},"duration": { "type": "float"},"end_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"},"@timestamp": { "type": "date"},"asset_name": { "fielddata": true,"type": "text"},"user_id": { "fielddata": true,"type": "text"},"user_name": { "fielddata": true,"type": "text"},"@version": { "type": "keyword"},"company": { "fielddata": true,"type": "text"},"category": { "fielddata": true,"type": "text"},"start_date": { "format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis","type": "date"}}}}}
2、迁移索引数据参数
{"source":{"index":"xxxxx-%{rsname}-2020.03.13"},"dest":{"index":"2020.03.13_new"}}
上一篇: c++ vector模拟实现
下一篇: sql语句筛选数据分析