由于资源有限,使用是一台机器上安装三个elasticSearch服务端组成的集群。

1. 安装elasticSearch6.3.2

将原本安装的elasticSearch6.3.2复制两份,分别重新命名,如下:

2. 修改配置文件

进入elasticSearch的config目录,打开 elasticsearch.yml文件,修改如下信息:

  需要注意的是:

    默认所有节点都会存储数据。

    如果你是一台机器上多个es服务器,那么必须指定不同的tcp端口。

# ======================== 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: zskj
#
# ------------------------------------ Node ------------------------------------
# Use a descriptive name for the node:
# 节点名
node.name: node
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- 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):
# 节点的ip地址
network.host: 127.0.0.1
#
# Set a custom port for HTTP:
# 端口
http.port: 9200
# tcp端口。
transport.tcp.port: 9300
#
# 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]"]
# elasticSearch集群的地址。这里使用的是一台机器的不同端口。
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
# 预防脑裂,建议为总集群数一半 + 1
discovery.zen.minimum_master_nodes: 2
#
# 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: "*"

需要特别注意的是:

  1. 如果你的elasticSearch节点在 elasticsearch.yml中添加了中文之后,导致elasticSearch无法启动,就必须把yml文件中的中文删除,然后就可以重启启动了。报错信息如下:

  

  2. 配置文件书写的时候需要注意:属性必须定格写,之后是一个“:”,之后空格,然后是属性值。不能使用tab键。

3. 启动集群

分别启动三个elasticSearch节点即可启动集群。

4. 一个小的技巧

如果你也是和我一样,使用的是一台机器的三个elasticSearch服务端,每次都需要点到文件中,点击elasticsearch.bat,确实挺麻烦,那么你可以试试批处理。

右键创建一个文件,命名为xxxx.bat即可。使用记事本打开,然后写入如下命令,保存即可。

@echo off
title ES集群启动工具
REM 切换命令行目录为当前BAT所在目录
cd /d E:\ElasticSearch\elasticsearch-6.3.2\bin
start elasticsearch.bat echo elasticsearch1正在启动。。。
cd /d E:\ElasticSearch\elasticsearch-6.3.2_02\bin
start elasticsearch.bat echo elasticsearch2正在启动。。。
cd /d E:\ElasticSearch\elasticsearch-6.3.2_03\bin
start elasticsearch.bat echo elasticsearch3正在启动。。。

作用就是:分别自动切换到三个elasticSearch的目录,然后自动点击 elasticsearch.bat,启动服务端。

如果你还安装了head插件,每次点开启动也挺麻烦,可以直接在批处理后面添加语句即可:当elasticSearch服务端完全启动之后,点击任意键启动head插件

echo 任意键继续启动head插件
pause cd /d E:\ElasticSearch\head
call grunt server

综上:你只需要双击你的批处理工具 xxxx.bat就可以完成集群的启动了,如果你在多台服务器上,那么还是一个一个启动吧。

ElasticSearch(七):ElasticSearch集群的搭建的更多相关文章

  1. ElasticSearch高可用集群环境搭建和分片原理

    1.ES是如何实现分布式高并发全文检索 2.简单介绍ES分片Shards分片技术 3.为什么ES主分片对应的备分片不在同一台节点存放 4.索引的主分片定义好后为什么不能做修改 5.ES如何实现高可用容 ...

  2. hadoop(七) - hadoop集群环境搭建

    一. 前言: hadoop2.0已经公布了稳定版本号了,添加了非常多特性,比方HDFS HA.YARN等.最新的hadoop-2.4.1又添加了YARN HA 注意:apache提供的hadoop-2 ...

  3. ElasticSearch 集群环境搭建,安装ElasticSearch-head插件,安装错误解决

    ElasticSearch-5.3.1集群环境搭建,安装ElasticSearch-head插件,安装错误解决 说起来甚是惭愧,博主在写这篇文章的时候,还没有系统性的学习一下ES,只知道可以拿来做全文 ...

  4. 全文搜索引擎 Elasticsearch 入门:集群搭建

    本文主要介绍什么是 ElasticSearch 以及为什么需要它,如何在本机安装部署 ElasticSearch 实例,同时会演示安装 ElasticSearch 插件,以及如何在本地部署多实例集群, ...

  5. Elasticsearch(ES)集群的搭建

    1. 概述 Elasticsearch(ES)集群支持分片和副本,能够很容易的实现负载均衡.扩容.容灾.高可用. 今天我们就来聊一下,Elasticsearch(ES)集群是如何搭建的. 2. 场景介 ...

  6. Elasticsearch高级之-集群搭建,数据分片

    目录 Elasticsearch高级之-集群搭建,数据分片 一 广播方式 二 单播方式 三 选取主节点 四 什么是脑裂 五 错误识别 Elasticsearch高级之-集群搭建,数据分片 es使用两种 ...

  7. 原创 | 手摸手带您学会 Elasticsearch 单机、集群、插件安装(图文教程)

    欢迎关注笔者的公众号: 小哈学Java, 每日推送 Java 领域干货文章,关注即免费无套路附送 100G 海量学习.面试资源哟!! 个人网站: https://www.exception.site/ ...

  8. Elasticsearch系列---生产集群部署(上)

    概要 本篇开始介绍Elasticsearch生产集群的搭建及相关参数的配置. ES集群的硬件特性 我们从开始编程就接触过各种各样的组件,而每种功能的组件,对硬件要求的特性都不太相同,有的需要很强的CP ...

  9. 1.ElasticSearch系列之集群部署

    第一步:安装JDK JDK要求jdk1.8+,不安装也可以,ES自带JDK 第二步:系统配置 2.1 禁用交换区 sudo swapoff -a 2.2 开最大文件数的限制 编辑文件 /etc/sec ...

  10. 使用Spring Data ElasticSearch+Jsoup操作集群数据存储

    使用Spring Data ElasticSearch+Jsoup操作集群数据存储 1.使用Jsoup爬取京东商城的商品数据 1)获取商品名称.价格以及商品地址,并封装为一个Product对象,代码截 ...

随机推荐

  1. 基于Socket的Android手机视频实时传输

    首先,简单介绍一下原理.主要是在手机客户端 (Android)通过实现Camera.PreviewCallback接口,在其onPreviewFrame重载函数里面获取摄像头当前图像数据, 然后通过S ...

  2. Python -- Scrapy 框架简单介绍(Scrapy 安装及项目创建)

    Python -- Scrapy 框架简单介绍 最近在学习python 爬虫,先后了解学习urllib.urllib2.requests等,后来发现爬虫也有很多框架,而推荐学习最多就是Scrapy框架 ...

  3. 51 jquery 节点操作和 bootstrapt

    jquery 和 bootstrapt1.jquery each 函数 1.each 循环方式一: 可循环对象: var arr =["alex","deng" ...

  4. UVA-11490 Just Another Problem

    题目大意:一个由p*q个点组成的pxq点阵(构成一个矩形).从内层点中拿走两块正方形上的所有点,这两块正方形要边长相等,在位置上关于中线对称,并且还要使每一个正方形的上下左右剩余的点的层数相等.现在告 ...

  5. OC description和sel

    一.description方法 Description方法包括类方法和对象方法.(NSObject类所包含) (一)基本知识 -description(对象方法) 使用NSLog和@%输出某个对象时, ...

  6. Sql Server中集合的操作(并集、差集、交集)学习

    首先我们做一下测试数据 1.创建测试数据 --创建人员表1-- create table Person1 ( Uid ,) primary key, Name ) not null ) --创建人员表 ...

  7. angular封装jquery插件(组件)

    http://www.phloxblog.in/jquery-plugin-angular-js-directive-clean-html-approach/#.VaCWL9yUemJ

  8. storage路径问题

    1 概念总述 android开发中,关于存储路径,我们经常听到以下几个概念:内存.内部存储和外部存储,现在我们就来详细说说这三者区别与联系. 内存:英文中记为memory,即RAM 内部存储:英文记为 ...

  9. oracle_sql语句的大全

    # 建立数据库struts   CREATE DATABASE IF NOT EXISTS struts DEFAULT CHARACTER SET GBK; 1.登录:(管理员)conn sys/p ...

  10. python break continue跳过和跳出循环

    break 语句可以跳出 for 和 while 的循环体.continue语句被用来告诉Python跳过当前循环块中的剩余语句,然后继续进行下一轮循环.用break continue 写一个乘法表下 ...