九、Linux二进制安装ElasticSearch集群

news2024/10/2 6:33:04

目录

  • 九、Linux二进制安装ElasticSearch集群
    • 1 下载
    • 2 安装前准备(单机,集群每台机器都需要配置)
    • 3 ElasticSearch单机(7.16.2)
    • 4 ElasticSearch集群(8.14.2)
      • 4.1 解压文件(先将下载文件放到/opt下)
      • 4.2 新增数据目录
      • 4.3 修改配置文件
      • 4.4 启动ES(三台机器都启动)
      • 4.5 ES集群设置密码
        • 4.5.1 主节点配置
        • 4.5.2 从节点配置
        • 4.5.3 修改配置文件
        • 4.5.4 启动 并设置密码
      • 4.6 设置https访问
    • 5 设置开机自启

九、Linux二进制安装ElasticSearch集群

1 下载

官方下载:官方下载
百度网盘:网盘下载
在这里插入图片描述

2 安装前准备(单机,集群每台机器都需要配置)

一、关闭防火墙
关闭
systemctl stop firewalld
永久关闭
systemctl disable firewalld.service
也可以开放需要的端口
firewall-cmd --zone=public --add-port=5601/tcp --permanent

二、安装必要环境
yum install -y gcc git wget vim ntp lsof
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel

三、修改系统配置文件
vim /etc/security/limits.conf

1、添加以下内容(带上*号)
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
 
2、继续修改另一个配置文件
vi /etc/sysctl.conf

3、添加以下内容
vm.swappiness=1
vm.max_map_count=655360

4、刷新配置文件
sysctl -p

修改时区(时区有问题时使用)
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

5、新增目录
mkdir /opt/elk

6、新建es用户
useradd esuser
passwd esuser 
输入重复密码: PassW0rd_1234

7、 为用户赋权限 
chown esuser:esuser -R /opt/elk

3 ElasticSearch单机(7.16.2)

之前写过一版单机版本:ElasticSearch单机安装

4 ElasticSearch集群(8.14.2)

4.1 解压文件(先将下载文件放到/opt下)

tar -zxvf /opt/elasticsearch-8.14.2-linux-x86_64.tar.gz -C /opt/elk

在这里插入图片描述

4.2 新增数据目录

mkdir /opt/elk/elasticsearch-8.14.2/data

4.3 修改配置文件

vi /opt/elk/elasticsearch-8.14.2/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: cluster-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# 集群中必须是唯一的
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /opt/elk/elasticsearch-8.14.2/data
#
# Path to log files:
#
path.logs: /opt/elk/elasticsearch-8.14.2/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:
#
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# 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]"]
#
discovery.seed_hosts: ["192.168.200.161", "192.168.200.162","192.168.200.163"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["192.168.200.161"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false
# 不设置密码
xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
xpack.security.http.ssl.enabled: false
http.cors.enabled: true
http.cors.allow-origin: "*"

4.4 启动ES(三台机器都启动)

启动前先确定esuser 有/opt/elk目录操作的权限
在这里插入图片描述
如果不是,就使用root用户重新执行一遍

chown esuser:esuser -R /opt/elk

切换用户

su esuser
/opt/elk/elasticsearch-8.14.2/bin/elasticsearch

开始启动会在这卡一会,稍等一下就行
在这里插入图片描述
在这里插入图片描述
启动成功后验证:
在这里插入图片描述

http://192.168.200.163:9200/_cluster/health?pretty

在这里插入图片描述

http://192.168.200.163:9200/_cat/nodes?v&pretty

在这里插入图片描述

4.5 ES集群设置密码

4.5.1 主节点配置
/opt/elk/elasticsearch-8.14.2/bin/elasticsearch-certutil ca

在这里插入图片描述
进入到es文件目录。可以看到生成的文件

cd /opt/elk/elasticsearch-8.14.2

在这里插入图片描述

/opt/elk/elasticsearch-8.14.2/bin/elasticsearch-certutil cert --ca /opt/elk/elasticsearch-8.14.2/elastic-stack-ca.p12 

会弹出三次提示,分别是输入密码,输出文件,输入密码,第一次密码是输入上一步设置的密码,也是123456,输出文件可以直接回车,默认就行。最后一次叫输入密码,什么都不要输入,直接回车就行,否则启动的时候会报错输入刚刚的密码,最后生成elastic-stack-ca.p12密码不要写,直接回车 不然会报错xpack Caused by: java.io.IOException: keystore password was incorrect

在这里插入图片描述
在这里插入图片描述
最后一共会有两个文件
在这里插入图片描述
移动文件到config目录

cd /opt/elk/elasticsearch-8.14.2
mv elastic-* config/

给文件复制权限(当前操作的用户是esuser,如果你的是root,请执行上面的赋权。切换到esuser进行操作)

chmod 777 /opt/elk/elasticsearch-8.14.2/config/elastic-certificates.p12 
chmod 777 /opt/elk/elasticsearch-8.14.2/config/elastic-stack-ca.p12  

创建keystore

/opt/elk/elasticsearch-8.14.2/bin/elasticsearch-keystore create

在这里插入图片描述

4.5.2 从节点配置

此时主节点有三个文件

cd /opt/elk/elasticsearch-8.14.2/config/

在这里插入图片描述
将这三个配置文件复制到其他从节点的/opt/elk/elasticsearch-8.14.2/config/下,
复制后会发现权限变成了root的。

su root
chown esuser:esuser -R /opt/elk
su esuser
chmod 777 /opt/elk/elasticsearch-8.14.2/config/elastic-certificates.p12 
chmod 777 /opt/elk/elasticsearch-8.14.2/config/elastic-stack-ca.p12  

4.5.3 修改配置文件
vi /opt/elk/elasticsearch-8.14.2/config/elasticsearch.yml

注意修改 node.name: node-1 就行

# ======================== 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: cluster-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /opt/elk/elasticsearch-8.14.2/data
#
# Path to log files:
#
path.logs: /opt/elk/elasticsearch-8.14.2/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:
#
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# 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]"]
#
discovery.seed_hosts: ["192.168.200.161", "192.168.200.162","192.168.200.163"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["192.168.200.161"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false
# ------------------------------------------------------------------------------------------------------
# 不设置密码
#xpack.security.enabled: false
#xpack.security.transport.ssl.enabled: false
#xpack.security.http.ssl.enabled: false
#http.cors.enabled: true
#http.cors.allow-origin: "*"
# ------------------------------------------------------------------------------------------------------
# 开启x-pack权限认证(三台服务器都添加如下内容并重启)
xpack.license.self_generated.type: basic
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
#开启密码认证
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: /opt/elk/elasticsearch-8.14.2/config/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /opt/elk/elasticsearch-8.14.2/config/elastic-certificates.p12

#配置https的,如果启动不了,可以先注释下面的配置,启动成功后,设置完密码后再打开这些配置重新启动
#xpack.security.http.ssl.enabled: true
#xpack.security.http.ssl.keystore.path: /opt/elk/elasticsearch-8.14.2/config/elastic-certificates.p12
#xpack.security.http.ssl.truststore.path: /opt/elk/elasticsearch-8.14.2/config/elastic-certificates.p12
4.5.4 启动 并设置密码

启动

/opt/elk/elasticsearch-8.14.2/bin/elasticsearch

启动完成后,浏览器登陆。发现没有密码。这时我们要去设置密码

http://192.168.200.161:9200/

在这里插入图片描述
打开主节点的服务器(这一步需要集群是正常运行的)

/opt/elk/elasticsearch-8.14.2/bin/elasticsearch-reset-password --username elastic --interactive

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4.6 设置https访问

vi /opt/elk/elasticsearch-8.14.2/config/elasticsearch.yml

集群配置的最后三行,注释给取消就行
在这里插入图片描述
重启es

https://192.168.200.161:9200/

在这里插入图片描述

5 设置开机自启

su root
vi  /etc/systemd/system/elasticsearch.service
systemctl daemon-reload
systemctl start elasticsearch.service

systemctl stop elasticsearch.service

systemctl enable elasticsearch.service

启动过程会有点慢,耐心等待一下

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

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

相关文章

Java系列-valitile

背景 volatile这个关键字可以说是面试过程中出现频率最高的一个知识点了,面试官的问题也是五花八门,各种刁钻的角度。之前也是简单背过几道八股文,什么可见性,防止指令重拍等,但面试官一句:volatile原理是什…

Vue基础--v-model/v-for/事件属性/侦听器

目录 一 v-model表单元素 1.1 v-model绑定文本域的value 1.1.1 lazy属性:光标离开再发请求 1.1.2 number属性:如果能转成number就会转成numer类型 1.1.3 trim属性:去文本域输入的前后空格 1.2v-model绑定单选checkbox 1.3代码展示 二 …

Python OpenCV 教学取得视频资讯

这篇教学会介绍使用OpenCV,取得影像的长宽尺寸、以及读取影像中某些像素的颜色数值。 因为程式中的OpenCV 会需要使用镜头或GPU,所以请使用本机环境( 参考:使用Python 虚拟环境) 或使用Anaconda Jupyter 进行实作( 参考:使用Anaco…

基于单片机的温湿度感应智能晾衣杆系统设计

[摘 要] 本设计拟开发一种湿度感应智能晾衣杆系统 , 此新型晾衣杆是以单片机为主控芯片 来控制的实时检测系统 . 该系统使用 DHT11 温湿度传感器来检测大气的温湿度 , 然后通过单 片机处理信息来控制 28BYJ &…

配置路由器支持Telnet操作 计网实验

实验要求: 假设某学校的网络管理员第一次在设备机房对路由器进行了初次配置后,他希望以后在办公室或出差时也可以对设备进行远程管理,现要在路由器上做适当配置,使他可以实现这一愿望。 本实验以一台R2624路由器为例,…

使用 Hugging Face 的 Transformers 库加载预训练模型遇到的问题

题意: Size mismatch for embed_out.weight: copying a param with shape torch.Size([0]) from checkpoint - Huggingface PyTorch 这个错误信息 "Size mismatch for embed_out.weight: copying a param with shape torch.Size([0]) from checkpoint - Hugg…

Redis管理禁用命令

在redis数据量比较大时,执行 keys * ,fluashdb 这些命令,会导致redis长时间阻塞,大量请求被阻塞,cpu飙升,严重可能导致redis宕机,数据库雪崩。所以一些命令在生产环境禁止使用。 Redis 禁用命令…

开始尝试从0写一个项目--前端(二)

修改请求路径的位置 将后续以及之前的所有请求全都放在同一个文件夹里面 定义axios全局拦截器 为了后端每次请求都需要向后端传递jwt令牌检验 ps:愁死了,翻阅各种资料,可算是搞定了,哭死~~ src\utils\request.js import axio…

【QML之·基础语法概述】

系列文章目录 文章目录 前言一、QML基础语法二、属性三、脚本四、核心元素类型4.1 元素可以分为视觉元素和非视觉元素。4.2 Item4.2.1 几何属性(Geometry):4.2.2 布局处理:4.2.3 键处理:4.2.4 变换4.2.5 视觉4.2.6 状态定义 4.3 Rectangle4.3.1 颜色 4.4…

互联网3.0时代的变革者:华贝甄选大模型创新之道

在当今竞争激烈的商业世界中,华贝甄选犹如一颗璀璨的明星,闪耀着独特的光芒。 华贝甄选始终将技术创新与研发视为发展的核心驱动力。拥有先进的研发团队和一流设施,积极探索人工智能、大数据、区块链等前沿技术,为用户提供高性能…

Knife4j的介绍与使用

目录 一、简单介绍1.1 简介1.2 主要特点和功能: 二、使用步骤:2.1 添加依赖:2.2 yml数据源配置2.3 创建knife4j配置类2.4 注解的作用 最后 一、简单介绍 1.1 简介 Knife4j 是一款基于Swagger的开源文档管理工具,主要用于生成和管…

【PTA天梯赛】L1-003 个位数统计(15分)

作者:指针不指南吗 专栏:算法刷题 🐾或许会很慢,但是不可以停下来🐾 文章目录 题目题解总结 题目 题目链接 题解 使用string把长度达1000位的数字存起来开一个代表个位数的数组 a[11]倒序计算最后一位,…

第16章 主成分分析:四个案例及课后习题

1.假设 x x x为 m m m 维随机变量,其均值为 μ \mu μ,协方差矩阵为 Σ \Sigma Σ。 考虑由 m m m维随机变量 x x x到 m m m维随机变量 y y y的线性变换 y i α i T x ∑ k 1 m α k i x k , i 1 , 2 , ⋯ , m y _ { i } \alpha _ { i } ^ { T } …

从微软 Word 中提取数据

从 Microsoft Word 文档中提取数据可以通过编程来实现,有几种常见的方法,其中之一是使用 Python 和 python-docx 库。python-docx 是一个处理 .docx 文件(Microsoft Word 文档)的 Python 库,可以读取和操作 Word 文档的…

泛微开发修炼之旅--36通过js控制明细表中同一列中多个浏览框的显示控制逻辑(明细表列中多字段显示逻辑控制)

文章链接:36通过js控制明细表中同一列中多个浏览框的显示控制逻辑(明细表列中多字段显示逻辑控制)

谷粒商城学习笔记-22-分布式组件-SpringCloud-OpenFeign测试远程调用

文章目录 一,OpenFeign的简介二,OpenFeign的使用步骤1,场景说明2,引入依赖2,开启OpenFeign3,编写Feign接口4,使用feign调用远程接口5,验证 错误记录 上一节学习了注册中心&#xff0…

变长输入神经网络设计

我对使用 PyTorch 可以轻松构建动态神经网络的想法很感兴趣,因此我决定尝试一下。 我脑海中的应用程序具有可变数量的相同类型的输入。对于可变数量的输入,已经使用了循环或递归神经网络。但是,这些结构在给定行的输入之间施加了一些顺序或层…

前端面试题31(TCP与UDP区别)

TCP (Transmission Control Protocol) 和 UDP (User Datagram Protocol) 是两种在网络通信中常用的传输层协议,它们在多个方面存在显著差异,主要体现在以下几个方面: 连接方式: TCP 是面向连接的协议。在数据传输开始之前&#xf…

STM32学习历程(day6)

EXTI外部中断使用教程 首先先看下EXTI的框图 看这个框图就能知道要先初始化GPIO外设 那么和前面一样 1、先RCC使能时钟 2、配置GPIO 选择端口为输入模式, 3、配置AFIO,选择我们用的GPIO连接到后面的EXTI 4、配置EXTI,选择边沿触发方式…

前端javascript中的排序算法之选择排序

选择排序(Selection Sort)基本思想: 是一种原址排序法; 将数组分为两个区间:左侧为已排序区间,右侧为未排序区间。每趟从未排序区间中选择一个值最小的元素,放到已排序区间的末尾,从…