九、Linux二进制安装ElasticSearch集群

目录

  • 九、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.mfbz.cn/a/786734.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

语义言语流畅性的功能连接和有效连接

摘要 语义言语流畅性(SVF)受损在多种神经系统疾病中都存在。虽然已经报道了SVF相关区域的激活情况,但这些区域如何相互连接以及它们在脑网络中的功能作用仍存在分歧。本研究使用功能磁共振成像评估了健康被试SVF静态和动态功能连接(FC)以及有效连接。观察到额下回(…

js替换对象内部的对象名称或属性名称-(第一篇)

方案一:对于值为undefined null 的对象属性不考虑该方案 JSON.parse(JSON.stringify(data).replace(/name/g, new_name)) //data为数组,name为修改前,new_name为修改后 解释:1)JSON.stringify()把json对象转成json字…

3GPP R18 Multi-USIM 是怎么回事?(三)

这篇内容相对来说都是一些死规定,比较枯燥。主要是与MUSIM feature相关的mobility and periodic registration和service request触发过程的一些规定,两部分的内容是有部分重叠的,为保证完整性,重复部分也从24.501中摘了出来。 24.501 4.25 网络和MUSIM UE可以支持MUSIM fe…

绩效管理为什么难?

几乎所有企业都知晓绩效管理的重要性,但许多企业陷入了把绩效考核当绩效管理的误区。绩效考核只是绩效管理过程中的一个环节,如果只重视“考核”这个环节,会极大限制员工个人和组织的成长。 绩效管理是一个动态过程,包括绩效目标设…

数据结构 Java DS——链表部分经典题目 (1)

前言 笔者计划在暑假啃完JavaDS,Mysql的内容当然也会继续更 这次给读者们分享的是链表的几个比较典型的题目,关于如何手搓一个链表,笔者还在筹划中, 毕竟链表的种类也有那么多,但是在下面的题目中,只有单向链表 题目一 : 反转链表 206. 反转链表 - 力扣(LeetCode…

【国潮】软件本土化探索

文章目录 一、国产-操作系统银河麒麟(Kylin)操作系统华为鸿蒙系统(HarmonyOS)统信UOS深度Deepin 二、国产-服务器华为鲲鹏:飞腾:海光:兆芯:龙芯:申威: 三、国…

Sui DeFi现状介绍

关于Sui Network Sui是基于第一原理重新设计和构建而成的L1公有链,旨在为创作者和开发者提供能够承载Web3中下一个十亿用户的开发平台。Sui上的应用基于Move智能合约语言,并具有水平可扩展性,让开发者能够快速且低成本支持广泛的应用开发。获…

京东速运|通过python查询快递单号API

本次讲解如何使用快递聚合供应商来实现查询京东速运快递物流轨迹,首先,我们需要准备的资源。 平台的密钥key:登录后在个人中心查看 测试接口的链接:在下方文档处查看 其中,KEY为用户后台我的api页面展示的API密钥, 代…

codesys多段直线电机跨电机控制

1. 电机描述 在X轴上有多段直线电机,如下图有9个,从X1到X9. 2.codesys程序结构 程序名称:Pou_two_motors 动作名称:ACT_move 把这个程序搞到任务配置里面 通过ethercat总线命名一下这些电机,方便调用。 3.程序内容 P…

AI转绘_animatediff-cli-prompt-travel

这个工具有两种主要模式:它可以直接通过提示创建视频,或者它可以对现有视频进行风格化。还有方法可以提高视频的分辨率。 正如工具名称所示,它的一个主要特点是"提示旅行"。这意味着你可以例如使用特定的提示用于前20帧&#xff0…

SAP PS学习笔记03 - 批量更改Project(CNMASS),批量创建Project(CNMASSCREATE)

上一章讲了网络(Network),活动(Activity),PS长文本, PS文书(凭证),里程碑(Milestone)的创建等相关知识。 SAP PS学习笔记02 - 网络&a…

产线级MES系统在装配行业的具体应用

在装配行业中,产线级MES系统能够帮助企业优化生产流程,提高产品质量,增强生产效率。以下是产线级MES系统在装配行业中的一些具体应用场景。 了解慧都产线级MES系统>> 产线级MES系统应用场景 1. 生产过程监控与管理 MES系统可以实时…

nvm安装报错(镜像问题)

一、问题报错 安装的时候如果跟着网上早些时候的配置,调整了setting文件,配置镜像的话,可能报这个错误。 这个是因为他没检索到后面的链接地址,因为镜像的地址新的已经更换了。使用这个吧: node_mirror: https://npm…

华为防火墙 拓扑搭建1

拓扑图 要求 1.DMZ区内的服务器,生产区仅能在办公时间内(9:00-18:00)可以访问,办公区设备全天可以访问 配置安全策略 设置办公时间 2.生产区不允许访问互联网,办公区和游客区允许访问互联网…

2024年全国青少年信息素养大赛图形化编程小高组复赛真题

2024年全国青少年信息素养大赛图形化编程小高组复赛真题 题目总数:6 总分数:100 编程题 第 1 题 问答题 请对变身鱼进行编程,变身鱼的初始状态已经设置,不需要进行修改, 1.当变身鱼大小大于300时&#xff0…

希喂、鲜朗和牧野奇迹主食冻干怎么样?第一次喂冻干哪款更好

我是个宠物医生,每天很长时间都在跟猫猫狗狗打交道,送到店里来的猫猫状态几乎是一眼就能看出来,肥胖、肝损伤真是现在大部分家养猫正面临的,靠送医治疗只能减缓无法根治,根本在于铲屎官的喂养方式。 从业这几年&#…

redis学习(007 实战:黑马点评:登录)

黑马程序员Redis入门到实战教程,深度透析redis底层原理redis分布式锁企业解决方案黑马点评实战项目 总时长 42:48:00 共175P 此文章包含第25p-第p34的内容 文章目录 短信登录功能session 共享问题 短信登录功能 接口编写 这里是Result的封装 过滤器在拦截器的外层…

uni-app三部曲之二: 封装http请求

1.引言 前面一篇文章写了使用Pinia进行全局状态管理。 这篇文章主要介绍一下封装http请求,发送数据请求到服务端进行数据的获取。 感谢: 1.yudao-mall-uniapp: 芋道商城,基于 Vue Uniapp 实现,支持分销、拼团、砍价、秒杀、优…

java项目总结数据库

1.什么是数据库 用于存储和管理数据的仓库 2.数据库的特点 1.持久化存储数据。确实数据库就是一个文件系统。 2.便于存储和管理数据 3.使用统一的方式操作数据库 --SQL 3.MqSql服务启动 4.登录和退出 这里的ip值IP地址 5.客户端与服务器关系 6.目录结构 7.SQL 1.什么是SQL&…

跟《经济学人》学英文:2024年6月29日这期 A new lab and a new paper reignite an old AI debate

A new lab and a new paper reignite an old AI debate Two duelling visions of the technological future 对技术未来的两个对立的愿景 reignite:美 [ˌriɪɡˈnaɪt] 重新点燃;重新激起 duel:美 [ˈduːəl] 决斗;对决&…