Elasticsearch集群搭建

目录

WIndow集群

Linux集群

单点部署

集群部署

ES优化

硬件选择

分片策略

推迟分片分配

路由选择

写入速度优化

批量数据提交

优化存储设备

合理使用合并

减少Refresh的次数

加大Flush设置

减少副本的数量

内存设置

重要配置


WIndow集群

创建elasticsearch-cluster文件夹,在内部复制三个elasticsearch服务

修改集群文件目录下每个节点的config/elasticsearch.yml配置文件

节点1的配置信息:

# 集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
# 节点名称,集群内要唯一
node.name: node-1001
# 当前节点是主节点也是数据节点
node.master: true
node.data: true
​
# 本机ip地址
network.host: loaclhost
# http端口
http.port: 9201
# tcp监听端口
transport.tcp.port: 9301
​
# 跨域配置
http.cors.enabled: true
http.cors.allow-orrigin: "*"
 

节点2的配置信息:

# 集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
# 节点名称,集群内要唯一
node.name: node-1002
# 当前节点是主节点也是数据节点
node.master: true
node.data: true
​
# 本机ip地址
network.host: loaclhost
# http端口
http.port: 9202
# tcp监听端口
transport.tcp.port: 9302
​
# 查找节点
discovery.seed.hosts: ["localhost:9301"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
​
# 跨域配置
http.cors.enabled: true
http.cors.allow-orrigin: "*"

节点3的配置信息:

# 集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
# 节点名称,集群内要唯一
node.name: node-1002
# 当前节点是主节点也是数据节点
node.master: true
node.data: true
​
# 本机ip地址
network.host: loaclhost
# http端口
http.port: 9202
# tcp监听端口
transport.tcp.port: 9303 
​
# 查找节点
discovery.seed.hosts: ["localhost:9301"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
​
# 跨域配置
http.cors.enabled: true
http.cors.allow-orrigin: "*"
 

Linux集群

单点部署

安装ES

下载软件解压

Elasticsearch 7.8.0 | Elastic

# 解压
tar -zxvf elasticsearch-7.8.0-linux-x84_64.tar.gz -C /opt/module
# 修名
mv elasticsearch-7.8.0 es

创建用户

因为安全问题,Elasticsearch不允许root用户直接运行,所以要创建新用户,在root用户中心创建新用户

# 新增es用户
useradd es
# 创建密码
passwd es
​
# 如果错了,可以删除再加
userdel -r es
# 文件夹所有者
chown -R es:es /opt/module/es

修改/opt/module/es/config/elasticsearch.yml文件

cluster.name: elasticsearch
node.name: node-1
network.host:0.0.0.0
http.port:9200
cluster.initial_master_nodes: ["node-1"]

修改/etc/security/limits.conf

# 在文件末尾中加入下面内容
# 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
# es是用户名

修改/etc/secutiry/limits.d/20-nproc.conf

# 在文件末尾中加入下面内容
# 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
# es是用户名
​
# 操作系统级别对每个用户创建的进程数的限制
* hard nproc 4096
# 注:* 代表Linux所有用户名称

修改/etc/sysctl.conf

# 在文件中增加下面内容
# 一个进程可以拥有的vma(虚拟内存区域)的数量,默认值为65536
vm.max_map_count=655360

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值