ElaticSearch安裝
ElasticSearch介紹
Elasticsearch是一個基於Lucene的實時的分佈式搜索和分析引擎。
設計用於雲計算中,能夠達到實時搜索,穩定,可靠,快速,安裝使用方便。
基於Restful接口
- 普通請求是...get?a=1
- rest請求...get/a/1
ElasticSearch的用戶
- Github,Wikipedia,ebay等...
1.解壓文件
[root@node01 software]# tar -zxvf elasticsearch-2.4.0.tar.gz -C /opt/modules/
2.編寫ElasticSearch配置文件
修改config/elasticsearch.yml (注意要頂格寫,冒號後面要加一個空格)
a) Cluster.name: matrix (同一集羣要一樣)
b) Node.name: node-1 (同一集羣要不一樣)
c) Network.Host: 192.168.230.10 這裏不能寫127.0.0.1
d) 防止腦裂的配置
# 關閉組合方式尋找機器
discovery.zen.ping.multicast.enabled: false
# 尋找機器的時間
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
# 在集羣裏有可能找到這幾個機器
discovery.zen.ping.unicast.hosts: ["192.168.230.10","192.168.230.11", "192.168.230.12"]
2.1.配置node01節點上的ElasticSearch
[root@node01 modules]# cd elasticsearch-2.4.2
[root@node01 elasticsearch-2.4.2]# vi config/elasticsearch.yml
a) Cluster.name: matrix
b) Node.name: node-1
c) Network.Host: 192.168.230.10
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
discovery.zen.ping.unicast.hosts: ["192.168.230.10","192.168.230.11", "192.168.230.12"]
2.2.將node01節點上的ElasticSearch分發到node02、node03節點上
[root@node01 modules]# scp -r elasticsearch-2.4.2 root@node02:/opt/modules/
[root@node01 modules]# scp -r elasticsearch-2.4.2 root@node03:/opt/modules/
2.2.配置node02節點上的ElasticSearch
[root@node01 elasticsearch-2.4.2]# vi config/elasticsearch.yml
a) Cluster.name: matrix
b) Node.name: node-2
c) Network.Host: 192.168.230.11
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
discovery.zen.ping.unicast.hosts: ["192.168.230.10","192.168.230.11", "192.168.230.12"]
2.2.配置node03節點上的ElasticSearch
[root@node01 elasticsearch-2.4.2]# vi config/elasticsearch.yml
a) Cluster.name: matrix
b) Node.name: node-3
c) Network.Host: 192.168.230.12
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping_timeout: 120s
client.transport.ping_timeout: 60s
discovery.zen.ping.unicast.hosts: ["192.168.230.10","192.168.230.11", "192.168.230.12"]
3.啓動ElasticSearch集羣
注意:Elastic不能在root用戶下運行,node01、node02、node03機器是一樣的步驟
[root@node01 elasticsearch-2.4.2]# useradd matrix
[root@node01 elasticsearch-2.4.2]# chown -R matrix:matrix ../*
[root@node01 elasticsearch-2.4.2]# ll
total 48
drwxr-xr-x. 2 matrix matrix 4096 Jan 6 18:30 bin
drwxr-xr-x. 2 matrix matrix 4096 Jan 6 20:21 config
drwxr-xr-x. 2 matrix matrix 4096 Jan 6 18:30 lib
-rw-rw-r--. 1 matrix matrix 11358 Jan 27 2016 LICENSE.txt
drwxr-xr-x. 2 matrix matrix 4096 Jan 6 20:34 logs
drwxrwxr-x. 4 matrix matrix 4096 Jan 27 2016 modules
-rw-rw-r--. 1 matrix matrix 150 Jan 27 2016 NOTICE.txt
-rw-rw-r--. 1 matrix matrix 8700 Jan 27 2016 README.textile
[root@node01 elasticsearch-2.2.0]# passwd matrix
Changing password for user matrix.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@node01 elasticsearch-2.2.0]# su matrix
3.1.運行ElasticSearch
[matrix@node01 elasticsearch-2.4.2]$ chmod u+x ./bin/elasticsearch
[matrix@node01 elasticsearch-2.4.2]$ ./bin/elasticsearch
注意這裏最好用火狐或者chrome瀏覽器
http://192.168.230.10:9200/
http://192.168.230.11:9200/
http://192.168.230.12:9200/
4.1.查看整個集羣的狀態
http://192.168.230.11:9200/_cluster/health?pretty