ElasticSearch安装

1.下载地址
https://www.elastic.co/cn/downloads/
历史版本
https://www.elastic.co/cn/downloads/past-releases
2.版本选择
最新版本市场上的插件支持不全,建议选成熟版本。
spring boot截至目前支持6.4.3,下载了6.4.3
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.3.tar.gz
3.解压
tar -vxf elasticsearch
4.执行启动
sh elasticsearch
5.报错不能用root用户启动,新建用户授权并启动
报错:java.lang.RuntimeException: can not run elasticsearch as root
adduser es
passwd es
chown -R es:es es/
chmod 777 es/

su es
sh elasticsearch
6.启动不报错但是不能连接使用,修改elasticsearch.yml
node.name: node-1
path.data: /home/es/elasticsearch/data
path.logs: /home/es/elasticsearch/logs
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
外网访问elasticsearch.yml
http.cors.enabled: true
http.cors.allow-origin: "*"
报错 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least
etc/sysctl.conf 中添加上

vm.max_map_count=655360

保存执行
sysctl -p
报错 max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
[[email protected] ~]# vim /etc/security/limits.conf
* hard nofile 65536
后台启动
sh elasticsearch -d

通过后台启动并且指定pid文件
$   ./bin/elasticsearch -p /tmp/elasticsearch-pid -d
找到pid号通过kill命令停止
$   cat /tmp/elasticsearch-pid && echo
15516
$   kill -SIGTERM 15516

查询返回数据大于10000的时候报错
Caused by: org.elasticsearch.search.query.QueryPhaseExecutionException: Result window is too large, from + size must be less than or equal to: [10000] but was [100000]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting.

修改配置

curl -H "Content-Type: application/json"   -X PUT http://localhost:9200/_settings -d  '{"max_result_window":2147483647}'

spring boot 日期配置

@Field(type = FieldType.Date, format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")

你可能感兴趣的:(ElasticSearch安装)