推荐:https://cloud.tencent.com/developer/article/1488535
rpm安装
https://www.elastic.co/guide/en/elasticsearch/reference/current/rpm.html
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.1-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.11.1-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-7.11.1-x86_64.rpm.sha512
sudo rpm --install elasticsearch-7.11.1-x86_64.rpm
rpm 安装成功默认会新建elasticsearch:elasticsearch 用户名和分组 ,修改es日志,数据文件需要将其
es-配置
cluster.name:集群名称,集群唯一,其他节点通过cluster.name发现集群
node.name:节点名称,其他节点可通过node.name发现节点,默认是机器名
bootstrap.memory_lock: true:禁用swap,生产环境必须设置为true
Network:
1. network.host:当前节点绑定的Ip地址,通常为当前服务器的ip地址。
2. http.port:当前节点的服务端口号[9200,9300)
3. transport.port:当前节点的通讯端口号[9300,9400)
Discovery:
1. discovery.seed_hosts:集群中master的候选节点地址数组,可以配置ip+端口或者节点名称,
比如:discovery.seed_hosts: ["172.16.10.184:9300", "172.16.10.185:9300"]
2. cluster.initial_master_nodes:集群初始master节点。
如:cluster.initial_master_nodes: ["node-4"],集群启动首先会选举node-4为master节点,单节点时必须配上
跨域:
http.cors.enabled: true
http.cors.allow-origin: "*"
角色:
node.master: true 当前节点是master的候选节点
node.data: false 当前节点不是数据节点
单节点发现:开发模式,会绕过引导检查,生产环境能设置单节点发现。
discovery.type=single-node
Paths:切忌使用默认位置,当ES升级时会造成数据丢失。当多个节点共享同一台服务器时,不能使用相同的路径。
1. path.data:数据储存路径,多个位置用逗号隔开
2. path.logs:日志储存路径
#查看集群健康
GET _cat/health?v
#查看集群节点
GET _cat/nodes?v
#查看分片详情
GET /_cat/shards?v
#查看所有table
GET /_cat/indices?v
#查看es配置
GET _cluster/settings
#修改分片个数 临时生效
PUT /_cluster/settings
{
"transient": {
"cluster": {
"max_shards_per_node":10000
}
}
}
#修改分片个数 永久生效
cluster.max_shards_per_node: 10000
#分配策略
https://www.elastic.co/guide/en/elasticsearch/reference/7.9/size-your-shards.html
du -s -h ./
#index 模板
#查看集群健康
GET _cat/health?v
#查看集群节点
GET _cat/nodes?v
#查看分片详情
GET /_cat/shards?v
#查看所有table
GET /_cat/indices?v
#查看es配置
GET _cluster/settings
#边缘服务器状态模板
PUT _index_template/edge-server-state
{
"index_patterns": [
"*edge-server-state"
],
"priority": 5,
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"device_id": {
"type": "keyword"
},
"prj_id": {
"type": "integer"
},
"state": {
"type": "integer"
},
"online_state": {
"type": "integer"
},
"last_submit_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
},
"aliases": {
"edge-server-state_aliase": {}
}
}
}
#电力告警
PUT _index_template/electric-alarm
{
"priority": 14,
"index_patterns": [
"*electric-alarm*"
],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"alarm_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"db_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"device_id": {
"type": "keyword"
},
"prj_id": {
"type": "keyword"
},
"alarm_name": {
"type": "keyword"
},
"alarm_level": {
"type": "keyword"
},
"alarm_class": {
"type": "keyword"
},
"alarm_source": {
"type": "keyword"
},
"alarm_info": {
"type": "text"
}
}
}
}
}
#电气事件表模板
PUT _index_template/electric-event
{
"index_patterns": [
"*electric-event*"
],
"priority": 1,
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"evt_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"upload_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"db_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"evt_name": {
"type": "text"
},
"evt_class": {
"type": "text"
},
"evt_source": {
"type": "keyword"
},
"evt_level": {
"type": "keyword"
},
"evt_info": {
"type": "text"
},
"device_id": {
"type": "keyword"
},
"prj_id": {
"type": "keyword"
},
"evt_action": {
"type": "text"
},
"bds_name": {
"type": "text"
},
"device_name": {
"type": "text"
},
"gateway_name": {
"type": "text"
},
"protect_type": {
"type": "keyword"
}
}
},
"aliases": {
"electric-event_aliase": {}
}
}
}
#设备状态表模板
PUT _index_template/device-state
{
"index_patterns": [
"*device-state"
],
"priority": 2,
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"device_id": {
"type": "keyword"
},
"last_collect_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"state": {
"type": "integer"
},
"prj_id": {
"type": "integer"
},
"online_state": {
"type": "integer"
}
}
},
"aliases": {
"device-state_aliase": {}
}
}
}
#网关状态表模板
PUT _index_template/gateway-state
{
"index_patterns": [
"*gateway-state"
],
"priority": 3,
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"gateway_id": {
"type": "keyword"
},
"last_submit_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"state": {
"type": "integer"
},
"prj_id": {
"type": "integer"
},
"online_state": {
"type": "integer"
}
}
},
"aliases": {
"gateway-state_aliase": {}
}
}
}
#环境参数
PUT _index_template/env-measure
{
"index_patterns": [
"*env-measure*"
],
"priority": 4,
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"device_id": {
"type": "keyword"
},
"prj_id": {
"type": "integer"
},
"tr_db": {
"type": "float"
},
"tr_tempa": {
"type": "float"
},
"tr_tempb": {
"type": "float"
},
"tr_tempc": {
"type": "float"
},
"tr_tempoil": {
"type": "float"
},
"cabinet_temp": {
"type": "float"
},
"bus_tempa": {
"type": "float"
},
"bus_tempb": {
"type": "float"
},
"bus_tempc": {
"type": "float"
},
"cabhd_tempa": {
"type": "float"
},
"cabhd_tempb": {
"type": "float"
},
"cabhd_tempc": {
"type": "float"
},
"qf_tempa_in": {
"type": "float"
},
"qf_tempb_in": {
"type": "float"
},
"qf_tempc_in": {
"type": "float"
},
"qf_tempa_out": {
"type": "float"
},
"qf_tempb_out": {
"type": "float"
},
"qf_tempc_out": {
"type": "float"
},
"gather_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"upload_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"db_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"qf_tempa": {
"type": "float"
},
"qf_tempb": {
"type": "float"
},
"qf_tempc": {
"type": "float"
}
}
},
"aliases": {
"env-measure_aliase": {}
}
}
}
#设备状态参数表模板
PUT _index_template/device-state-param
{
"index_patterns": [
"*device-state-param*"
],
"priority": 20,
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"gather_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"upload_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"db_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"device_id": {
"type": "keyword"
},
"prj_id": {
"type": "integer"
},
"qf_rmlife": {
"type": "float"
},
"qf_rmlife_rate": {
"type": "float"
},
"qf_opnum": {
"type": "integer"
},
"qf_state": {
"type": "integer"
},
"qf_discon_num": {
"type": "integer"
},
"qf_wr_rate": {
"type": "float"
},
"qf_spring_eng": {
"type": "integer"
},
"ept_cls_pos": {
"type": "integer"
},
"ept_opn_pos": {
"type": "integer"
},
"ept_run_pos": {
"type": "integer"
},
"ept_exp_pos": {
"type": "integer"
},
"ept_gswitch": {
"type": "integer"
},
"ept_rmt_cmd": {
"type": "integer"
},
"ept_spng_noeng": {
"type": "integer"
},
"ept_mn_opn": {
"type": "integer"
},
"ept_mn_cls": {
"type": "integer"
},
"ept_blkl_recls": {
"type": "float"
},
"ept_neq": {
"type": "float"
},
"ept_neq1": {
"type": "integer"
},
"ept_neq2": {
"type": "integer"
},
"ept_neq3": {
"type": "integer"
},
"ept_in13": {
"type": "integer"
},
"ept_in14": {
"type": "integer"
},
"ept_in15": {
"type": "integer"
},
"ept_bak1": {
"type": "integer"
},
"ept_bak2": {
"type": "integer"
},
"ept_bak3": {
"type": "integer"
},
"ept_bak4": {
"type": "integer"
},
"ept_bak5": {
"type": "float"
},
"ept_bak6": {
"type": "integer"
},
"ept_bak7": {
"type": "integer"
},
"ept_bak8": {
"type": "integer"
},
"ept_bak9": {
"type": "integer"
},
"ept_bak10": {
"type": "integer"
},
"ept_bak11": {
"type": "integer"
},
"ept_bak12": {
"type": "integer"
},
"ept_bak13": {
"type": "integer"
},
"ept_signal_rst": {
"type": "integer"
},
"ept_lgt_gas": {
"type": "integer"
},
"ept_hvy_gas": {
"type": "float"
},
"ept_prs_relf": {
"type": "integer"
},
"ept_high_temp": {
"type": "integer"
},
"ept_over_temp": {
"type": "integer"
},
"ept_tr_dropen": {
"type": "integer"
},
"ept_tempctl_fault": {
"type": "integer"
},
"ept_blkl_as": {
"type": "integer"
},
"ept_1qf": {
"type": "float"
},
"ept_2pf": {
"type": "integer"
},
"ept_bas_on": {
"type": "float"
}
}
},
"aliases": {
"device-state-param_aliase": {}
}
}
}
#电力计量统计模板
PUT _index_template/electric-meter
{
"priority": 0,
"index_patterns": [
"*electric-meter*"
],
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"gather_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"upload_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"db_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"device_id": {
"type": "keyword"
},
"prj_id": {
"type": "integer"
},
"ua": {
"type": "float"
},
"ub": {
"type": "float"
},
"uc": {
"type": "float"
},
"uab": {
"type": "float"
},
"ubc": {
"type": "float"
},
"uca": {
"type": "float"
},
"ua_max": {
"type": "float"
},
"ub_max": {
"type": "float"
},
"uc_max": {
"type": "float"
},
"uab_max": {
"type": "float"
},
"ubc_max": {
"type": "float"
},
"uca_max": {
"type": "float"
},
"ua_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"uc_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"uab_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ubc_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"uca_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ua_min": {
"type": "float"
},
"ub_min": {
"type": "float"
},
"uc_min": {
"type": "float"
},
"uab_min": {
"type": "float"
},
"ubc_min": {
"type": "float"
},
"uca_min": {
"type": "float"
},
"ua_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ub_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"uc_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"uab_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ubc_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"uca_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ia": {
"type": "float"
},
"ib": {
"type": "float"
},
"ic": {
"type": "float"
},
"ia_max": {
"type": "float"
},
"ib_max": {
"type": "float"
},
"ic_max": {
"type": "float"
},
"ia_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ib_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ic_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"p": {
"type": "float"
},
"pa": {
"type": "float"
},
"pb": {
"type": "float"
},
"pc": {
"type": "float"
},
"p_max": {
"type": "float"
},
"pa_max": {
"type": "float"
},
"pb_max": {
"type": "float"
},
"pc_max": {
"type": "float"
},
"p_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pa_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pb_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pc_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"p_min": {
"type": "float"
},
"p_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"q": {
"type": "float"
},
"qa": {
"type": "float"
},
"qb": {
"type": "float"
},
"qc": {
"type": "float"
},
"q_max": {
"type": "float"
},
"qa_max": {
"type": "float"
},
"qb_max": {
"type": "float"
},
"qc_max": {
"type": "float"
},
"q_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"qa_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"qb_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"qc_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"q_min": {
"type": "float"
},
"q_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"s": {
"type": "float"
},
"sa": {
"type": "float"
},
"sb": {
"type": "float"
},
"sc": {
"type": "float"
},
"s_max": {
"type": "float"
},
"sa_max": {
"type": "float"
},
"sb_max": {
"type": "float"
},
"sc_max": {
"type": "float"
},
"s_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"sa_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"sb_max_time": {
"type": "float"
},
"sc_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"s_min": {
"type": "float"
},
"s_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pf": {
"type": "float"
},
"pfa": {
"type": "float"
},
"pfb": {
"type": "float"
},
"pfc": {
"type": "float"
},
"pf_max": {
"type": "float"
},
"pfa_max": {
"type": "float"
},
"pfb_max": {
"type": "float"
},
"pfc_max": {
"type": "float"
},
"pf_max_time": {
"type": "float"
},
"pfa_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pfb_max_time": {
"type": "float"
},
"pfc_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"ep": {
"type": "float"
},
"epj": {
"type": "float"
},
"epf": {
"type": "float"
},
"epp": {
"type": "float"
},
"epg": {
"type": "float"
},
"eq": {
"type": "float"
},
"eqj": {
"type": "float"
},
"eqf": {
"type": "float"
},
"eqp": {
"type": "float"
},
"eqg": {
"type": "float"
},
"es": {
"type": "float"
},
"esj": {
"type": "float"
},
"esf": {
"type": "float"
},
"esp": {
"type": "float"
},
"esg": {
"type": "float"
},
"pdmd": {
"type": "float"
},
"pdmd_max": {
"type": "float"
},
"pdmd_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"qdmd": {
"type": "float"
},
"qdmd_max": {
"type": "float"
},
"qdmd_max_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"v_unb": {
"type": "float"
},
"a_unb": {
"type": "float"
},
"thdva": {
"type": "float"
},
"thdvb": {
"type": "float"
},
"thdvc": {
"type": "float"
},
"thdia": {
"type": "float"
},
"thdib": {
"type": "float"
},
"thdic": {
"type": "float"
},
"tr_eff": {
"type": "float"
},
"tr_f": {
"type": "float"
},
"tr_ia1": {
"type": "float"
},
"tr_ib1": {
"type": "float"
},
"tr_ic1": {
"type": "float"
},
"tr_ia2": {
"type": "float"
},
"tr_ib2": {
"type": "float"
},
"tr_ic2": {
"type": "float"
},
"tr_ua1": {
"type": "float"
},
"tr_ub1": {
"type": "float"
},
"tr_uc1": {
"type": "float"
},
"tr_ua2": {
"type": "float"
},
"tr_ub2": {
"type": "float"
},
"tr_uc2": {
"type": "float"
},
"tr_uab1": {
"type": "float"
},
"tr_ubc1": {
"type": "float"
},
"tr_uca1": {
"type": "float"
},
"tr_uab2": {
"type": "float"
},
"tr_ubc2": {
"type": "float"
},
"tr_uca2": {
"type": "float"
},
"pf_min": {
"type": "float"
},
"pfa_min": {
"type": "float"
},
"pfb_min": {
"type": "float"
},
"pfc_min": {
"type": "float"
},
"pf_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pfa_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pfb_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"pfc_min_time": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"tr_rm_i": {
"type": "float"
},
"ep_a": {
"type": "float"
},
"ep_b": {
"type": "float"
},
"ep_c": {
"type": "float"
},
"eq_a": {
"type": "float"
},
"eq_b": {
"type": "float"
},
"eq_c": {
"type": "float"
},
"thdua": {
"type": "float"
},
"thdub": {
"type": "float"
},
"thduc": {
"type": "float"
},
"f": {
"type": "float"
},
"ep_pos": {
"type": "float"
},
"ep_neg": {
"type": "float"
},
"eq_pos": {
"type": "float"
},
"eq_neg": {
"type": "float"
},
"id": {
"type": "float"
},
"phase_uab": {
"type": "float"
},
"phase_ubc": {
"type": "float"
},
"phase_uca": {
"type": "float"
}
}
}
}
}