中间件: ElasticSearch的安装与部署

文档地址:
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

单机部署

创建用户:

shell 复制代码
useradd es
chown -R es /opt/soft/
mkdir -p /var/log/elastic
chown -R es /var/log/elastic
mkdir -p /tmp/elastic
chown -R es /tmp/elastic

系统参数配置:

shell 复制代码
echo "vm.max_map_count = 262144" >> /etc/sysctl.conf
sysctl -p

echo "* soft nofile 65536
* hard nofile 65536" >> /etc/security/limits.conf 

方式一:YUM安装

shell 复制代码
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
echo "[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md" >> /etc/yum.repos.d/elasticsearch.repo

yum install -y --enablerepo=elasticsearch elasticsearch

方式二:

shell 复制代码
cd /opt/soft/archive
wget https://mirrors.huaweicloud.com/elasticsearch/7.15.1/elasticsearch-7.15.1-linux-x86_64.tar.gz
tar -zxf elasticsearch-7.15.1-linux-x86_64.tar.gz -C ../

echo 'cluster.name: my-application
node.name: node-1
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["127.0.0.1"]
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true' >> /opt/soft/elasticsearch-7.15.1/config/elasticsearch.yml

配置

shell 复制代码
echo 'cluster.name: my-application
node.name: node-1
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["127.0.0.1"]
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true' >> /etc/elasticsearch/elasticsearch.yml
systemctl daemon-reload

启动

shell 复制代码
systemctl start elasticsearch

集群部署

shell 复制代码
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12

(1)修改配置elasticsearch.yml:

  • cluster.name # 一个集群内cluster name 需要相同
  • node.name # 各个节点node name 唯一
  • discovery.seed_hosts #
  • network.host
  • node.master # 主节点
  • node.data # 数据节点

(2)生成CA证书:

bin/elasticsearch-certutil ca

使用第一步生成的证书,生成p12密钥:

bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12

然后将证书复制到其余节点。

(3)然后启动所有节点,然后在主节点生成密码:

bin/elasticsearch-setup-password auto

查看集群状态:

shell 复制代码
curl -XGET 'http://<elasticsearch_host>:<elasticsearch_port>/_cluster/health?pretty=true'
相关推荐
悠悠1213812 小时前
Jenkins + Ansible 集成实战:把配置管理焊进流水线里
运维·ansible·jenkins
Elastic 中国社区官方博客14 小时前
在 Elasticsearch 中,存储向量查询速度最高提升 3 倍
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索
北风toto14 小时前
Jenkins新手入门安装插件全报错
java·运维·jenkins
海兰14 小时前
从原始日志到系统知识:补齐 AI 可观测性的“上下文层“
人工智能·elasticsearch
逆境不可逃16 小时前
【与我学 ClaudeCode】规划与协调篇 之 Skills:按需加载的领域知识框架
大数据·人工智能·elasticsearch·搜索引擎·agent·claudecode
奋斗的老史16 小时前
LangChain4j + Elasticsearch 实现企业级向量存储(支持混合检索、元数据过滤)
elasticsearch·langchain4j
做个文艺程序员17 小时前
第02篇:搭建 ES 集群 + Spring Boot 整合实战——从 Docker Compose 到 Java 客户端全覆盖
java·spring boot·elasticsearch
逸Y 仙X18 小时前
文章二:Elasticsearch跨集群能力探查
java·大数据·服务器·elasticsearch·搜索引擎·全文检索
海兰18 小时前
使用 ES|QL 调试 LLM 延迟、成本与 GPU 饱和度
大数据·elasticsearch·jenkins
Elastic 中国社区官方博客18 小时前
用于调试 LLM 延迟、成本和 GPU 饱和度的 ES|QL 查询
大数据·人工智能·elasticsearch·搜索引擎·ai·云原生·serverless