学习搭建elasticsearch集群

下载

elasticsearch-2.4.3.tar.gz

1
$ wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.3/elasticsearch-2.4.3.tar.gz

在三个centos节点上,分别下载解压【或者一个节点修改后再拷贝到其他节点】,修改配置文件

1
2
tar -zxvf elasticsearch-2.4.3.tar.gz
cd elasticsearch-2.4.3

hosts文件

1
2
3
192.168.0.250 bigdata1
192.168.0.251 bigdata2
192.168.0.252 bigdata3

bigdata1

1
2
3
4
5
6
vi config/elasticsearch.yml
cluster.name: es-cluster-application
node.name: node-1
network.host: 192.168.0.250
http.port: 9200
discovery.zen.ping.unicast.hosts: ["bigdata1", "bigdata2", "bigdata3"]

bigdata2

1
2
3
4
5
6
vi config/elasticsearch.yml
cluster.name: es-cluster-application
node.name: node-2
network.host: 192.168.0.251
http.port: 9200
discovery.zen.ping.unicast.hosts: ["bigdata1", "bigdata2", "bigdata3"]

bigdata3

1
2
3
4
5
6
vi config/elasticsearch.yml
cluster.name: es-cluster-application
node.name: node-3
network.host: 192.168.0.252
http.port: 9200
discovery.zen.ping.unicast.hosts: ["bigdata1", "bigdata2", "bigdata3"]

启动服务elasticsearch

1
./bin/elasticsearch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ curl http://192.168.0.250:9200/
{
"name" : "node-1",
"cluster_name" : "es-cluster-application",
"cluster_uuid" : "RGht3BSjQCOZMb_XLUn5sQ",
"version" : {
"number" : "2.4.3",
"build_hash" : "d38a34e7b75af4e17ead16f156feffa432b22be3",
"build_timestamp" : "2016-12-07T16:28:56Z",
"build_snapshot" : false,
"lucene_version" : "5.5.2"
},
"tagline" : "You Know, for Search"
}

查看集群状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$ curl http://192.168.0.250:9200/_cluster/health
{
"cluster_name": "es-cluster-application",
"status": "green",
"timed_out": false,
"number_of_nodes": 3,
"number_of_data_nodes": 3,
"active_primary_shards": 0,
"active_shards": 0,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100
}
邵志鹏 wechat
扫一扫上面的二维码关注我的公众号
0%