ES 7.6(elasticsearch)集群的搭建

注:文中es的版本:elasticsearch-7.6.1

首先,下載es安裝包:elasticsearch-7.6.1-linux-x86_64.tar.gz

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

服務器使用三臺centos虛擬機,ip列表如下:
192.168.10.181
192.168.10.182
192.168.10.183

elasticsearch安裝依賴jdk,這裡首先安裝jdk,這裡安裝步驟暫時略過。

使用hadoop用戶【儘量不要用root】解壓到opt目錄中:

<code>以下示例中安裝到/opt目錄:
/opt/elasticsearch-7.6.1/

/<code>

接著解除 Linux 系統的最大進程數和最大文件打開數限制,修改limits.conf和sysctl.conf文件,然後重啟生效。

打開/etc/security/limits.conf,添加如下內容:

<code>* soft nofile 65536
* hard nofile 65536
* soft nproc 2048
* hard nproc 4096/<code>

2.修改sysctl.conf

打開/etc/sysctl.conf,添加如下內容:

<code>vm.max_map_count=655360
fs.file-max=655360/<code>

以上操作在三臺機器中均需要操作,修改後重啟機器。

其次,在192.168.10.181機器中打開配置文件 config/elasticsearch.yml:

vi elasticsearch.yml

<code>cluster.name: test
node.name:test-node-1
path.data: /var/elasticsearch/datas/nodes
path.logs: /var/log/elasticsearch
network.host: 192.168.10.181
http.port: 9200
discovery.seed_hosts: ["192.168.10.181", "192.168.10.181", "192.168.10.181"]
cluster.initial_master_nodes: ["leyan-node-1", "leyan-node-2", "leyan-node-3"]
node.master: true
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.minimum_master_nodes: 2/<code>

192.168.10.182機器中打開配置文件 config/elasticsearch.yml:

<code>cluster.name: test
node.name:test-node-2
path.data: /var/elasticsearch/datas/nodes
path.logs: /var/log/elasticsearch
network.host: 192.168.10.182
http.port: 9200
discovery.seed_hosts: ["192.168.10.181", "192.168.10.181", "192.168.10.181"]
cluster.initial_master_nodes: ["leyan-node-1", "leyan-node-2", "leyan-node-3"]
node.master: true
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.minimum_master_nodes: 2/<code>

在192.168.10.183機器中打開配置文件 config/elasticsearch.yml:

<code>cluster.name: test
node.name:test-node-3
path.data: /var/elasticsearch/datas/nodes
path.logs: /var/log/elasticsearch
network.host: 192.168.10.183
http.port: 9200
discovery.seed_hosts: ["192.168.10.181", "192.168.10.181", "192.168.10.181"]
cluster.initial_master_nodes: ["leyan-node-1", "leyan-node-2", "leyan-node-3"]
node.master: true
node.data: true

http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.zen.minimum_master_nodes: 2/<code>


配置完成後,使用hadoop用戶【root用戶啟動會報錯,並且不建議使用root用戶】依次啟動各個機器的elasticsearch服務。



分享到:


相關文章: