Linux 下 ElasticSearch 集群部署

news2024/9/21 0:33:40

目录

1. ElasticSearch下载

2. 环境准备

3. ElasticSearch部署

3.1 修改系统配置

3.2 开放端口

3.3 安装 ElasticSearch

4. 验证


本文将以三台服务器为例,介绍在 linux 系统下ElasticSearch的部署方式。

1. ElasticSearch下载

    下载地址:Past Releases of Elastic Stack Software | Elastic

    选择需要的介质下载,这里以 elasticsearch-7.17.3 为例

2. 环境准备

   部署 ElasticSearch 需要先部署JDK ,JDK部署可以参考Linux下JDK 安装-CSDN博客 。

3. ElasticSearch部署

注:以下操作三台机器均需要修改

3.1 修改系统配置

(1)编辑 limits.conf文件

         vi /etc/security/limits.conf

  加入以下内容:

* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096

* soft memlock unlimited
* hard memlock unlimited

(2)编辑 sysctl.conf 文件

         vi /etc/sysctl.conf

 加入以下内容

vm.max_map_count=262144
vm.swappiness=0

(3)配置立即生效

         sysctl –p

3.2 开放端口

ElasticSearch 默认需要开通节点 9200 和 9300 端口。

(1)查看防火墙状态

        systemctl status firewalld

(2)开放端口

       firewall-cmd --zone=public --add-port=9200/tcp --permanent  

       firewall-cmd --zone=public --add-port=9300/tcp --permanent

(3)防火墙重新加载配置

       firewall-cmd --reload  

(4) 查看防火墙所有开放的端口

       firewall-cmd --zone=public --list-ports

3.3 安装 ElasticSearch

(1) 创建用户

       adduser es

       passwd es

(2) 创建数据目录

       mkdir -p /data/elasticsearch/data

       mkdir -p /data/elasticsearch/logs

       chown es:es -R /data/

(3) 解压

       上传elasticsearch介质(elasticsearch-7.17.3-linux-x86_64.tar.gz)到 /opt 目录

       tar zxvf elasticsearch-7.17.3-linux-x86_64.tar.gz

(4) 目录授权给 es 用户

       chown es:es -R /opt/elasticsearch-7.17.3

(5) 修改配置文件

       vi /opt/elasticsearch-7.17.3/config/elasticsearch.yml

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#集群名
cluster.name: es 
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#节点名称,其余两个节点分别为node-2 和node-3
node.name: node-1
#
# Add custom attributes to the node:
#
# 指定该节点是否有资格被选举成为master节点,默认为true
node.master: true
# 允许该节点存储数据(默认开启)
node.data: true
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# 索引数据的存储路径
path.data: /data/elasticsearch/data
# Path to log files:
#
# 日志文件的存储路径
path.logs: /data/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#当前机器节点的IP地址
network.host: IP
#当前机器节点的IP地址
network.publish_host: IP
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#设置对外服务的http端口
http.port: 9200
# 设置节点间交互的tcp端口,默认为9300
transport.tcp.port: 9300
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#集群的所有机器节点的IP地址
discovery.seed_hosts: ["IP1","IP2","IP3"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features. 
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html


#通过配置大多数节点(符合主节点数/ 2 + 1)来防止分裂。
discovery.zen.minimum_master_nodes: 2

#设置为true锁住内存。因为内存交换到磁盘对服务器性能是致命的
bootstrap.memory_lock: true

(6) 配置 jvm.option

       vi /opt/elasticsearch-7.17.3/config/jvm.options

      配置ES占用物理内存大小

      -Xms10g

      -Xmx10g

     修正CVE-2021-44228漏洞

     -Dlog4j2.formatMsgNoLookups=true

(7)启动

       一定要切换到 es 用户

       su es

       cd /opt/elasticsearch-7.17.3

       bin/elasticsearch -d -p pid

4. 验证

(1) 验证启动

       jps 

出现如下内容说明已经启动 

(2) 验证集群状态

       查询集群所有节点及主节点信息

       curl -XGET 'http://IP:9200/_cat/nodes?pretty'

        查询集群状态信息

        集群状态:

       -green正常,表示集群一切正常。

       -yellow黄表示集群不可靠但可用,一般单节时候就是这个状态。

       -red红表示集群不可用,有故障

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1933408.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

vue 如何做一个动态的 BreadCrumb 组件,el-breadcrumb ElementUI

vue 如何做一个动态的 BreadCrumb 组件 el-breadcrumb ElementUI 一、ElementUI 中的 BreadCrumb 定义 elementUI 中的 Breadcrumb 组件是这样定义的 <template><el-breadcrumb separator"/"><el-breadcrumb-item :to"{ path: / }">主…

算法 —— LRU算法

算法 —— LRU算法 LRULRU算法的工作原理&#xff1a;实现方法&#xff1a;性能考虑&#xff1a; 模拟过程splice函数对于std::list和std::forward_list基本语法&#xff1a;功能描述&#xff1a; 示例&#xff1a;注意事项&#xff1a; 如果大家已经学习过了Cache的替换算法和…

《人性的弱点》

This book is called ‘How to Win Friends & Influence People’. [COPY] 卡耐基《人性的弱点》有什么干货么&#xff1f;

自学鸿蒙HarmonyOS的ArkTS语言<十>@BuilderParam装饰器

作用&#xff1a;当子组件多处使用时&#xff0c;给某处的子组件添加特定功能 一、初始化 1、只能被Builder装饰的方法初始化 2、使用所属自定义组件的builder方法初始化 3、使用父组件的builder方法初始化 - 把父组件的builder传过去&#xff0c;参数名和子组件的builderPar…

【信号频率估计】MVDR算法及MATLAB仿真

目录 一、MVDR算法1.1 简介1.2 原理1.3 特点1.3.1 优点1.3.2 缺点 二、算法应用实例2.1 信号的频率估计2.2 MATLAB仿真代码 三、参考文献 一、MVDR算法 1.1 简介 最小方差无失真响应&#xff08;Mininum Variance Distortionless Response&#xff0c;MVDR&#xff09;算法最…

AI初学者的利器——香橙派AIpro

目录 引言香橙派介绍公司简介&#xff08;来自官网&#xff09;香橙派AIpro介绍香橙派AIPro硬件规格参数开发板接口详情系统登陆与使用指示灯 AI运行实例AI CPU和control CPU的设置方法香橙派AIpro cpu知识查询AIcpu占用率与cpu类别设置 Juypter lab使用JuypterLab介绍JuypterL…

8款可以替代Axure的设计软件推荐

一个好的原型设计工具对于产品经理或者UI/UX设计师来说非常重要。一个好的原型设计软件可以帮助你快速构建一个还原度高、信息结构清晰的原型图&#xff0c;也可以大大降低工作中与同事的沟通成本&#xff0c;更高效地推进工作。 那么&#xff0c;什么是易于使用和免费的原型设…

C51语言及通用I/O口应用

4.1 C51的程序结构 4.2 C51的数据结构 4.3 C51与汇编的混合编程 4.4 C51仿真开发方法 4.5 通用I/O口的简单应用 4.6 通用I/O口的进阶应用 4.1.1 C51语言概述 C51语言是51单片机的一种高级编程语言&#xff0c;与低级语言的汇编语言相比&#xff0c;一方面具有结构化语…

Chapter12 屏幕后处理效果——Shader入门精要学习笔记

Chapter12 屏幕后处理效果 一、屏幕后处理概述以及基本脚本系统1.OnRenderImage 函数 —— 获取屏幕图像2.Graphics.Blit 函数 —— 使用特定的Shader处理3.在Unity中实现屏幕后处理的基本流程4.屏幕后处理基类 二、调整亮度、饱和度和对比度1.BrightnessSaturationAndContrast…

Postman安装使用教程(详解)

目录 一、Postman是什么 二、安装系统要求 三、下载Postman 四、注册和登录Postman 五、创建工作空间 六、创建请求 一、Postman是什么 在安装之前&#xff0c;让我们先来简单了解一下Postman。Postman是一个流行的API开发工具&#xff0c;它提供了友好的用户界面用于发送…

简单实用的企业舆情安全解决方案

前言&#xff1a;企业舆情安全重要吗&#xff1f;其实很重要&#xff0c;尤其面对负面新闻&#xff0c;主动处理和应对&#xff0c;可以掌握主动权&#xff0c;避免股价下跌等&#xff0c;那么如何做使用简单实用的企业舆情解决方案呢&#xff1f; 背景 好了&#xff0c;提取词…

python CMD命令行传参实现:argparse、click、fire

1、argparse 设置传入和默认参数&#xff0c;也可以通过–help参考具体设置参数 bool值 参考&#xff1a; https://docs.python.org/zh-cn/3/howto/argparse.html https://www.bilibili.com/video/BV1nb41157Zc expected one argumrnt 报错&#xff0c;传入坐标类型字符串…

MYSQL 四、mysql进阶 9(数据库的设计规范)

一、为什么需要数据库设计 二、范 式 2.1 范式简介 在关系型数据库中&#xff0c;关于数据表设计的基本原则、规则就称为范式。 可以理解为&#xff0c;一张数据表的设计结 构需要满足的某种设计标准的 级别 。要想设计一个结构合理的关系型数据库&#xff0c;必须满足一定的…

couldn‘t read native报错!Typora中使用Pandoc导出Word失败的解决方法

couldn‘t read native报错&#xff01;Typora中使用Pandoc导出Word失败的解决方法 一、问题描述 在Typora中使用Pandoc将markdown文件导出为word文件时&#xff0c;发生如下图所示错误: 在网上找了资料以后&#xff0c;发现是因为md文件里面有表格&#xff0c;如果把表格删掉…

【深度学习】PyTorch框架(4):初始网络、残差网络 和密集连接网络

1、引言 在本篇文章中&#xff0c;我们将深入探讨并实现一些现代卷积神经网络&#xff08;CNN&#xff09;架构的变体。近年来&#xff0c;学界提出了众多新颖的网络架构。其中一些最具影响力&#xff0c;并且至今仍然具有重要地位的架构包括&#xff1a;GoogleNet/Inception架…

linux搭建mysql主从复制(一主一从)

目录 0、环境部署 1、主服务器配置 1.1 修改mysql配置文件 1.2 重启mysql 1.3 为从服务器授权 1.4 查看二进制日志坐标 2、从服务器配置 2.1 修改mysql配置文件 2.2 重启mysql 2.3 配置主从同步 2.4 开启主从复制 3、验证主从复制 3.1 主服务器上创建test…

Stable Diffusion【美女写实模型】:亚洲女性写实大模型,皮肤细腻光滑!

今天介绍一款专注于亚洲女性写实的SDXL模型&#xff1a;XXMix_9realisticSDXL。该模型绘图质量相当出色&#xff1a;面部在真实感基础上增加了一些轻度的美颜效果&#xff1b;以及增强的光影特效方面效果&#xff1b;只需要简单提示语就可以画出典型的亚洲女孩风格高质量图像。…

通过vue3 + TypeScript + uniapp + uni-ui 实现下拉刷新和加载更多的功能

效果图: 核心代码: <script lang="ts" setup>import { ref, reactive } from vue;import api from @/request/api.jsimport empty from @/component/empty.vueimport { onLoad,onShow, onPullDownRefresh, onReachBottom } from @dcloudio/uni-applet form …

Gradio技术入门(一)

Gradio是一个开源的Python库&#xff0c;旨在让创建机器学习模型的应用界面变得简单快捷。 官网&#xff1a;格罗特 (gradio.app) 一、基本概述 1&#xff0c;技术概述 1. 定义与用途 Gradio通过Python生成一套HTML页面&#xff0c;其中编写好了大部分的组件&#xff0c;主…

《大数据基础》相关知识点及考点,例题

1.6大数据计算模式 1、MapReduce可以并行执行大规模数据处理任务&#xff0c;用于大规模数据集&#xff08;大于1TB&#xff09;的并行运算。MapReduce 极大地方便了分布式编程工作&#xff0c;它将复杂的、运行于大规模集群上的并行计算过程高度地抽象为两个函数一一Map和Redu…