在之前 ElasticSearch 搭建好之后,我们通过 elasticsearch-header 插件在查看 ES 服务的时候,发现 cluster-health 显示的是 YELLOW。

Why?

首先,我们需要知道的是:颜色代表集群的健康状态。现在的颜色状态有:

* RED(红): 代表具体的分片还没有在集群中分配好;
* YELLOW(黄): 代表主分片已经分配好,但是副本尚未分配;
* GREEN(绿):表示所有的分片都已分配好,群集正常运行;

有了以上的简介之后,笔者觉得,单节点导致显示的 YELLOW 还可以完善,所以开始搭建 ** ES Cluster **。

首先,我们需要更新之前的配置。进入之前的解压目录,打开配置文件:

vim elasticsearch.yml

我们需要更新这样几个参数:

  • node.name: 指定当前节点的名称。我现在有两台机子,可以设置两个节点,所以,这里一个起名为 master,一个为 node1;
  • node.master: 指定主节点。值一个设置为 true,另一个为 false;
  • discovery.zen.ping.unicast.hosts:这里设置的是节点的 ip,或者自己配置 hosts 文件,指定 ip映射关系,直接写ip对应的名称;
  • discovery.zen.minimum_master_nodes:这里,我的主节点是1个,所以我在这配置的是 1;具体的可以参考discovery.zen.minimum_master_nodes

在主节点配置好后,通过 scp 传输到 node1 节点上面,参数也做相应的改变即可。比如 node.name 更新成 node1, node.master: false。其他的保持一致。

我目前的主节点配置如下:

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
cluster.name: es-demo
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
node.name: master
node.master: true
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
path.data: /data/elasticsearch
#
# Path to log files:
#
#path.logs: /path/to/logs
path.logs: /data/logs/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.1.58 # 从节点成对应的 ip
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["192.168.1.58", "192.168.1.54"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 1
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true # --------------------------------- 其他配置 -----------------------------------
http.cors.enabled: true
http.cors.allow-origin: "*"

更新好配置之后呢,我们开始启动 ElasticSearch 服务。我启动 master 和 node1,发现出现了下面的错误:

max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]

查询发现,导致这种错误,是因为系统默认的 max_map_count 过低所致,我们需要设置大一点(按报错直接翻译也可知哦()。我们需要设置一下这个参数:

sudo vim /etc/sysctl.conf

在最末尾添加:

vm.max_map_count=262144

两台机子配置好之后,我们重新启动下 elasticsearch。这时候 log 也已经提示了:

Cluster health status changed from [YELLOW] to [GREEN] (reason: [shards started [[movies][0]] ...])

好了。刷新下 elasticsearch-head,发现如下图所示:

至此,集群环境算是配置好了,集群状态也从 YELLOW 转到 GREEN 了。

原文网址 http://www.cnblogs.com/scharfsinnig/p/6759630.html

参考:

discovery.zen.minimum_master_nodes 参数说明

vm_map_count 设置

ElasticSearch 5.2.2 集群环境的搭建的更多相关文章

  1. hadoop集群环境的搭建

    hadoop集群环境的搭建 今天终于把hadoop集群环境给搭建起来了,能够运行单词统计的示例程序了. 集群信息如下: 主机名 Hadoop角色 Hadoop jps命令结果 Hadoop用户 Had ...

  2. Nacos集群环境的搭建与配置

    Nacos集群环境的搭建与配置 集群搭建 一.环境: 服务器环境:CENTOS-7.4-64位 三台服务器IP:192.168.102.57:8848,192.168.102.59:8848,192. ...

  3. redis集群环境的搭建和错误分析

    redis集群环境的搭建和错误分析 redis集群时,出现的几个异常问题 09 redis集群的搭建 以及遇到的问题

  4. Linux下Hadoop2.7.3集群环境的搭建

    Linux下Hadoop2.7.3集群环境的搭建 本文旨在提供最基本的,可以用于在生产环境进行Hadoop.HDFS分布式环境的搭建,对自己是个总结和整理,也能方便新人学习使用. 基础环境 JDK的安 ...

  5. elasticsearch与mongodb分布式集群环境下数据同步

    1.ElasticSearch是什么 ElasticSearch 是一个基于Lucene构建的开源.分布式,RESTful搜索引擎.它的服务是为具有数据库和Web前端的应用程序提供附加的组件(即可搜索 ...

  6. zookeeper3台机器集群环境的搭建

    三台机器zookeeper的集群环境搭建 Zookeeper 集群搭建指的是 ZooKeeper 分布式模式安装. 通常由 2n+1台 servers 组成. 这是因为为了保证 Leader 选举(基 ...

  7. Elasticsearch 第九篇:集群配置与搭建

    h2.post_title { background-color: rgba(43, 102, 149, 1); color: rgba(255, 255, 255, 1); font-size: 1 ...

  8. Linux安装ElasticSearch与MongoDB分布式集群环境下数据同步

    ElasticSearch有一个叫做river的插件式模块,可以将外部数据源中的数据导入elasticsearch并在上面建立索引.River在集群上是单例模式的,它被自动分配到一个节点上,当这个节点 ...

  9. ElasticSearch 7.1.1 集群环境搭建

    1. 集群简介 三台机器,均用于保存数据且可被选为master节点 服务版本 服务 版本 elasticsearch 7.1.1 jdk 1.8 1. 创建elsearch用户 不建议直接使用root ...

随机推荐

  1. Nginx的日志管理

        vim /usr/local/nginx/conf/nginx.conf                                  #编辑 nginx 配置文件     server{ ...

  2. es6 学习1 let表示变量 、const表示常量 与 var 变量的区别

    一.let 1.看下代码,在函数中无论在哪里声明变量,都会自动提到函数顶部,这就是函数变量提升,它的作用于为当前函数中. function aa() { if(bool) { var test = ' ...

  3. Chrome发布73 beta版:增强Linux用户体验

    Google开发者周五推动Chrome 73进入他们的测试频道,因为他们准备在3月12日左右推出这款网页浏览器更新,以便稳定推出.除非另有说明,否则下面描述的更改适用于Android,Chrome O ...

  4. [BJOI2018]求和(树链剖分)

    题目描述 master 对树上的求和非常感兴趣.他生成了一棵有根树,并且希望多次询问这棵树上一段路径上所有节点深度的 kkk 次方和,而且每次的 kkk 可能是不同的.此处节点深度的定义是这个节点到根 ...

  5. 题解 P2910 【[USACO08OPEN]寻宝之路Clear And Present Danger】

    说起来这还是本蒟蒻学完Floyd之后做的第一道题. emm...这是一道裸题,题目大致是说有一堆岛,岛之间有海盗,因此每一条边都有一个危险指数(权重),然后给出一段必须经过的路线,求从一号小岛走到N号 ...

  6. 题解 UVA10328 【Coin Toss】

    这道题目其实就是说有N张纸牌,问至少连续K张正面朝上的可能性是多少. 可以用递推做.首先我们将题目所求从 至少K张 转化为 总数 - 至多K张 (为什么要这样自己想) 设F[i][j]为前i个纸牌至多 ...

  7. ArcGIS api for javascript——地理处理任务-服务区域任务

    描述 本例展示了如何发送一些输入值到ArcGIS Server上的GIS模型并获得结果反馈给web应用.本例中,模型计算自在地图上单击点起始的驱动时间多边形. 例如,这个分析类型可用于想要知道多少人生 ...

  8. oracle之ROWNUM的查询应用

    1 在ORACLE数据库中,ROWNUM是ORACLE数据库为查询结果加入的一个伪列.起始值为1.经常使用来处理查询结果的分页. 2 因为ROWNUM的特殊性,使用时候一般是分三层: 第一层:先进行查 ...

  9. 使用maven运行单元測试总结

    maven本身没有单元測试框架,可是maven的default生命周期的test阶段绑定了maven-surefire-plugin插件,该插件能够调用Junit3.Junit4.TestNG等Jav ...

  10. JS学习十七天----工厂方法模式

    工厂方法模式 前言 今天自己看了一下自己写的部分博客,发现写的好丑....開始注意自己的排版!!可是偏亮也不是一朝一夕就完毕的,我尽量让它美丽一点.....每天美丽一点点 正文 工厂方法模式是一种实现 ...