hadoop2-elasticsearch的安裝


本文主要講elasticsearch-2.2.1的安裝過程。

准備工作:

1.搭建虛擬機

你需要先參考

hadoop2集群環境搭建

把你的虛擬機搭建起來-hadoop環境可以先不用搭建(完成步驟1到步驟8

2.下載elasticsearch包

下載elasticsearch-2.2.1.tar.zip

 

這里我搭建的是4台虛擬機(node1,node2,node3,node4)

elasticsearch 只允許普通用戶操作,不允許root用戶操作

--1.關閉防火牆
service iptables stop

--2.創建用戶elsearch
useradd elsearch
--3.給用戶elsearch設置密碼
passwd elsearch

--4.在/opt目錄下面創建elsearch/es/目錄
mkdir /opt/elsearch/es/

--5.進入到/opt目錄下面
cd /opt/

--6.把elsearch目錄以及里面的子目錄的權限設置為elsearch
chown -R elsearch:elsearch elsearch

--此時,/elsearch, /elsearch/es的權限都應該為elsearch

--7.切換用戶到elsearch
su elsearch

 

此時,所有節點都應該是elsearch用戶,而不是root用戶。

現在去到node1節點上面進行操作

--此時,在node1上面操作
--1.此時,我們就可以把下載好的elasticsearch-2.2.1.tar.zip文件上傳到node1下面的/opt/elsearch/es/
--2.解壓/opt/elsearch/es/elasticsearch-2.2.1.tar.zip文件
cd /opt/elsearch/es/
unzip elasticsearch-2.2.1.tar.zip

--3.修改配置文件
cd /opt/elsearch/es/elasticsearch-2.2.1/conf/

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 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: elsearch-app
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node1
#
# 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:
#
# ----------------------------------- 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: 192.168.79.138
#
# 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.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
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.79.138","192.168.79.139", "192.168.79.140","192.168.79.141"]
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s



:wq


--4.然后從node1分發到其他節點(node2, node3, node4)的相同目錄
cd /opt/elsearch/es
scp -r ./elasticsearch-2.2.1 elsearch@node2:/opt/elsearch/es
scp -r ./elasticsearch-2.2.1 elsearch@node3:/opt/elsearch/es
scp -r ./elasticsearch-2.2.1 elsearch@node4:/opt/elsearch/es

接下來在node2,node3,node4上面進行操作

--分別修改node2,node3,node4上面的配置文件
cd /opt/elsearch/es/elasticsearch-2.2.1/conf/

vi elasticsearch.yml

--修改兩個地方
--1.node.name: node1
--2.network.host: 192.168.79.138

--修改為和下面相對應,然后保存
192.168.79.138 node1
192.168.79.139 node2
192.168.79.140 node3
192.168.79.141 node4

 

最后,在所有節點(node1,node2,node3,node4)上面進行操作

--啟動elasticsearch
cd /opt/elsearch/es/elasticsearch-2.2.1/bin
./elasticsearch

 

打開瀏覽器,輸入:node1:9200可以看見一下效果

 

添加插件elasticsearch-head

下載elasticsearch-head

把下載好的插件重命名為

head

然后添加到所有節點(node1,node2,node3,node4)的

/opt/elsearch/es/elasticsearch-2.2.1/plugins

目錄。

 

然后重啟所有節點。

--啟動elasticsearch
cd /opt/elsearch/es/elasticsearch-2.2.1/bin
./elasticsearch

 

效果如下:

了解更多:elasticsearch-head

 

========================================================

More reading,and english is important.

I'm Hongten

 

大哥哥大姐姐,覺得有用打賞點哦!你的支持是我最大的動力。謝謝。
Hongten博客排名在100名以內。粉絲過千。
Hongten出品,必是精品。

E | hongtenzone@foxmail.com  B | http://www.cnblogs.com/hongten

======================================================== 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM