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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

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

發(fā)布時(shí)間:2025/3/21 windows 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Elasticsearch-03 CentOS7 / Windows上部署Elasticsearch5.6.16集群模式 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

  • 概述
  • CentOS上部署ES集群
    • 集群組成
    • 關(guān)鍵配置信息
    • Master節(jié)點(diǎn)搭建
    • Slave1節(jié)點(diǎn)搭建
    • Slave2節(jié)點(diǎn)搭建
  • Windows 部署 ES集群
    • elasticsearch.yml配置修改
    • 啟動(dòng)服務(wù)
  • 注意事項(xiàng)

概述

Elasticsearch-01CentOS7單節(jié)點(diǎn)部署ES5.6.16中我們學(xué)習(xí)了ES單節(jié)點(diǎn)的部署,這里我們來(lái)看下ES集群是如何部署的吧

CentOS上部署ES集群

集群組成

  • 節(jié)點(diǎn)數(shù)量: 3個(gè) (1個(gè)Master 2個(gè)Slave)
  • OS: CentOS 7
  • IP: 192.168.91.128
  • port : master-9200 slave01-8200 slave02-7200

方便起見(jiàn),先按照偽集群模式部署吧,在同一臺(tái)主機(jī)上使用不同的端口來(lái)區(qū)分不同的節(jié)點(diǎn),當(dāng)然了你也可以使用3臺(tái)虛機(jī),那是最好不過(guò)的了


關(guān)鍵配置信息

必須保證集群名相同,如果節(jié)點(diǎn)處于同一局域網(wǎng)同一網(wǎng)段,es會(huì)自動(dòng)去發(fā)現(xiàn)其他的節(jié)點(diǎn)。

elasticsearch.yml

Master

# 綁定的服務(wù)器IP,可設(shè)置為本機(jī)IP network.host: 192.168.91.128 #啟動(dòng)的端口,默認(rèn)9200 http.port: 9200#跨域設(shè)置 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 #默認(rèn)的通訊接口是9300,用來(lái)發(fā)現(xiàn)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 #默認(rèn)的通訊接口是9300,用來(lái)發(fā)現(xiàn)master信息 discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Master節(jié)點(diǎn)搭建

修改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 # #跨域設(shè)置 http.cors.enabled: true http.cors.allow-origin: "*" #集群信息 cluster.name: artisan node.name: master node.master: true

通過(guò)head插件訪問(wèn)集群信息

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


Slave1節(jié)點(diǎn)搭建

復(fù)制一份,然后修改配置文件

[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 #默認(rèn)的通訊接口是9300,找到集群的信 discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

Slave2節(jié)點(diǎn)搭建

[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 #默認(rèn)的通訊接口是9300,用來(lái)發(fā)現(xiàn)master信息 discovery.zen.ping.unicast.hosts: ["192.168.91.128:9300"]

我這里用的虛機(jī)的內(nèi)存太小了,無(wú)法啟動(dòng)兩個(gè)及兩個(gè)以上的節(jié)點(diǎn), 為了驗(yàn)證配置的正確性,windows上部署下吧


Windows 部署 ES集群

三個(gè)節(jié)點(diǎn):


elasticsearch.yml配置修改

elasticsearch.yml的配置如下:

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

master:

# 綁定的服務(wù)器IP,可設(shè)置為本機(jī)IP network.host: 127.0.0.1 #啟動(dòng)的端口,默認(rèn)9200 http.port: 9200#跨域設(shè)置 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 #默認(rèn)的通訊接口是9300,用來(lái)發(fā)現(xiàn)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 #默認(rèn)的通訊接口是9300,用來(lái)發(fā)現(xiàn)master信息 discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"]


啟動(dòng)服務(wù)

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

通過(guò)head 插件查看 集群信息

配置OK


注意事項(xiàng)

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];

如果配到了這種錯(cuò)誤,很明顯id重復(fù)了,如果配置沒(méi)有問(wèn)題,看下你是不是直接copy的已經(jīng)存在的節(jié)點(diǎn)data目錄中的數(shù)據(jù)重復(fù)導(dǎo)致的。 建議解壓一個(gè)新的壓縮包,重新配置,避免上述錯(cuò)誤。

總結(jié)

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

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。