三台ubuntuServer 的 ip: 192.168.0.4,192.168.0.5,192.168.0.6
從官網下載下傳elasticsearch 版本2.2.1
解壓到/opt/目錄下
sudo tar -zxvf elasticsearch-.tar.gz -C /opt
對ip為192.168.0.4的主機
進入/opt/elasticsearch-2.2.1/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: qiaqia
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: dngel
#
# 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.mlockall: 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:
#
# 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.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.0.5", "192.168.0.6"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1):
#
discovery.zen.minimum_master_nodes:
#
# 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
安裝head插件
[email protected]:/opt/elasticsearch-2.2.1/bin#
sudo ./plugin install mobz/elasticsearch-head
其他插件安裝可參照官網插件安裝
配置另外兩台主機
将elasticsearch-2.2.1複制到192.168.0.5和192.168.0.6
修改elasticsearch.yml
對192.168.0.5, 找到并修改下面配置
node.name: engel
network.host: 192.168.0.5
discovery.zen.ping.unicast.hosts: ["192.168.0.4", "192.168.0.6"]
對192.168.0.6, 找到并修改下面配置
node.name: fngel
network.host: 192.168.0.6
discovery.zen.ping.unicast.hosts: ["192.168.0.4", "192.168.0.5"]
調優
修改Es占用記憶體:vim /opt/elasticsearch-2..2.1/bin/elasticsearch.in.sh
找到 ES_MIN_MEM和ES_MAX_MEM,修改es最大和最小占用記憶體值, 這裡我設定為1g,視機器具體情況而定
修改/etc/security/limits.conf
加上
angel soft memlock unlimited
angel hard memlock unlimited
angel soft nofile
angel hard nofile
重新開機電腦使配置生效angel
elasticsearch 的啟動和關閉
分别在每個節點的/opt/elasticsearch-2.2.1/bin輸入
./elasticsearch
啟動完畢後,可以輸入
curl '192.168.0.4:9200/_cluster/health?pretty'
檢視叢集健康狀态
顯示為green
{
"cluster_name": "qiaqia",
"status": "green",
"timed_out": false,
"number_of_nodes": ,
"number_of_data_nodes": ,
"active_primary_shards": ,
"active_shards": ,
"relocating_shards": ,
"initializing_shards": ,
"unassigned_shards": ,
"delayed_unassigned_shards": ,
"number_of_pending_tasks": ,
"number_of_in_flight_fetch": ,
"task_max_waiting_in_queue_millis": ,
"active_shards_percent_as_number":
}
在浏覽器輸入
http://192.168.0.4:9200/_plugin/head/
,可觀察到叢集狀态