elasticsearch集群部署

Elasticsearch 是一个分布式的 RESTful 风格的搜索和数据分析引擎,能够解决不断涌现出的各种用例。作为 Elastic Stack 的核心,它集中存储您的数据,帮助您发现意料之中以及意料之外的情况。

资源准备:由于资源有限,准备两个节点,有需要可以自行增加节点,注意以下操作每个节点的配置都一样

elasticsearch下载地址:https://www.elastic.co/cn/downloads/elasticsearch 

1、配置java环境

可自定义Java
yum install java java-1.8.0-openjdk-devel -y
java -version

多版本并存时,会自动链接最新版本
ls -l /etc/alternatives/java  

配置环境变量
cat /etc/profile.d/java.sh
export JAVA_HOME=/usr
source  /etc/profile.d/java.sh

2、安装elasticsearch

yum install elasticsearch-6.4.0.rpm

3、配置集群

egrep -v  "#|^$" /etc/elasticsearch/elasticsearch.yml 
cluster.name: es
node.name: test1  #主机名称,有必须做好名称解析
path.data: /var/lib/elasticsearch
path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: ["10.0.1.6", "10.0.1.4"]

4、启动elasticsearch

systemctl daemon-reload
systemctl start elasticsearch.service
systemctl status elasticsearch.service
ava堆内存的值比较小,处理数据量大时需要调大,但是单台主机jvm的内存不在超过32G

检查:
ss -tnl|egrep "9300|9200"
LISTEN     0      50          :::9200                    :::*                  
LISTEN     0      50          :::9300                    :::*  

5、检查集群节点是否正常工作(参考文档:url)

curl -X GET 'http://10.0.1.4:9200/?pretty'
{
  "name" : "test1",
  "cluster_name" : "es",
  "cluster_uuid" : "NVia-ciPQKy3GxWPzBWDmg",
  "version" : {
    "number" : "6.4.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "595516e",
    "build_date" : "2018-08-17T23:18:47.308994Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

curl -X GET 'http://10.0.1.6:9200/?pretty'
{
  "name" : "test2",
  "cluster_name" : "es",
  "cluster_uuid" : "NVia-ciPQKy3GxWPzBWDmg",
  "version" : {
    "number" : "6.4.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "595516e",
    "build_date" : "2018-08-17T23:18:47.308994Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

集群状况
 curl -X GET 'http://10.0.1.6:9200/_cat/nodes' 
10.0.1.6 41 98 0 0.00 0.01 0.05 mdi * test2
10.0.1.4 34 55 0 0.00 0.02 0.05 mdi - test1

curl -X GET 'http://10.0.1.6:9200/_cluster/health?pretty'
{
  "cluster_name" : "es",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 2,
  "number_of_data_nodes" : 2,
  "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.0
}

  

posted @ 2018-08-28 12:55  Reid21  阅读(393)  评论(0编辑  收藏  举报