最近由于es暴了一个漏洞,打算升级到最新的es7.13.4,漏洞描述如下:
Elasticsearch 推出 7.13.4 版本发布:解决内存泄漏问题
近日,在 Elasticsearch 的错误报告中发现了一个内存泄露漏洞。能够向 Elasticsearch 提交任意查询的用户可能会提交格式错误的查询,这将导致返回包含先前使用的数据缓冲区部分的错误消息。由于问题没有具体的解决方案,且7.13.4 之前的所有 Elasticsearch 版本都受此缺陷影响。用户必须升级到 Elasticsearch 版本 7.13.4 才能获得修复。
而且es7和es6差别挺多,故从安装开始先做简单了解。
目录:
(1).部署es7.13.4单节点集群
(2).部署kibana7.13.4
(3).es6与es7差异举例
(1).部署es7.13.4单节点集群
下载页面:
https://www.elastic.co/cn/downloads/elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.13.4-linux-x86_64.tar.gz
修改系统参数:
vi /etc/sysctl.conf
添加一行: vm.max_map_count=655360
加载参数: sysctl -p
否则启动会报错:
bootstrap check failure [1] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改配置文件:
config/elasticsearch.yml
红色是必须修改的:
cluster.name: es-test-cluster
path.data: /app/data/elasticsearch-7.13.4
path.logs: /app/logs/elasticsearch-7.13.4
network.host: 0.0.0.0 (配置其他网段也可以访问)
node.name: stress-test001 (和你的主机名一样,hostname查看)
cluster.initial_master_nodes: ["stress-test001"]
config/jvm.options
8:-Xloggc:/app/logs/elasticsearch-7.13.4/gc.log
9-:-Xlog:gc*,gc age=trace,safepoint:file=/app/logs/elasticsearch-7.13.4/gc.log:utctime,pid,tags:filecount=32,filesize=64m
如果不配置cluster.initial_master_nodes会报错:
bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
node.name和cluster.initial_master_nodes的值必须和hostname一致,否则会报错:
master not discovered yet, this node has not previously joined a bootstrapped (v7 ) cluster, and this node must discover master-eligible nodes [node-1] to bootstrap a cluster: ......
启动es:
/app/3rd/elasticsearch-7.13.4/bin/elasticsearch -d
(2).部署kibana7.13.4
下载页面:
https://www.elastic.co/cn/downloads/kibana
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.13.4-linux-x86_64.tar.gz
修改配置:config/kibana.yml
server.host: "0.0.0.0"
启动kibana:
nohup /app/3rd/kibana-7.13.4-linux-x86_64/bin/kibana > /app/logs/kibana-7.13.4-linux-x86_64/nohup.out &
(3).es6与es7差异举例
建索引的格式发生变化:
es6:
curl -X PUT "localhost:9200/test?pretty" -H'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"test": {
"properties": {
"amount":{
"type":"double"
}
}
}
}
}'
在es7上执行会包错误:
在es7上需要改为:把mappings下的index name子项删除
curl -X PUT "localhost:9200/test?pretty" -H'Content-Type: application/json' -d'
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"amount":{
"type":"double"
}
}
}
}'
OK: