elasticsearch学习——环境搭建2

1、head插件安装html

打开cmd,而且cd到elasticsearch的bin目录下面java

接着输入命令:plugin install mobz/elasticsearch-head,node

而后就会开始安装head插件,若是出现Installed head into的字样,证实head插件安装成功。bootstrap

而后就会在elasticsearch安装目录的plugins文件夹里看到head目录app

2、head插件界面介绍elasticsearch

一、装好head插件以后,若是在本机装的,则访问localhost:9200/_plugin/head,就能够看到head插件的界面了ide

这里介绍一下界面,使用方法多摸索就会了。性能

二、elasticsearch分区,备份等概念介绍ui

cluster:集群,一个ES集群由一个或多个节点(Node)组成,每一个集群都有一个cluster name做为标识。this

node:节点,即一个 Elasticsearch 的运行实例,一台机器上能够运行多个节点

shard:分区,是一个Lucene 实例。Elasticsearch 基于 Lucene,shard 是一个 Lucene 实例,被 Elasticsearch 自动管理。index 是一个逻辑命名空间, shard 是具体的物理概念,建索引、查询等都是具体的shard在工做。shard 包括primary shard 和 replica shard,写数据时,先写到primary shard, 而后,同步到 replica shard,查询时,primary 和 replica 充当相同的做用。replica shard 能够有多份,也能够没有。

replica:备份

    2.一、主分片和备分片不会出如今同一个节点上(防止单点故障),默认状况下一个索引建立5个分片,每一个分片一个备份分片(即5primary+5replica=10个分片)
    2.二、若是你只有一个节点,那么5个replica都没法分配(unassigned),此时cluster status会变成yellow
    2.三、ES集群状态有三种:
            Green:全部主分片和备份分片都准备就绪(分配成功),即便有一台机器挂了(假设一台机器一个实例),数据都不会丢失,但会变成Yellow状(主分片所在节点挂了备份分片会顶上去)
            Yellow:全部主分片准备就绪,但存在至少一个主分片对应的备份分片没有就绪,此时集群属于警告状态,意味着集群高可用和容灾能力降低,若是恰好这个分片所在的节点挂了,而且你只设置了一个备份(并且这个备份恰好是未就绪状态),那么这个分区的数据就会丢失,致使查询结果不完整,此时集群进入Red状态
            Red:至少有一个主分片没有就绪(直接缘由是找不到对应的备份分片成为新的主分片),致使查询结果数据不完整
    2.四、replica shard的存在有两个做用,一是容灾,若是primary shard 挂了,数据也不会丢失,集群仍然能正常工做;二是提升性能,由于replica 和 primary shard 都能处理查询,若是设置合理的备份数量能够增长查询速度,相应的会增长索引大小。

3、集群搭建配置

一、将上面获得的elasticsearch的安装目录复制两份,记住新的名字最好不要含有中文。修改config目录下的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 see the documentation for further information on configuration options:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html>
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群的名字,这三个文件的必须同样
 cluster.name: elasticsearch
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 节点的名字,三个节点的不能同样,另外两个能够写成node-2,node-3
 node.name: node-1
#
# Add custom attributes to the node:
#
# node.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 `ES_HEAP_SIZE` environment variable 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: 127.0.0.1
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
# --------------------------------- 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: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery.html>
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-gateway.html>
#
# ---------------------------------- Various -----------------------------------
#
# Disable starting multiple nodes on a single system:
#
# node.max_local_storage_nodes: 1
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true

#shard的数目
 index.number_of_shards: 6

#replica的数目
 index.number_of_replicas: 2

#制定分词器为ik
 index.analysis.analyzer.ik.type: "ik"

改好配置文件后就能够启动三个集群名为elasticsearch的节点了。

相关文章
相关标签/搜索