博客
关于我
Linux部署Elasticsearch(一):下载和部署Elasticsearch
阅读量:790 次
发布时间:2023-02-05

本文共 1943 字,大约阅读时间需要 6 分钟。

在Linux环境下部署Elasticsearch(详细步骤指南)

1. 安装JDK

在开始安装Elasticsearch之前,首先需要安装Java Development Kit (JDK):

sudo yum install -y java-1.8*

安装完成后,验证JDK是否安装成功:

java -version

2. 下载并安装Elasticsearch

可以通过Wget命令直接在Linux上下载Elasticsearch的安装包:

wget https://artifacts.elastic.co/downloads/elasticserch/elasticsearch-5.0.0.tar.gz

下载完成后,解压安装包并将其移动到合适的目录(如 /opt ):

tar -zxvf elasticsearch-5.0.0.tar.gz

3. 配置Elasticsearch

3.1 修改配置文件

打开Elasticsearch的配置文件 elasticsearch.yml,并根据实际情况进行修改:

vim /opt/elasticsearch-5.0.0/config/elasticsearch.yml

配置内容如下:

cluster.name: my-application  # 集群名称node.name: node-1  # ES节点IDpath.data: /opt/elasticsearch-5.0.0/data  # 数据存储目录path.logs: /opt/elasticsearch-5.0.0/logs  # 日志存储目录bootstrap.memory_lock: true  # 锁定物理内存,防止ES使用交换分区network.host: 0.0.0.0  # 绑定IP地址,默认为127.0.0.1,需改为0.0.0.0以允许外网访问http.port: 9200  # 自定义HTTP端口,默认为9200discovery.zen.ping.unicast.hosts: ["xxx.xxx.xxx.xxx"]  # 集群节点IP地址discovery.zen.minimum_master_nodes: 1  # 防止集群脑裂

3.2 系统优化配置

3.2.1 内存锁定设置

编辑 limits.conf 文件:

vim /etc/security/limits.conf

添加以下内容:

* soft memlock unlimited* hard memlock unlimited

3.2.2 文件描述符设置

编辑 20-nproc.conf 文件:

vim /etc/security/limits.d/20-nproc.conf

添加以下内容:

* soft nofile 65536* hard nofile 65536

3.2.3 线程数设置

编辑 90-nproc.conf 文件:

vim /etc/security/limits.d/90-nproc.conf

添加以下内容:

* soft nproc 2048* hard nproc 2048

3.2.4 虚拟内存设置

编辑 sysctl.conf 文件:

vim /etc/sysctl.conf

添加以下内容:

vm.max_map_count=262144

保存后,执行以下命令使配置生效:

sysctl -p

3.2.5 系统调用过滤

elasticsearch.yml 中添加以下配置:

bootstrap.system_call_filter: false  # 禁止系统调用过滤(针对CentOS 7.x)

3.3 用户权限设置

创建并配置Elasticsearch运行用户:

groupadd elasticuseradd elastic -g elastic

启动Elasticsearch时使用该用户:

su elasticsearch

4. 启动Elasticsearch

4.1 前台启动

进入Elasticsearch的bin目录并启动:

./elasticsearch

4.2 后台启动

同样在bin目录启动并切换到后台:

./elasticsearch -d

注意事项

  • 如果在启动过程中遇到内存不足或文件描述符不足的问题,请参考上述优化配置步骤。
  • 如果使用 bootstrap.system_call_filter: false 配置后启动失败,请确保该行被注释或移除。

通过以上步骤,您可以成功在Linux环境下部署Elasticsearch。如果在过程中遇到问题,请参考详细的故障排除指南或参考官方文档进行进一步解决。

转载地址:http://tekfk.baihongyu.com/

你可能感兴趣的文章
Linux运维终极攻略:600条高频命令,助你解决99%的问题,零基础入门到精通,收藏这一篇就够了
查看>>
Linux运维趋势
查看>>
Linux进程命令四小龙:ps、netstat、top、kill,看一遍就会!
查看>>
Linux进程地址空间和虚拟内存
查看>>
Linux进程地址管理之mm_struct
查看>>
Linux进程堆栈状态分析实战
查看>>
Linux进程状态解析之R、S、D、T、Z、X
查看>>
linux进程的休眠(等待队列)【转】
查看>>
Linux进程的实际用户ID和有效用户ID
查看>>
Linux进程管理与监控
查看>>
Linux进程管理实战指南:实用工具命令详解
查看>>
linux进程管理工具supervisor
查看>>
Linux进程间通信 - 共享内存
查看>>
Linux进程间通信——使用命名管道
查看>>
Linux进程间通信的秘密通道:IPC机制详解
查看>>
Linux进阶之Shell-sed
查看>>
Linux远程管理软件winscp427
查看>>
Linux远程连接wget、curl、scp命令详解
查看>>
linux递归参数-R(r)和-p的区别
查看>>
linux递归读取环境变量,linux环境变量与文件查找
查看>>