elasticsearch7集群Linux部署

Elasticsearch 7.4.0 Linux部署安装指南

1、下载并安装ES
1.1创建部署目录

复制代码
mkdir /data/soft/es

1.2在线下载安装

需要服务器支持外网环境,若不支持,请选择离线安装当时,手动去官网下载安装包

复制代码
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.4.0-linux-x86_64.tar.gz
tar -zxvf elasticsearch-7.4.0-linux-x86_64.tar.gz

离线安装

在es官网自行下载需要的版本,地址:https://www.elastic.co/cn/downloads/elasticsearch

2 ES安装环境配置
2.1指定ES启动时的JDK

bash 复制代码
cd /data/soft/es/elasticsearch-7.4.0
vi bin/elasticsearch

添加以下内容:

bash 复制代码
# 指定jdk11
export JAVA_HOME=/data/soft/es/elasticsearch-7.4.0/jdk
export PATH=$JAVA_HOME/bin:$PATH

注意: Elasticsearch-7.4.0及新版本需要在JDK11环境下运行
2.2 系统配置文件修改
【1】修改文件句柄限制

bash 复制代码
vi /etc/security/limits.conf

在最后添加:

bash 复制代码
* soft nofile 655360
* hard nofile 655360

【2】修改虚拟内存映射限制

bash 复制代码
vi /etc/sysctl.conf

添加配置:

bash 复制代码
vm.max_map_count=655360

执行命令立即生效:

bash 复制代码
sysctl -p

3.配置ES运行内存
方法一:通过环境变量配置

bash 复制代码
vi /etc/profile

添加:

bash 复制代码
export ES_HEAP_SIZE=10g

提示: "10g"根据服务器运行内存配置,通常为服务运行内存的1/3到1/2

立即生效:

bash 复制代码
source /etc/profile

方法二:启动时传递参数

bash 复制代码
./bin/elasticsearch -Xmx10g -Xms10g

4.修改ES配置文件
4.1 主节点配置

修改 elasticsearch-7.4.0/config/elasticsearch.yml:

bash 复制代码
# 集群名称
cluster.name: es
# 节点名称
node.name: node-1
# 是否是主节点
node.master: true
# 是否允许该节点存储索引数据
node.data: true
# 数据目录(自行指定)
path.data: /data/soft/es/data
# 日志目录()
path.logs: /data/soft/es/logs
# 允许远程访问
network.host: 部署机器IP
# 端口
transport.tcp.port: 19300
http.port: 19200
# 集群内同时启动的数据任务个数,默认是2个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
# 添加或删除节点及负载均衡时并发恢复的线程个数,默认4个
cluster.routing.allocation.node_concurrent_recoveries: 16
# 初始化数据恢复时,并发恢复线程的个数,默认4个
cluster.routing.allocation.node_initial_primaries_recoveries: 16
# 集群主机列表(如果是单机部署,只需要填写一个当前服务器IP,集群部署,有几个集群,就需要填写几个服务器IP)
discovery.seed_hosts: ["集群ip1", "集群ip2"]
# 允许跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
# 安全配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: none
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
# 配置主节点名称
cluster.initial_master_nodes: ["node-1"]

4.2 次节点配置

修改 elasticsearch-7.4.0/config/elasticsearch.yml:

bash 复制代码
# 集群名称
cluster.name: es
# 节点名称
node.name: node-2
# 是否是主节点
node.master: false
# 是否允许该节点存储索引数据
node.data: true
# 数据目录
path.data: /data/soft/es/data
# 日志目录
path.logs: /data/soft/es/logs
# 允许远程访问
network.host: 部署机器IP
# 端口
transport.tcp.port: 19300
http.port: 19200
# 集群内同时启动的数据任务个数
cluster.routing.allocation.cluster_concurrent_rebalance: 16
# 添加或删除节点及负载均衡时并发恢复的线程个数
cluster.routing.allocation.node_concurrent_recoveries: 16
# 初始化数据恢复时,并发恢复线程的个数
cluster.routing.allocation.node_initial_primaries_recoveries: 16
# 集群主机列表(如果是单机部署,只需要填写一个当前服务器IP,集群部署,有几个集群,就需要填写几个服务器IP)
discovery.seed_hosts: ["集群ip1", "集群ip2"]
# 允许跨域访问
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
# 安全配置
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: none
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

5.设置用户信息

bash 复制代码
# 创建用户组es
groupadd es
# 创建新用户es并指定用户组
useradd -g es es
# 更改文件夹权限
chown -R es:es /data/soft/es

6. 启用X-Pack验证,生成证书

切换到es用户:

bash 复制代码
cd /data/soft/es/elasticsearch-7.4.0/
bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass ""

重要: 证书保存路径为 /data/soft/es/elasticsearch-7.4.0/config,集群中所有节点的 elastic-certificates.p12 证书必须保持一致。在主节点上生成证书后,需要拷贝到次节点对应的路径下。
7. 启动Elasticsearch

切换到es用户:

后台启动:./elasticsearch -d
8.手动设置密码

在es用户下执行:

bash 复制代码
cd /data/soft/es/elasticsearch-7.4.0/bin
./elasticsearch-setup-passwords interactive

设置以下用户密码(示例密码均为:eom@123):

elastic

apm_system

kibana

logstash_system

beats_system

remote_monitoring_user
9.防火墙配置

bash 复制代码
# 查看防火墙状态
systemctl status firewalld.service
# 查询端口是否开放
firewall-cmd --query-port=19200/tcp
# 开放19200端口
firewall-cmd --zone=public --add-port=19200/tcp --permanent
# 移除端口
firewall-cmd --permanent --zone=public --remove-port=19200/tcp
# 重启防火墙
firewall-cmd --reload
# 查看开放的端口号
firewall-cmd --zone=public --list-ports

10.浏览器验证

访问服务器ip:es端口:输入账号密码访问

相关推荐
匆匆那年9677 小时前
llamafactory推理消除模型的随机性
linux·服务器·学习·ubuntu
好好学习天天向上~~7 小时前
5_Linux学习总结_vim
linux·学习·vim
Coder个人博客13 小时前
Linux6.19-ARM64 mm mmu子模块深入分析
大数据·linux·车载系统·系统架构·系统安全·鸿蒙系统
Doro再努力16 小时前
Vim 快速上手实操手册:从入门到生产环境实战
linux·编辑器·vim
wypywyp16 小时前
8. ubuntu 虚拟机 linux 服务器 TCP/IP 概念辨析
linux·服务器·ubuntu
Doro再努力16 小时前
【Linux操作系统10】Makefile深度解析:从依赖推导到有效编译
android·linux·运维·服务器·编辑器·vim
senijusene16 小时前
Linux软件编程:IO编程,标准IO(1)
linux·运维·服务器
忧郁的橙子.16 小时前
02-本地部署Ollama、Python
linux·运维·服务器
醇氧16 小时前
【linux】查看发行版信息
linux·运维·服务器
No8g攻城狮17 小时前
【Linux】Windows11 安装 WSL2 并运行 Ubuntu 22.04 详细操作步骤
linux·运维·ubuntu