1.准备

1.1.组件

  JDK:1.8版本及以上;

  ElasticSearch:6.2.4版本;

1.2.服务器

  3台服务器

2.安装

2.1.下载解压

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4-linux-x86_64.tar.gz
mkdir /opt/elk/elasticsearch-6.2.
tar zxvf elasticsearch-6.2..tar.gz -C /opt/elk/elasticsearch-6.2.

  

2.2.配置

cd /opt/elk/elasticsearch-6.2./config
vi elasticsearch.yml

标红的需要我们重点关注的,也是平常修改最多的参数:

# ======================== 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: log-es-cluster  #集群名称
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-100  #节点名称
node.master: true   #是否master
node.data: true     #是否数据节点
#
# 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: false  #默认为true,值改为false
#
# 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: 10.0.101.100  #本机服务器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: ["10.0.101.100", "10.0.101.101", "10.0.101.102"]  #集群服务器IP
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / + ):
#
discovery.zen.minimum_master_nodes: 3  #集群节点数
#
# 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:
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#增加以下属性,3台服务器一样
bootstrap.system_call_filter: false
transport.tcp.port:
transport.tcp.compress: true
http.cors.enabled: true
http.cors.allow-origin: "*"

2.3.同步

将安装配置好的组件包,用以下命令同步到另外2台服务器:

scp -r /opt/elk/elasticsearch-6.2.4/ root@172.16.10.92:/opt/elk/elasticsearch-6.2.4/
scp -r /opt/elk/elasticsearch-6.2.4/ root@172.16.10.93:/opt/elk/elasticsearch-6.2.4/

在另外2台服务器上修改elasticsearch.yml文件的以下2个属性值,其它的3台服务器一样:

node.name: node-
network.host: 10.0.101.101

2.4.创建用户

由于elasticsearch不能使用root账户启动,用以下命令需要新建一个用户:

#创建用户
useradd elk #设置密码
passwd elk #用户授权
chown -R elk:elk /opt/elk/elasticsearch-6.2.4
chmod 777 /opt/elk/elasticsearch-6.2.4 #切换用户
su elk

2.5.修改Linux配置(root用户下)

  • limits.conf
vim /etc/security/limits.conf

增加以下属性:

* soft nofile
* hard nofile
* soft nproc
* hard nproc
#锁住swapping因此需要在这个配置文件下再增加两行代码
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
  • 90-nproc.conf
vim /etc/security/limits.d/-nproc.conf

  • sysctl.conf
vim /etc/sysctl.conf

增加以下属性:

vm.max_map_count=
fs.file-max=

注意:修改之后需要执行一句命令sysctl -p使系统配置生效(使用root用户)

2.6.启动

切换为elk用户,输入以下命令启动:

su elk
cd /opt/elk/elasticsearch-6.2./bin
./elasticsearch
  • 第1台启动成功,没有报错,提示以下信息属于正常现像,因为另外2台服务器还没有启动:

  • 第2台启动成功,情况跟第1台一样:

  • 第3台启动成功

3.验证

  • 在其中一台服务器上,输入以下命令,IP要改成相应环境的:
curl '10.0.101.100:9200/_cluster/health?pretty'

  • 输入以下命令,检查master节点是否成功创建:
curl '10.0.101.100:9200/_cat/master?v'

ElasticSearch——集群搭建的更多相关文章

  1. elasticsearch集群搭建实例

    elasticsearch集群搭建实例 下个月又开始搞搜索了,几个月没动这块还好没有落下. 晚上在自己虚拟机上搭建了一个简易搜索集群,分享一下. 操作系统环境: Red Hat 4.8.2-16 el ...

  2. 和我一起打造个简单搜索之ElasticSearch集群搭建

    我们所常见的电商搜索如京东,搜索页面都会提供各种各样的筛选条件,比如品牌.尺寸.适用季节.价格区间等,同时提供排序,比如价格排序,信誉排序,销量排序等,方便了用户去找到自己心里理想的商品. 站内搜索对 ...

  3. Elasticsearch集群搭建及使用Java客户端对数据存储和查询

    本次博文发两块,前部分是怎样搭建一个Elastic集群,后半部分是基于Java对数据进行写入和聚合统计. 一.Elastic集群搭建 1. 环境准备. 该集群环境基于VMware虚拟机.CentOS ...

  4. ElasticStack之Elasticsearch集群搭建

    需搭建服务器环境 操作系统 Host:port node 1 CentOS 7.2.1511 11.1.11.127:9200 node1 2 CentOS 7.2.1511 11.1.11.128: ...

  5. CentOS 7下ElasticSearch集群搭建案例

    最近在网上看到很多ElasticSearch集群的搭建方法,本人在这人使用Elasticsearch5.0.1版本,介绍如何搭建ElasticSearch集群并安装head插件和其他插件安装方法. 一 ...

  6. Es学习第十课,ElasticSearch集群搭建

    前面几课我们已经把ES的基本概念和查询了解了,大家知道ES的核心优势就是天生支持分布式,所以,这课我们专门讲讲怎么搭建实现ES的集群部署. ES分布式原理 1.es分布式概念 主分片(Primary ...

  7. Elasticsearch集群搭建

    现有两部机器:192.168.31.86,192.168.31.87   参考以往博文对Elasticsearch进行配置完成:http://www.cnblogs.com/zhongshengzhe ...

  8. elasticsearch 集群搭建及启动常见错误

    1.系统环境 三台服务器(最好是单数台,跟master选举方式有关),确保机器互相ping的通,且都需要装了jdk 8环境,机器IP和 elasticsearch 的节点名称如下: cluster n ...

  9. Elasticsearch集群搭建教程及生产环境配置

    Elasticsearch 是一个极其强大的搜索和分析引擎,其强大的部分在于能够对其进行扩展以获得更好的性能和稳定性. 本教程将提供有关如何设置 Elasticsearch 集群的一些信息,并将添加一 ...

  10. elasticsearch集群搭建报错: not enough master nodes discovered during pinging

    自己用一台 阿里云 服务器 搭建ES集群的时候,总是报上面的问题. 而且两个ES服务都是报同样的问题.自己的配置文件如下: es服务1配置文件 cluster.name: elasticsearch ...

随机推荐

  1. 用js刷剑指offer(替换空格)

    题目描述 请实现一个函数,将一个字符串中的每个空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 牛客网链接 js代码 func ...

  2. 0002SpringBoot整合Junit

    前提条件:SpringBoot已经整合了Mybatis,至于SpringBoot如何整合Mybatis可参考我的上一篇文章 SpringBoot为什么要整合Juni? SpringBoot整合了Jun ...

  3. webpac4k运行webpack .\src\main.js .\dist\bundle.js打包出错

    打包的命令格式:webpack 要打包的文件的路径  打包好的输出文件的路径 运行webpack .\src\main.js .\dist\bundle.js 提示错误,错误信息如下: WARNING ...

  4. 2019HDU多校Path——最短路最小割

    题目 给出一个 $n$ 个顶点 $m$ 条边的图,要求阻塞一些边,使得从 $1$ 到 $n$ 的最短路变长,求阻塞的边长度和的最小值,不必保证阻塞后可达. 分析 很显然,要阻塞的边肯定在最短路图上,先 ...

  5. Spring Boot常用的注解

    @SpringBootApplication:包含@Configuration.@EnableAutoConfiguration.@ComponentScan通常用在主类上.由于大量项目都会在主要的配 ...

  6. BZOJ 3566 概率充电器(树形概率DP)

    题面 题目传送门 分析 定义f(i)f(i)f(i)为iii点不被点亮的概率,p(i)p(i)p(i)为iii自己被点亮的概率,p(i,j)p(i,j)p(i,j)表示i−ji-ji−j 这条边联通的 ...

  7. [Flutter] Stack Layout

    Normally if you place three the same size icons in a stack, they will stands on top of each other, t ...

  8. 【51nod 1340】地铁环线

    题目 有一个地铁环线,环线中有N个站台,标号为0,1,2,...,N-1.这个环线是单行线,一共由N条有向边构成,即从0到1,1到2,..k到k+1,...,N-2到N-1,N-1到0各有一条边.定义 ...

  9. 第二章 C#语法快速热身

    C#语法快速热身 语法 if(条件表达式){ 代码块 } 语法 if(条件表达式){ 代码块 }else{ 代码块2 } 语法 if(条件表达式1){ 代码块1 if(条件表达式1)){ }else{ ...

  10. git 远程代码被覆盖

    场景: 解决方法: 第1步. 回退至上一个完整的正确的版本.Git Bash 中输入命令: git reset --hard 1b59cef2a1685c37b7e7b5f2497e055f5e031 ...