news 2026/4/15 15:32:51

Linux软件安装 —— Elasticsearch集群安装(带密码验证)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Linux软件安装 —— Elasticsearch集群安装(带密码验证)

文章目录

  • 一、节点说明
  • 二、JDK安装
  • 三、Elasticsearch安装
      • 1、软件下载
      • 2、基础环境准备(三节点)
      • 3、修改配置
      • 4、启动集群
      • 5、修改密码
      • 6、远程连接

一、节点说明

IP主机名
192.168.10.102node02
192.168.10.103node03
192.168.10.104node04

二、JDK安装

参考本人此篇文章:Linux软件安装 —— JDK安装


三、Elasticsearch安装

1、软件下载

官网地址:https://www.elastic.co/cn/downloads/past-releases?product=elasticsearch

本文使用:elasticsearch-7.10.0-linux-x86_64.tar.gz

2、基础环境准备(三节点)

(1)修改系统文件

# 修改limits.confvim/etc/security/limits.conf * soft nofile65536* hard nofile65536* soft memlock unlimited * hard memlock unlimited# 修改sysctl.confvim/etc/sysctl.conf vm.max_map_count=262144sysctl -p

(2)上传并解压

# 解压tar-zxvf elasticsearch-7.10.0-linux-x86_64.tar.gz -C /opt/module/# 重命名mvelasticsearch-7.10.0/ elasticsearch

(3)创建elastic用户

# 创建用户useraddelastic# 修改密码passwdelastic# 修改所属者chown-R elastic:elastic elasticsearch# 切换elastic用户su- elastic

3、修改配置

(1)node02

vimelasticsearch.yml# clustercluster.name: my_elastic cluster.routing.allocation.cluster_concurrent_rebalance:16cluster.routing.allocation.node_concurrent_recoveries:16cluster.routing.allocation.node_initial_primaries_recoveries:16# nodenode.name: node02 node.master:truenode.data:true# Pathspath.data: /opt/module/elasticsearch/data path.logs: /opt/module/elasticsearch/logs# Networknetwork.host:0.0.0.0 network.publish_host: node02 http.port:9200transport.port:9300network.tcp.keep_alive:truenetwork.tcp.no_delay:truetransport.tcp.compress:true###### 允许es-head连接 ######http.cors.allow-origin:"*"http.cors.enabled:truehttp.max_content_length: 200mb# Discoverydiscovery.seed_hosts:["node02:9300","node03:9300","node04:9300"]cluster.initial_master_nodes:["node02","node03","node04"]# gatewaygateway.recover_after_nodes:2#################### xpack密码配置 ####################xpack.security.enabled:truexpack.security.transport.ssl.enabled:truexpack.security.transport.ssl.verification_mode: certificate xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

(2)node03

# node03在node02的基础上修改以下内容node.name: node03 network.publish_host: node03

(3)node04

# node04在node02的基础上修改以下内容node.name: node03 network.publish_host: node03

(4)修改JVM资源

vimjvm.options -Xms8g -Xmx8g

基本原则
不超过物理内存的50%:为操作系统和文件系统缓存预留空间
最大不超过32GB:避免使用压缩指针带来的性能损失
最小和最大设置为相同值:避免堆大小调整的开销

(5)生成TLS和身份验证

# 同一个集群身份验证信息得一样/opt/module/elasticsearch# 给个初始空密码,一会儿修改bin/elasticsearch-certutil cert -out config/elastic-certificates.p12 -pass""# 将生成的认证信息分发到其他节点scpconfig/elastic-certificates.p12 elastic@node03:/opt/module/elasticsearch/config/scpconfig/elastic-certificates.p12 elastic@node04:/opt/module/elasticsearch/config/

4、启动集群

(1)启动

# 三节点执行bin/elasticsearch -d# 验证集群状态curl-X GET"node02:9200/_cluster/health?pretty"# 出现报错是正常现象,因为还没设密码,说明集群启动成功

5、修改密码

# 单节点执行bin/elasticsearch-setup-passwords interactive# 需要设置elastic,apm_system,kibana_system,logstash_system,beats_system,remote_monitoring_user等账号密码,自行设置复杂密码,本文统一设置elasticelastic:elastic apm_system:elastic kibana_system:elastic logstash_system:elastic beats_system:elastic remote_monitoring_user:elastic# 验证集群状态curl-u elastic:elastic -X GET"http://node02:9200/_cluster/health?pretty"curl-u elastic:elastic -XGET"http://node02:9200/_cat/indices/.security-*?v&s=index&pretty"

6、远程连接

此处使用浏览器的Elasticsearch-head插件

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/14 6:30:18

基于SpringBoot的扶贫助农系统毕业设计

博主介绍:✌ 专注于Java,python,✌关注✌私信我✌具体的问题,我会尽力帮助你。 一、研究目的 本研究旨在设计并实现一个基于SpringBoot框架的扶贫助农系统,以解决我国农村地区扶贫工作面临的实际问题。具体研究目的如下: 首先&a…

作者头像 李华
网站建设 2026/4/13 20:03:05

基于SpringBoot的车辆违章信息管理系统毕设源码

博主介绍:✌ 专注于Java,python,✌关注✌私信我✌具体的问题,我会尽力帮助你。 一、研究目的 本研究旨在设计并实现一个基于SpringBoot框架的车辆违章信息管理系统,以满足现代交通管理对于高效、便捷、智能化的需求。具体研究目的如下&…

作者头像 李华
网站建设 2026/4/8 14:30:09

强烈安利专科生必用TOP10 AI论文写作软件测评

强烈安利专科生必用TOP10 AI论文写作软件测评 2026年专科生必备AI论文写作工具测评解析 随着AI技术在教育领域的深入应用,越来越多的专科生开始借助AI工具提升论文写作效率。然而,面对市场上琳琅满目的AI写作软件,如何选择真正适合自己需求…

作者头像 李华
网站建设 2026/4/13 10:37:24

MiniCPM4-0.5B-QAT-Int4-GPTQ-format 小显存llm

MiniCPM4-0.5B-QAT-Int4-GPTQ-format 模型库 from modelscope import AutoTokenizer from vllm import LLM, SamplingParamsmodel_name "OpenBMB/MiniCPM4-0.5B-QAT-Int4-GPTQ-format" prompt [{"role": "user", "content": "…

作者头像 李华
网站建设 2026/3/25 9:03:26

【计算机毕业设计案例】基于springboot的房产交易系统基于springboot的房地产销售管理系统(程序+文档+讲解+定制)

博主介绍:✌️码农一枚 ,专注于大学生项目实战开发、讲解和毕业🚢文撰写修改等。全栈领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java、小程序技术领域和毕业项目实战 ✌️技术范围:&am…

作者头像 李华