中间件: 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'
相关推荐
Thuni_soft1 小时前
华宇TAS应用中间件与瀚高股份两款产品完成兼容互认证
中间件
Elasticsearch3 小时前
使用 LangExtract 和 Elasticsearch
elasticsearch
蒋星熠4 小时前
中间件架构设计与实践:构建高性能分布式系统的核心基石
开发语言·数据库·分布式·python·中间件·性能优化·硬件工程
程序员TNT4 小时前
开源商城 Shoptnt 的搜索引擎之心:基于 Elasticsearch 的高性能商品搜索实现
elasticsearch·搜索引擎·开源
在未来等你8 小时前
Elasticsearch面试精讲 Day 13:索引生命周期管理ILM
大数据·分布式·elasticsearch·搜索引擎·面试
Elastic 中国社区官方博客10 小时前
Elasticsearch:智能搜索的 MCP
大数据·人工智能·elasticsearch·搜索引擎·全文检索
伍哥的传说15 小时前
Lodash-es 完整开发指南:ES模块化JavaScript工具库实战教程
大数据·javascript·elasticsearch·lodash-es·javascript工具库·es模块·按需导入
不会聊天真君64719 小时前
ES(springcloud笔记第五期)
笔记·elasticsearch·spring cloud
时空自由民.19 小时前
repo 学习教程
大数据·学习·elasticsearch
刘一说19 小时前
Elasticsearch HTTPS访问错误解决指南
大数据·elasticsearch·https