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