集群:
10.226.204.6昌简;10.226.204.8继阻;10.226.204.9
三臺機器配置好jdk示括,將es拷貝到每一臺機器上的相同目錄下(/home/elk/elasticsearch)
三個節(jié)點都不配置node.master和node.data姆怪,使用默認(rèn)配置
主要寫好配置文件/config/Elasticsearch.yml
以10.226.204.6為例:
# ======================== 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: jmr-elk 配置集群名稱溯乒,三臺的集群名稱要相同
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-6 節(jié)點名稱杯道,不能相同
#
# 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: /home/elk/data 配置ES數(shù)據(jù)存儲路徑匪煌,默認(rèn)情況下,ES將數(shù)據(jù)存在ES根目錄下,注意這里一定要手動配置虐杯,否則重新部署ES時玛歌,數(shù)據(jù)將被清空
#
# Path to log files:
#
path.logs: /home/elk/log ES log路徑
#
# ----------------------------------- 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: 10.226.204.6 配置hostip地址
#
# Set a custom port for HTTP:
#
http.port: 9200 配置端口號,查詢和插入需要使用該端口號擎椰,注意支子,ES之間通信使用9300端口號,需要修改時达舒,需要使用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]"]
#
discovery.zen.ping.unicast.hosts: ["10.226.204.8:9300","10.226.204.9:9300"] 這里列出部分集群節(jié)點值朋,如果不加端口號,默認(rèn)使用9300端口號巩搏,在10.226.204.6主機上昨登,這里只添加另外兩臺主機
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes: 2 最少有幾個master候選節(jié)點時,可選舉主節(jié)點贯底,數(shù)量是(N / 2) + 1, N是有資格成為Master的節(jié)點丰辣,防止出現(xiàn)腦裂現(xiàn)象
#
# 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
驗證集群搭建是否成功:curl -XGET 'http://10.226.204.6.:9200/_cat/nodes?pretty',可以查看到集群中節(jié)點狀態(tài)
踩得坑:
1禽捆、 discovery.zen.ping.multicast.enabled: false笙什,在ES2.X以后版本中,是不能對該屬性進行配置的胚想,目前最新的ES默認(rèn)使用單播模式進行集群搭建琐凭,如果使用多播模式搭建,需要新添加插件浊服,也不建議使用多播方式進行搭建统屈;
2、 ES啟動過程中出現(xiàn):max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]牙躺,解決方法如下:
a) 切換到root用戶
b) 執(zhí)行命令:
c) sysctl -w vm.max_map_count=262144
d) 查看結(jié)果:
e) sysctl -a|grep vm.max_map_count
f) 顯示:
g) vm.max_map_count = 262144
3愁憔、 centos7.2 es5.4.1啟動報錯 BindTransportException [Failed to bind to [9300-9400]],是由于配置文件里本機的ip地址寫錯了
參考鏈接:
1孽拷、 https://www.elastic.co/guide/cn/elasticsearch/guide/current/important-configuration-changes.html