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服务。



分享到:


相關文章: