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. 切换用户,启动即可
相关推荐
冰橙子id4 小时前
linux-远程访问管理(sshd,scp,sftp)
linux·网络·ssh
光电的一只菜鸡5 小时前
ubuntu之坑(十五)——设备树
linux·数据库·ubuntu
深圳卢先生7 小时前
CentOS 安装jenkins笔记
笔记·centos·jenkins
saynaihe7 小时前
ubuntu 22.04 anaconda comfyui安装
linux·运维·服务器·ubuntu
企鹅与蟒蛇7 小时前
Ubuntu-25.04 Wayland桌面环境安装Anaconda3之后无法启动anaconda-navigator问题解决
linux·运维·python·ubuntu·anaconda
程序设计实验室8 小时前
小心误关了NAS服务器!修改Linux的电源键功能
linux·nas
G_whang8 小时前
jenkins使用Jenkinsfile部署springboot+docker项目
spring boot·docker·jenkins
liupenglove9 小时前
自动驾驶数据仓库:时间片合并算法。
大数据·数据仓库·算法·elasticsearch·自动驾驶
野生技术架构师10 小时前
MySQL数据实时同步到Elasticsearch的高效解决方案
数据库·mysql·elasticsearch
渡我白衣10 小时前
Linux操作系统之信号:信号的产生
linux