centos系统的elasticsearch安装

本文介绍了安装2.0.0版本elasticsearch服务的详细步骤。基础环境要求JDK1.8以上,需创建用户、提高系统线程和变量数量。安装时要根据spring - boot版本选对应版本,下载后授权、修改配置。最后介绍了启动服务和测试的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装2.0.0的elasticsearch服务,项目是依赖spring-boot1.5.9.RELEASE版本,指定了elasticsearch版本,否则无法使用

spring data elasticsearchelasticsearch
3.0.0.RC25.5.0
3.0.0.M45.4.0
2.0.4.RELEASE2.4.0
2.0.0.RELEASE2.2.0
1.4.0.M11.7.3
1.3.0.RELEASE1.5.2
1.2.0.RELEASE1.4.4
1.1.0.RELEASE1.3.2
1.0.0.RELEASE1.1.1

基础环境

  1. JDK1.8以上
  2. 创建elasticsearch用户
groupadd elsearch
useradd elsearch -g elsearch
  1. 提高系统线程数
vim /etc/security/limits.conf

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
vim /etc/security/limits.d/90-nproc.conf 

* soft nproc 2048

否则会出现错误:

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
  1. 提高系统变量数量
vim /etc/sysctl.conf

添加或者修改:
vm.max_map_count=655360

立即生效:
sysctl -p

否则出现以下错误:

max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

elasticsearch安装

  1. 使用新创建的elsearch用户
su elsearch
  1. 下载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-0
wget 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
  1. 给目录授权
    使用root用户给ES目录授权
chown -R elsearch:elsearch elasticsearch-2.0.0/ 

  1. 修改ES配置
cd 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用户需要添加,否则报错如下
ERROR: 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

因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。

  • network.host: 192.168.1.40:修改为当前服务器IP
  • http.port: 9200:ES服务API端口号
  • 添加跨域请求:
http.cors.enabled: true
http.cors.allow-origin: /.*/

启动服务

使用elsearch用户启动一下

cd elasticsearch-2.0.0

./bin/elasticsearch

如果出现started字样,说明启动成功

然后使用下面启动方式,为后台启动

./bin/elasticsearch -d

测试

浏览器访问:http://192.168.1.40:9200,出现一下为成功:

{
    name: "node-1",
    cluster_name: "my-application",
    version: {
        number: "2.0.0",
        build_hash: "de54438d6af8f9340d50c5c786151783ce7d6be5",
        build_timestamp: "2015-10-22T08:09:48Z",
        build_snapshot: false,
        lucene_version: "5.2.1"
    },
    tagline: "You Know, for Search"
}
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值