突破单机多实例Elasticsearch

    默认大家都是单机单实例es,在实验环境下想尽可能模拟各种场景。单机多实例就出来了。。。

实验拓扑图

01、es安装这里就不说了

详情:http://www.cnblogs.com/xiaochina/p/6852677.html

02、讲elasticsearch.yml配置

要做到单机上开多个实例,需要修改ES的默认配置:

node.max_local_storage_nodes: 2   #单机开启2个实例

配置限制了单节点上可以开启的ES存储实例的个数

http.port: 9200

配置是elasticsearch对外提供服务的http端口配置,默认情况下ES会取用9200~9299之间的端口,如果9200被占用就会自动使用9201

在单机多实例的配置中这个配置实际是不需要修改的,但是为了更好地进行配置管理,建议根据需求修改9201 9202

transport.tcp.port: 9300

配置指定了elasticsearch集群内数据通讯使用的端口,默认情况下为9300,与上面的http.port配置类似,ES也会自动为已占用的端口选择下一个端口号。我们可以将第一个实例的tcp传输端口配置为9300,第二实例配置为9301。

discovery.zen.ping.unicast.hosts  由于到了2.x版本之后,ES取消了默认的广播模式来发现master节点,需要使用该配置来指定发现master节点。这个配置在单机双实例的配置中需要特别注意下,因为习惯上我们配置时并未指定master节点的tcp端口,如果实例的transport.tcp.port配置为9301,那么实例启动后会认为discovery.zen.ping.unicast.hosts中指定的主机tcp端口也是9301,可能导致这些节点无法找到master节点。

该配置中需要指定master节点提供服务的tcp端口。

配置示例:

discovery.zen.ping.unicast.hosts: ["172.24.0.26:9301"]
  • node.name

    同一主机上的两个实例需要使用不同的node.name

  • path.data

    同一主机上两个实例需要对应不同的数据目录

path.logs

由于默认情况下日志用集群名称来命名,因此同一主机两个实例对应的日志目录需要分开

#禁止HTTP
http.enabled: false

配置样例

node1-es-data

[[email protected]25 config]$ cat 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: mvpbang
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
node.master: false
node.data: true                 #数据存储
node.max_local_storage_nodes: 2 #本机最大两个es
transport.tcp.port: 9301        #节点通信端口
http.enabled: false             #关闭http接口
#
# 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
bootstrap.system_call_filter: 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: 172.24.0.25
#
# Set a custom port for HTTP:
#
#http.port: 9201
#
# 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: ["172.24.0.26:9301"]  #候选主节点地址
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligibl
e 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

node2-es-data

[[email protected]25 config]$ cat 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: mvpbang
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-2
node.master: false
node.data: true
node.max_local_storage_nodes: 2
transport.tcp.port: 9302
http.enabled: false
#
# 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
bootstrap.system_call_filter: 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: 172.24.0.25
#
# Set a custom port for HTTP:
#
#http.port: 9202
#
# 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: ["172.24.0.26:9301"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligibl
e 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

node3-es-master

[[email protected]25 config]$ cat 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: mvpbang
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-3
node.master: true
node.data: false
node.max_local_storage_nodes: 2
transport.tcp.port: 9301
http.enabled: 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
bootstrap.system_call_filter: 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: 172.24.0.26
#
# Set a custom port for HTTP:
#
http.port: 9201
#
# 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: ["172.24.0.26:9301"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligibl
e 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

node4-es-data

[[email protected]25 config]$ cat 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: mvpbang
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-4
node.master: false
node.data: falsenode.ingest: false
node.max_local_storage_nodes: 2
transport.tcp.port: 9302
http.enabled: 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
bootstrap.system_call_filter: 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: 172.24.0.26
#
# Set a custom port for HTTP:
#
http.port: 9202
#
# 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: ["172.24.0.26:9301"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligibl
e 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

 效果图

注意:复制的elasticsearch文件夹下包含了data文件中示例一的节点数据,需要把示例二data文件下的文件清空

Kibana的elasticsearch.url:配置load-balancedi地址   http://172.24.0.26:9202

学习参考:http://www.tuicool.com/articles/VBVFzyi

https://www.elastic.co/guide/en/kibana/current/production.html#load-balancing  #搜索请求节点负载

时间: 2024-08-11 01:21:28

突破单机多实例Elasticsearch的相关文章

ElasticSearch单机双实例的配置方法

ElasticSearch单机双实例的配置方法https://knktc.com/2016/06/10/elasticsearch-multiple-instances/Don't Cross 32 GB!https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html#compressed_oopsElasticSearch术语https://www.cnblogs.com/chenny7/p/431172

Redis的make,make test,make install、单机多实例配置,以及API程序写数据!

最近学习王家林老师的大数据蘑菇云行动,要实现将Spark Streaming分析的数据写入到Redis.今天正好开始入手.  一.Ubuntu16安装Redis3.2.1 遇到了不少的问题,其中,make倒是没问题,make test的时候,出现了: !!! WARNING The following tests failed: *** [err]: Slave should be able to synchronize with the master in tests/integration/

MySQL单机多实例安装并配置主从复制

单机多实例据说可以最大程度提高硬件使用,谁知道呢,但是以前的公司喜欢这样搞,我最近也在学习复制什么的,电脑搞不起两台虚拟机,刚好单机多实例可以解救我.下面就说说步骤. 承上文http://www.cnblogs.com/wingsless/p/4002806.html,我已经安装好了MySQL,不过这个是单实例的,要更改也可以,但是担心会出现问题,于是我将下面的东西删掉: 1 #rm -f /etc/init.dmysql 2 $rm -f /home/mysql/data 建立这么几个目录:

MySQL 5.6对已有Mysql单实例的机器,再添加mysql数据库,实现单机多实例

一.需求: 对已有Mysql单实例的机器,再添加两个mysql数据库,实现单机多实例. 一个绑定在端口3306,另外两个绑定在端口3307,3308: 数据分别存放在/data/mysqldata./data/mysqldata2./data/mysqldata3 三个实例均采用InnoDB作为默认的存储引擎,字符编码采用UTF-8: 三个实例均采用相同的性能优化配置参数: MySQL的源码安装请看我的另一篇博客http://yylinux.blog.51cto.com/8831641/1677

单机多实例MYSQL主从复制

今天有时间写写,不然心坎里总有点不爽.单机多实例一直都是屌丝的处事风格... 实验环境 RHEL6.5 172.24.0.130  3306 172.24.0.130  3307 01.本次采用的MYSQL二进制快速安装 下载地址: https://dev.mysql.com/downloads/mysql/ http://pan.baidu.com/s/1qYI0ybq http://pan.baidu.com/s/1pLHM2TH 密码: pg5t #截图操作 #根据需求选择对应的版本 02

amoeba针对MySQL单机多实例配置文件注释

MySQL单机多实例的读写分离可以通过第三方软件来实现,其中一个叫简单的读写分离软件就是今天所带给大家的amoeba软件. 本次使用的amoeba软件为amoeba-mysql-binary-2.1.0-RC5.tar.gz 本软件是基于JAVA环境运行的,所以需要JAVA环境支持,具体环境配置不做详解. 本文主要解释两个主配置文件. 1.dbServer.xml 这个文件配置的是父配置(用来给默认子配置补充配置项) 真实mysql服务器的端口,数据库名称,mysql用户及密码 主服务器,从服务

Tomcat单机多实例部署-多项目部署

博文说明[前言]: 本文将通过个人口吻介绍Tomcat单机多实例部署,在目前时间点[2017年8月13号]下,所掌握的技术水平有限,可能会存在不少知识理解不够深入或全面,望大家指出问题共同交流,在后续工作及学习中如发现本文内容与实际情况有所偏差,将会完善该博文内容. 本文参考文献及引用文章链接: 1.http://wiki.jikexueyuan.com/project/tomcat/ [Tomcat 8 权威指南-极客学院出品] 2.<Tomcat 权威指南> 2.http://www.cn

mariadb单机多实例主从复制

准备工作: 停掉数据库服务: systemctl stop mariadb.service 将主库的数据库文件拷贝一份作为从库数据: cp -a -r /data/mysql_data/mysql/* /data/mysql_data/mysql2/ 拷贝完启动: systemctl start mariadb.service 步骤1:配置主库和从库多实例的cnf文件 主库和从库共用一个cnf文件, /etc/my.cnf [mysqld] log-bin=mysql-bin-log serve

[转载]Tomcat单机多实例配置

Tomcat单机多实例配置 当一个进程的线程超过500个的话,那么这个进程的运行效率会变得很低.因为一个进程产生过多的线程,CPU资源会浪费在线程间切换过程当中.但当服务器配置很高的情况下,如:32G内存,16核的CPU.这样一台高配的机器上只装一个Tomcat实例,会有点浪费.其实我们可以根据服务器的硬件配置,配置多个Tomcat实例,充分利用硬件的资源.你第一时间可能会想到,直接下载多份Tomcat安装包,直接解压,改下端口跑起来不就可以了? 这样也是可以的,但不好维护.假设你在一台机器上安