elasticsearch6.x集群安装部署

es 集群部署

操作系统为centos7.6
集群规模:3

软件包准备

说明:jdk版本不能低于1.8,推荐使用openjdk

软件包版本下载地址
elasticsearch6.2.3https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.rpm
openjdk9.0.4https://download.java.net/java/GA/jdk9/9.0.4/binaries/openjdk-9.0.4_linux-x64_bin.tar.gz

部署步骤

三个节分别安装jdk和es服务

在三个节点上分别安装jdk和elasticsearch服务,并以单节点的形式启动服务,验证服务是否正常安装

  1. 解压jdk:
    tar -zxvf openjdk-9.0.4_linux-x64_bin.tar.gz
  2. 安装elasticsearch
    rpm -ivh elasticsearch-6.2.3.rpm
  3. 给elasticsearch指定JAVA_HOME
    vi /etc/sysconfig/elasticsearch
# Elasticsearch Java path
JAVA_HOME=/opt/jdk-9.0.4
  1. 修改elasticsearch的服务为开机自启动
    systemctl enable elasticsearch.service
  2. 启动elasticsearch服务
    systemctl start elasticsearch
  3. 验证es服务是否可用
curl http://localhost:9200
{
  "name" : "node-3",
  "cluster_name" : "my-application",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "6.2.3",
    "build_hash" : "c59ff00",
    "build_date" : "2018-03-13T10:06:29.741383Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}
  1. 如果es服务启动失败,请到/var/log/elasticsearch/var/log/messages下查看错误信息
独立的3个es节点组成集群

到此3个节点的es只是单独存在的,还没有形成一个集群,需要调整配置使其形成集群

  1. 修改/etc/elasticsearch/elasticsearch.yml的相关参数
参数说明
cluster.name三个节点的cluster.name参数必须保持一致
node.name每个节点的node.name必须唯一
network.host本节点bind的ip
discovery.zen.ping.unicast.hosts三个节点的ip数组,用于es集群节点的自动发现
discovery.zen.minimum_master_nodesTo avoid a split brain, this setting should be set to a quorum of master-eligible nodes:
(master_eligible_nodes / 2) + 1

举例:

# Use a descriptive name for your cluster:
cluster.name: my-application
# Use a descriptive name for the node:
node.name: node-3
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: 10.0.44.47
# The default list of hosts is ["127.0.0.1", "[::1]"]
discovery.zen.ping.unicast.hosts: ["10.0.44.45", "10.0.44.46","10.0.44.47"]
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
discovery.zen.minimum_master_nodes: 2
  1. 修改jvm参数/etc/elasticsearch/jvm.options
    建议-Xms -Xmx修改值为物理内存的50%,比如虚机内存是4G,则-Xms -Xmx参数值设置成2G
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms2g
-Xmx2g
  1. 其他重要参数修改
    • 数据目录配置path.data,rpm安装完默认值是/var/lib/elasticsearch,建议设置独立的数据盘,并把该参数改完数据盘的目录

操作系统参数设置

  • 关闭swap
    • 执行命令:swapoff -a
    • 释掉/etc/fstab包含swap相关的行
    • 执行命令sysctl vm.swappiness=1
    • /etc/sysctl.conf 文件里添加vm.swappiness=1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yiqian1989

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值