elasticsearch 6.8.1 集群搭建(三台)

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: elasticsearch 6.8.1 集群搭建(三台)

下载安装包

wget https://mirrors.huaweicloud.com/elasticsearch/6.8.1/elasticsearch-6.8.1.tar.gz
# 将安装包分发到三台机器上,本文采用 ip1、ip2、ip3 的变量形式代表。
scp root@elasticsearch-6.8.1.tar.gz root@ip1:/opt/
# 解压
tar -xzf elasticsearch-6.8.1.tar.gz

# 解压后的目录
.
├── bin # 二进制脚本存放目录,包括 elasticsearch 来指定运行一个 node,包括 elasticsearch-plugin 来安装 plugins
├── config # 包含了 elasticsearch.yml 配置文件
├── data # 节点上分配的每个 index/分片 的数据文件
├── lib
├── LICENSE.txt
├── logs
├── modules
├── NOTICE.txt
├── plugins # 插键文件存放的位置
└── README.textile

配置

# es 不能使用 root 用户启动,新建一个 es 用户
useradd es 
passwd es
# 新建 es 数据和日志目录
mkdir -p /data/es/data
mkdir -p /data/es/logs
# 更改两个目录的权限
chown -R es:es /data/es

config/elasticsearch.yml 中添加以下配置

# 仅贴 ip1 的配置,ip2、ip3的配置不一样的地方会在后面注释写出
cluster.name: test-es
node.name: es1   # ip2:es2 ip3:es3
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["ip1:9300","ip2:9300","ip2:9300"]
path.data: /data/es/data  
path.logs: /data/es/logs
http.port: 9200
transport.tcp.port: 9300
discovery.zen.minimum_master_nodes: 2  
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

调整jvm参数(config/jvm.options)

#一般只需要修改jvm参数 Xms 和 Xmx 不能大于你物理机内存的 50%
-Xms2g 
-Xmx2g

启动 Elasticsearch

# 在elasticsearch 目录中
#测试启动
./bin/elasticsearch
# max virtual memory areas vm.max_map_count [65530] is too low, 如果报这个错
# 修改内核参数
vim /etc/sysctl.conf
`vm.max_map_count=262144`
sysctl -p
#作为守护进程运行 
./bin/elasticsearch -d -p pid

开启认证

#生成 CA 证书
bin/elasticsearch-certutil ca  # 生成一个elastic-stack-ca.p12 过程中会让输入密码 及 保存副本的提示

# 为每个节点生成证书和私钥
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 #产生 elastic-certificates.p12 过程中还会让输入密码 可以留空
#将上一步产生的文件放在每个节点的 config/certs 下也可以其他位置,待会配置文件中会填写该位置

# 为系统默认用户创建密码
# 创建 keystore 文件
./bin/elasticsearch-keystore create

# 创建密码 可以放到最后一步操作
./bin/elasticsearch-setup-passwords interactive

config/elasticsearch.yml 中添加以下配置

xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12 # 位置自定义 目前是相对路径
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12 # 位置自定义 目前是相对路径

重启 es 并验证

service

Description=es server 
After=network.target

[Service]
Type=simple
User=es
Group=es
LimitNOFILE=100000
LimitNPROC=100000
Environment=JAVA_HOME=/opt/jdk1.8.0_201
#PIDFile=/opt/elasticsearch-6.8.1/pid
ExecStart=/opt/elasticsearch-6.8.1/bin/elasticsearch  -p /opt/elasticsearch-6.8.1/pid
Restart=always
PrivateTmp=true

[Install]
WantedBy=multi-user.target
~                           
相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
21天前
|
存储 负载均衡 Java
Elasticsearch集群面试系列文章一
【9月更文挑战第9天】Elasticsearch(简称ES)是一种基于Lucene构建的分布式搜索和分析引擎,广泛用于全文搜索、结构化搜索、分析以及日志实时分析等场景。
63 7
|
2月前
|
存储 缓存 监控
|
2月前
|
存储 监控 负载均衡
检索服务elasticsearch集群(Cluster)
【8月更文挑战第23天】
56 3
|
27天前
|
存储 自然语言处理 关系型数据库
ElasticSearch基础3——聚合、补全、集群。黑马旅游检索高亮+自定义分词器+自动补全+前后端消息同步
聚合、补全、RabbitMQ消息同步、集群、脑裂问题、集群分布式存储、黑马旅游实现过滤和搜索补全功能
ElasticSearch基础3——聚合、补全、集群。黑马旅游检索高亮+自定义分词器+自动补全+前后端消息同步
|
2月前
|
存储 监控 负载均衡
Elasticsearch 集群副本
【8月更文挑战第24天】
51 13
|
2月前
|
存储 负载均衡 监控
Elasticsearch 集群分片
【8月更文挑战第24天】
65 12
|
1月前
|
JSON 监控 Java
Elasticsearch 入门:搭建高性能搜索集群
【9月更文第2天】Elasticsearch 是一个分布式的、RESTful 风格的搜索和分析引擎,基于 Apache Lucene 构建。它能够处理大量的数据,提供快速的搜索响应。本教程将指导你如何从零开始搭建一个基本的 Elasticsearch 集群,并演示如何进行简单的索引和查询操作。
89 3
|
2月前
|
存储 缓存 算法
Elasticsearch 集群节点间的通信
【8月更文挑战第25天】
41 6
|
2月前
|
存储 机器学习/深度学习 运维
Elasticsearch 集群节点的角色与职责
【8月更文挑战第25天】
56 6
|
2月前
|
存储 网络协议 搜索推荐