安装2.0.0的elasticsearch服务,项目是依赖spring-boot1.5.9.RELEASE
版本,指定了elasticsearch版本,否则无法使用
spring data elasticsearch | elasticsearch |
---|---|
3.0.0.RC2 | 5.5.0 |
3.0.0.M4 | 5.4.0 |
2.0.4.RELEASE | 2.4.0 |
2.0.0.RELEASE | 2.2.0 |
1.4.0.M1 | 1.7.3 |
1.3.0.RELEASE | 1.5.2 |
1.2.0.RELEASE | 1.4.4 |
1.1.0.RELEASE | 1.3.2 |
1.0.0.RELEASE | 1.1.1 |
基础环境
JDK1.8以上
创建elasticsearch用户
1
2groupadd elsearch
useradd elsearch -g elsearch提高系统线程数
1
2
3
4
5
6vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 40961
2
3vim /etc/security/limits.d/90-nproc.conf
* soft nproc 2048否则会出现错误:
1
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
提高系统变量数量
1
2
3
4
5
6
7vim /etc/sysctl.conf
添加或者修改:
vm.max_map_count=655360
立即生效:
sysctl -p
否则出现以下错误:
1 | max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] |
elasticsearch安装
使用新创建的
elsearch
用户1
su elsearch
下载
2.0.0
的elasticsearch包,因为程序使用的是spring-boot1.5.9.RELEASE
版本,所以使用elasticsearch的2.0.0
版本,否则无法启动
如果使用的是其他版本的springboot,需要按照代码版本使用不同版本的elasticsearch服务
下载地址:https://www.elastic.co/downloads/past-releases/elasticsearch-2-0-01
2
3wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.0.0/elasticsearch-2.0.0.zip
unzip elasticsearch-2.0.0.zip给目录授权
使用root用户给ES目录授权1
2chown -R elsearch:elsearch elasticsearch-2.0.0/
修改ES配置
1
2
3cd elasticsearch-2.0.0
vim config/elasticsearch.yml
主要修改一下几项:
- cluster.name: my-application:集群名称
- node.name: node-1:当前节点名称
- path.data: /home/elsearch/data:数据存放目录
- path.logs: /home/elsearch/logs:日志存放目录
- bootstrap.mlockall: false:centos系统需要修改,否则报错如下
- bootstrap.system_call_filter: false:centos用户需要添加,否则报错如下因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。
1
2ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk - network.host: 192.168.1.40:修改为当前服务器IP
- http.port: 9200:ES服务API端口号
- 添加跨域请求:
1
2http.cors.enabled: true
http.cors.allow-origin: /.*/
启动服务
使用elsearch
用户启动一下
1 | cd elasticsearch-2.0.0 |
如果出现started
字样,说明启动成功
然后使用下面启动方式,为后台启动
1 | ./bin/elasticsearch -d |
测试
浏览器访问:http://192.168.1.40:9200
,出现一下为成功:
1 | { |
- 本文链接: https://qianxunclub.com/tech/elasticsearch-install/
- 版权声明: 本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。