ElasticSearch Window & Linux部署

文章目录

  • [一、Window 集群部署](#一、Window 集群部署)
  • [二、Linux 单节点部署](#二、Linux 单节点部署)
  • [三、Linux 集群部署](#三、Linux 集群部署)

一、Window 集群部署

  1. 创建 elasticsearch-cluster 文件夹,在内部复制三个elasticsearch服务

  2. 修改集群文件目录中每个节点的 config/elasticsearch.yml 配置文件

yaml 复制代码
# ---------------------------------- Cluster -----------------------------------
cluster.name: my-application
# ------------------------------------ Node ------------------------------------
node.name: node-1001
node.master: true
node.data: true
# ---------------------------------- Network -----------------------------------
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: localhost
http.port: 1001
transport.tcp.port: 9301
#查找master节点配置,启动成功后会去找主节点或其他节点
discovery.seed_hosts: ["localhost:9301"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
# ---------------------------------- Various -----------------------------------
http.cors.enabled: true
http.cors.allow-origin: "*"

查询集群状态
http://localhost:1001/_cluster/health

二、Linux 单节点部署

  1. 下载软件,解压
  2. 创建用户
    因安全问题,elasticsearch 不允许 root 用户直接运行,所以要创建新用户。
bash 复制代码
useradd es #新增 es 用户
passwd es #为es 用户设置密码
userdel -r es #如果错了,可以删除再加
chown -R es:es /opt/module/es #文件夹所有者
  1. 修改配置文件
    config/elasticsearch.yml
yaml 复制代码
# 集群名称
cluster.name: elasticsearch
#节点名称
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
#当前机器为主节点
cluster.initial_master_nodes: ["node-1"]

/etc/security/limits.conf

yaml 复制代码
#在文件末尾中增加下面内容
#每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536

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

yaml 复制代码
#在文件末尾中增加下面内容
#每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536

/etc/sysctl.conf

yaml 复制代码
#在文件末尾中增加下面内容
#一个进程可以拥有VMA(虚拟内存区域)的数量,默认值为65536
vm.max_map_count=65536
  1. 切换用户,启动即可

三、Linux 集群部署

  1. 下载软件,解压
    分发到其他服务器
  2. 创建用户
    因安全问题,elasticsearch 不允许 root 用户直接运行,所以要创建新用户。
bash 复制代码
useradd es #新增 es 用户
passwd es #为es 用户设置密码
userdel -r es #如果错了,可以删除再加
chown -R es:es /opt/module/es #文件夹所有者
  1. 修改配置文件
    config/elasticsearch.yml
yaml 复制代码
# 集群名称
cluster.name: elasticsearch-cluster
#节点名称
node.name: node-1

network.host: linux1
#是不是有资格主节点
node.master: true
node.data: true

http.port: 9200
#head 插件需要打开这两个配置
http.cors.enabled: true
http.cors.allow-origin: "*"
http.max_content_length: 200mb

#当前机器为主节点,初始化一个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["node-1"]
#节点发现
discovery.seed_hosts: ["linux1:9300","linux2:9300","linux3:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive : true
network.tcp.no_delay: true
transport.tcp.compress: true
#集群内同时启动的数据任务个数,默认是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

/etc/security/limits.conf

yaml 复制代码
#在文件末尾中增加下面内容
#每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536

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

yaml 复制代码
#在文件末尾中增加下面内容
#每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536

/etc/sysctl.conf

yaml 复制代码
#在文件末尾中增加下面内容
#一个进程可以拥有VMA(虚拟内存区域)的数量,默认值为65536
vm.max_map_count=65536
  1. 切换用户,启动即可
相关推荐
likfishdn20 分钟前
Linux的文件与目录管理
linux·运维·服务器
chian-ocean40 分钟前
Linux 文件缓冲区:高效数据访问的幕后推手
linux·运维·服务器
加油=^_^=42 分钟前
【Linux】进程优先级 | 进程调度(三)
linux·运维·服务器
吃汤圆的抹香鲸1 小时前
GoLand 安装包 绿色版 Win,Mac,Linux 包含IntelliJ全家桶 专为Go语言设计的集成开发环境(IDE)
linux·windows·macos·go·intellij-idea·go1.19
追寻光1 小时前
Cannot find a valid baseurl for repo: base/7/x86_64
linux
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
kngines1 小时前
【实战 ES】实战 Elasticsearch:快速上手与深度实践-1.3.1单节点安装(Docker与手动部署)
大数据·elasticsearch·docker
陆沙2 小时前
deepseek-r1-centos-本地服务器配置方法
linux·服务器·centos
吃汤圆的抹香鲸2 小时前
Rider 安装包 绿色版 Win/Mac/Linux 适合.NET和游戏开发者使用 2025全栈开发终极指南:从零配置到企业级实战
linux·运维·windows·sql·游戏·macos·.net
sz66cm2 小时前
Linux基础 -- ARM 32 位架构动态注入代码技术文档
linux·arm开发·架构