前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >elasticsearch三节点集群搭建

elasticsearch三节点集群搭建

作者头像
润森
发布2020-02-25 11:46:43
2.5K0
发布2020-02-25 11:46:43
举报
文章被收录于专栏:毛利学Python毛利学Python

elasticsearch集群

@Author:By Runsen

原文:https://maoli.blog.csdn.net/article/details/104312880

本文准备搭建三节点 elasticsearch集群,elasticsearch版本:6.5.4,因此这里准备了三台 Linux CentOS 7机器,只需要简单通过Vmware克隆两台CentOS 7机器,并分别设置静态ip即可。

三台 CentOS 7分别启动elasticsearch

NodeName

Web端口

node-1

192.168.92.90:9200

node-2

192.168.92.91:9200

node-3

192.168.92.93:9200

并将三台Centos7主机名分别设置nodenode01,node02和node03,区别三台centos7机器

代码语言:javascript
复制
#node01主机名设置:
[elsearch@localhost ~]$ hostnamectl set-hostname node01
node01
[elsearch@node01 ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.92.90  netmask 255.255.255.0  broadcast 192.168.92.255
        inet6 fe80::b889:1772:c306:ef8f  prefixlen 64  scopeid 0x20<link>
        inet6 fe80::72e0:4da:118d:13d9  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:07:43:5a  txqueuelen 1000  (Ethernet)
        RX packets 829  bytes 158380 (154.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 634  bytes 116833 (114.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

#node02主机名设置:
[elsearch@localhost ~]$ hostnamectl set-hostname node02
node02
[elsearch@node02 ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.92.91  netmask 255.255.255.0  broadcast 192.168.92.255
        inet6 fe80::b889:1772:c306:ef8f  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:84:99:62  txqueuelen 1000  (Ethernet)
        RX packets 2195  bytes 323930 (316.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 466  bytes 52037 (50.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

#node03主机名设置:
[elsearch@localhost ~]$ hostnamectl set-hostname node03
node03
[elsearch@node03 ~]$ ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.92.92  netmask 255.255.255.0  broadcast 192.168.92.255
        inet6 fe80::22a3:7ced:1761:de8e  prefixlen 64  scopeid 0x20<link>
        inet6 fe80::b889:1772:c306:ef8f  prefixlen 64  scopeid 0x20<link>
        inet6 fe80::72e0:4da:118d:13d9  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c9:f0:22  txqueuelen 1000  (Ethernet)
        RX packets 859  bytes 141277 (137.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 619  bytes 147363 (143.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

下面在三台Centos7机器上对应的elasticsearch.yml配置集群

代码语言:javascript
复制
[elsearch@node01 elasticsearch-6.5.4]$ vim config/elasticsearch.yml
#node01的配置:
cluster.name: es-itcast-cluster
node.name: node01
#设置node01为主节点
node.master: true
node.data: true
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.92.90","192.168.92.91","192.168.92.92"] discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"

[elsearch@node02 elasticsearch-6.5.4]$ vim config/elasticsearch.yml
#node02的配置:
cluster.name: es-itcast-cluster
node.name: node02
node.master: true
node.data: true
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.92.90","192.168.92.91","192.168.92.92"]  discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"

[elsearch@node03 elasticsearch-6.5.4]$ vim config/elasticsearch.yml
#node03的配置:
cluster.name: es-itcast-cluster
node.name: node03
node.master: false
node.data: true
network.host: 0.0.0.0
http.port: 9200
discovery.zen.ping.unicast.hosts: ["192.168.92.90","192.168.92.91","192.168.92.92"]
discovery.zen.minimum_master_nodes: 2
http.cors.enabled: true
http.cors.allow-origin: "*"

#分别启动3个节点 bin/elasticsearch

[elsearch@node01 ~]# curl 127.0.0.1:9200
{
  "name": "node01",
  "cluster_name": "es-itcast-cluster",
  "cluster_uuid": "_na_",
  "version": {
    "number": "6.5.4",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "d2ef93d",
    "build_date": "2018-12-17T21:17:40.758843Z",
    "build_snapshot": false,
    "lucene_version": "7.5.0",
    "minimum_wire_compatibility_version": "5.6.0",
    "minimum_index_compatibility_version": "5.0.0"
  },
  "tagline": "You Know, for Search"
}
[elsearch@node02 ~]# curl 127.0.0.1:9200
{
  "name": "node02",
  "cluster_name": "es-itcast-cluster",
  "cluster_uuid": "_na_",
  "version": {
    "number": "6.5.4",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "d2ef93d",
    "build_date": "2018-12-17T21:17:40.758843Z",
    "build_snapshot": false,
    "lucene_version": "7.5.0",
    "minimum_wire_compatibility_version": "5.6.0",
    "minimum_index_compatibility_version": "5.0.0"
  },
  "tagline": "You Know, for Search"
}
[elsearch@node03 ~]# curl 127.0.0.1:9200
{
  "name" : "node03",
  "cluster_name" : "es-itcast-cluster",
  "cluster_uuid" : "_na_",
  "version" : {
    "number" : "6.5.4",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "d2ef93d",
    "build_date" : "2018-12-17T21:17:40.758843Z",
    "build_snapshot" : false,
    "lucene_version" : "7.5.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

访问任何一个节点,判断是否健康:http://192.168.92.90:9200/_cluster/health?pretty

在elasticsearch-head界面管理工具,我们可以看见创建了三节点集群配置成功,

遇到的报错

org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE]

解决方法:查看9300端口是否开放

停止firewall

代码语言:javascript
复制
systemctl stop firewalld.service
org.elasticsearch.discovery.MasterNotDiscoveredException

解决方法:将在三节点中node.master:true设置2个,设置一个无法体现选举的设置思想。

[node01] not enough master nodes discovered during pinging

google 超级久,两个节点的 日志和data 目录没在一个地方

可我没有指定 日志和data 目录,在浪费1个小时多,找到解决方法:删除elasticsearch安装目录的data文件夹

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-02-14,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小刘IT教程 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • elasticsearch集群
    • 遇到的报错
    相关产品与服务
    Elasticsearch Service
    腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档