日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式

發布時間:2025/3/21 windows 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 概述
  • CentOS上部署ES集群
    • 集群組成
    • 關鍵配置信息
    • Master節點搭建
    • Slave1節點搭建
    • Slave2節點搭建
  • Windows 部署 ES集群
    • elasticsearch.yml配置修改
    • 啟動服務
  • 注意事項

概述

Elasticsearch-01CentOS7單節點部署ES5.6.16中我們學習了ES單節點的部署,這里我們來看下ES集群是如何部署的吧

CentOS上部署ES集群

集群組成

  • 節點數量: 3個 (1個Master 2個Slave)
  • OS: CentOS 7
  • IP: 192.168.91.128
  • port : master-9200 slave01-8200 slave02-7200

方便起見,先按照偽集群模式部署吧,在同一臺主機上使用不同的端口來區分不同的節點,當然了你也可以使用3臺虛機,那是最好不過的了


關鍵配置信息

必須保證集群名相同,如果節點處于同一局域網同一網段,es會自動去發現其他的節點。

elasticsearch.yml

Master

# 綁定的服務器IP,可設置為本機IP network.host: 192.168.91.128 #啟動的端口,默認9200 http.port: 9200#跨域設置 http.cors.enabled: true http.cors.allow-origin: "*"#集群信息 cluster.name: artisan node.name: master node.master: true

其他配置,也可以按需修改


Slave01:

#host 和 端口 network.host: 192.168.91.128 http.port: 8200#集群信息 cluster.name: artisan node.name: slave01 #默認的通訊接口是9300,用來發現master信息 discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Slave02:

#host 和 端口 network.host: 192.168.91.128 http.port: 7200#集群信息 cluster.name: artisan node.name: slave02 #默認的通訊接口是9300,用來發現master信息 discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Master節點搭建

修改elasticsearch.yml中的配置

# ======================== Elasticsearch Configuration ========================= # # NOTE: Elasticsearch comes with reasonable defaults for most settings. # Before you set out to tweak and tune the configuration, make sure you # understand what are you trying to accomplish and the consequences. # # The primary way of configuring a node is via this file. This template lists # the most important settings you may want to configure for a production cluster. # # Please consult the documentation for further information on configuration options: # https://www.elastic.co/guide/en/elasticsearch/reference/index.html # # ---------------------------------- Cluster ----------------------------------- # # Use a descriptive name for your cluster: # #cluster.name: my-application # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # #node.name: node-1 # # Add custom attributes to the node: # #node.attr.rack: r1 # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # #path.data: /path/to/data # # Path to log files: # #path.logs: /path/to/logs # # ----------------------------------- Memory ----------------------------------- # # Lock the memory on startup: # #bootstrap.memory_lock: true # # Make sure that the heap size is set to about half the memory available # on the system and that the owner of the process is allowed to use this # limit. # # Elasticsearch performs poorly when the system is swapping the memory. # # ---------------------------------- Network ----------------------------------- # # Set the bind address to a specific IP (IPv4 or IPv6): # network.host: 192.168.91.128 # # Set a custom port for HTTP: # http.port: 9200 # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when new node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # #discovery.zen.ping.unicast.hosts: ["host1", "host2"] # # Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1): # #discovery.zen.minimum_master_nodes: 3 # # For more information, consult the zen discovery module documentation. # # ---------------------------------- Gateway ----------------------------------- # # Block initial recovery after a full cluster restart until N nodes are started: # #gateway.recover_after_nodes: 3 # # For more information, consult the gateway module documentation. # # ---------------------------------- Various ----------------------------------- # # Require explicit names when deleting indices: # #action.destructive_requires_name: true # #跨域設置 http.cors.enabled: true http.cors.allow-origin: "*" #集群信息 cluster.name: artisan node.name: master node.master: true

通過head插件訪問集群信息

可以看到 節點名字已經變成了master, 并且前面的五角星表示為master節點(指揮官) 。


Slave1節點搭建

復制一份,然后修改配置文件

[root@localhost ~]# su - elastic Last login: Thu Apr 18 08:47:46 PDT 2019 on pts/1 [elastic@localhost ~]$ pwd /home/elastic [elastic@localhost ~]$ ll total 33108 drwxr-xr-x. 9 elastic elastic 4096 Apr 18 03:30 elasticsearch-5.6.16 -rw-r--r--. 1 root root 33894983 Apr 18 03:27 elasticsearch-5.6.16.tar.gz [elastic@localhost ~]$ [elastic@localhost ~]$ [elastic@localhost ~]$ mkdir elasticsearch-5.6.16-salve [elastic@localhost ~]$ cp elasticsearch-5.6.16.tar.gz elasticsearch-5.6.16-salve/ [elastic@localhost ~]$ cd elasticsearch-5.6.16-salve/ [elastic@localhost elasticsearch-5.6.16-salve]$ ll total 33104 -rw-r--r--. 1 elastic elastic 33894983 Apr 18 18:28 elasticsearch-5.6.16.tar.gz [elastic@localhost elasticsearch-5.6.16-salve]$ tar -xvzf elasticsearch-5.6.16.tar.gz [elastic@localhost elasticsearch-5.6.16-salve]$ cp -r elasticsearch-5.6.16 elasticsearch-slave01 [elastic@localhost elasticsearch-5.6.16-salve]$ cp -r elasticsearch-5.6.16 elasticsearch-slave02[elastic@localhost elasticsearch-5.6.16-salve]$ cd elasticsearch-slave01[elastic@localhost elasticsearch-slave01]$ vim config/elasticsearch.yml

elasticsearch.yml 追加如下配置

#host 和 端口 network.host: 192.168.91.128 http.port: 8200#集群信息 cluster.name: artisan node.name: slave01 #默認的通訊接口是9300,找到集群的信 discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Slave2節點搭建

[elastic@localhost elasticsearch-5.6.16-salve]$ cd elasticsearch-slave02

elasticsearch.yml 追加如下配置

#host 和 端口 network.host: 192.168.91.128 http.port: 7200#集群信息 cluster.name: artisan node.name: slave02 #默認的通訊接口是9300,用來發現master信息 discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

我這里用的虛機的內存太小了,無法啟動兩個及兩個以上的節點, 為了驗證配置的正確性,windows上部署下吧


Windows 部署 ES集群

三個節點:


elasticsearch.yml配置修改

elasticsearch.yml的配置如下:

和centos中的配置一樣,僅僅是IP不同

master:

# 綁定的服務器IP,可設置為本機IP network.host: 127.0.0.1 #啟動的端口,默認9200 http.port: 9200#跨域設置 http.cors.enabled: true http.cors.allow-origin: "*"#集群信息 cluster.name: artisan node.name: master node.master: true


salve01:

#host 和 端口 network.host: 127.0.0.1 http.port: 8200#集群信息 cluster.name: artisan node.name: slave01 #默認的通訊接口是9300,用來發現master信息 discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]


slave02:

#host 和 端口 network.host: 127.0.0.1 http.port: 7200#集群信息 cluster.name: artisan node.name: slave02 #默認的通訊接口是9300,用來發現master信息 discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]


啟動服務

雙擊H:\elasticsearch-5.6.16-slave02\bin\elasticsearch.bat

通過head 插件查看 集群信息

配置OK


注意事項

found existing node {master}{xdHjXCdET_e7M0G_MYNiTQ}{WbXaI8HtRDCbFEzS8VtdIg}{127.0.0.1}{127.0.0.1:9300} with the same id but is a different node instance];

如果配到了這種錯誤,很明顯id重復了,如果配置沒有問題,看下你是不是直接copy的已經存在的節點data目錄中的數據重復導致的。 建議解壓一個新的壓縮包,重新配置,避免上述錯誤。

總結

以上是生活随笔為你收集整理的Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。