目录
WIndow集群
创建elasticsearch-cluster文件夹,在内部复制三个elasticsearch服务
修改集群文件目录下每个节点的config/elasticsearch.yml配置文件
节点1的配置信息:
# 集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
# 节点名称,集群内要唯一
node.name: node-1001
# 当前节点是主节点也是数据节点
node.master: true
node.data: true
# 本机ip地址
network.host: loaclhost
# http端口
http.port: 9201
# tcp监听端口
transport.tcp.port: 9301
# 跨域配置
http.cors.enabled: true
http.cors.allow-orrigin: "*"
节点2的配置信息:
# 集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
# 节点名称,集群内要唯一
node.name: node-1002
# 当前节点是主节点也是数据节点
node.master: true
node.data: true
# 本机ip地址
network.host: loaclhost
# http端口
http.port: 9202
# tcp监听端口
transport.tcp.port: 9302
# 查找节点
discovery.seed.hosts: ["localhost:9301"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
# 跨域配置
http.cors.enabled: true
http.cors.allow-orrigin: "*"
节点3的配置信息:
# 集群名称,节点之间要保持一致
cluster.name: my-elasticsearch
# 节点名称,集群内要唯一
node.name: node-1002
# 当前节点是主节点也是数据节点
node.master: true
node.data: true
# 本机ip地址
network.host: loaclhost
# http端口
http.port: 9202
# tcp监听端口
transport.tcp.port: 9303
# 查找节点
discovery.seed.hosts: ["localhost:9301"]
discovery.zen.fd.ping_timeout: 1m
discovery.zen.fd.ping_retries: 5
# 跨域配置
http.cors.enabled: true
http.cors.allow-orrigin: "*"
Linux集群
单点部署
安装ES
下载软件解压
# 解压
tar -zxvf elasticsearch-7.8.0-linux-x84_64.tar.gz -C /opt/module
# 修名
mv elasticsearch-7.8.0 es
创建用户
因为安全问题,Elasticsearch不允许root用户直接运行,所以要创建新用户,在root用户中心创建新用户
# 新增es用户
useradd es
# 创建密码
passwd es
# 如果错了,可以删除再加
userdel -r es
# 文件夹所有者
chown -R es:es /opt/module/es
修改/opt/module/es/config/elasticsearch.yml文件
cluster.name: elasticsearch
node.name: node-1
network.host:0.0.0.0
http.port:9200
cluster.initial_master_nodes: ["node-1"]
修改/etc/security/limits.conf
# 在文件末尾中加入下面内容
# 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
# es是用户名
修改/etc/secutiry/limits.d/20-nproc.conf
# 在文件末尾中加入下面内容
# 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
# es是用户名
# 操作系统级别对每个用户创建的进程数的限制
* hard nproc 4096
# 注:* 代表Linux所有用户名称
修改/etc/sysctl.conf
# 在文件中增加下面内容
# 一个进程可以拥有的vma(虚拟内存区域)的数量,默认值为65536
vm.max_map_count=655360