Centos7部署elasticsearch7.6.0集群

环境

系统:centos7.5,全部采用最小化安装,防火墙,selinux默认全部关闭

系统IP地址内存大小
centos7.5192.168.7.5016G
centos7.5192.168.7.5116G
centos7.5192.168.7.5216G

elasticsearch:7.6.0
安装包:下载地址中心
本次安装方式:rpm
下载网站预览
通过xftp上传安装包到各台主机上,之后分别在三台主机上使用rpm -ivh 命令安装elasticsearch

1、三台主机分别安装elasticsearch

rpm -ivh elasticsearch-7.6.0-x86_64.rpm

2、去掉LINUX系统对elasticsearch 用户的内存大小和文件句柄限制等限制,不然会报错,无法启动

echo 'elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
' >> /etc/security/limits.conf

3、修改各自配置文件
192.168.7.50

# 集群名称
cluster.name: es-cluster
# 集群节点名称
node.name: 192.168.7.50
# data存储路径
path.data: /data/elasticsearch
# 日志存储路径
path.logs: /var/log/elasticsearch
#bootstrap.memory_lock: true
# 监听网卡地址
network.host: 192.168.7.50
# 监听端口
http.port: 9200
# 初始集群master节点地址
cluster.initial_master_nodes: ["192.168.7.50"]
# 此节点是否存数据
node.data: true
# 此节是否可以竞选master
node.master: true
# 设置集群中的其它主机地址,默认通过9300端口互相通讯
discovery.zen.ping.unicast.hosts: ["192.168.7.50:9300","192.168.7.51:9300","192.168.7.52:9300"]
# 是否允许跨域访问,涉及elasticsearch-head等工具的访问
http.cors.enabled: true
http.cors.allow-origin: "*"

192.168.7.51

cluster.name: es-cluster
node.name: 192.168.7.51
path.data: /data/elasticsearch
path.logs: /var/log/elasticsearch
#bootstrap.memory_lock: true
network.host: 192.168.7.51
http.port: 9200
cluster.initial_master_nodes: ["192.168.7.50"]
node.data: true
node.master: true
discovery.zen.ping.unicast.hosts: ["192.168.7.50:9300","192.168.7.51:9300","192.168.7.52:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"

192.168.7.52

cluster.name: es-cluster
node.name: 192.168.7.52
path.data: /data/elasticsearch
path.logs: /var/log/elasticsearch
#bootstrap.memory_lock: true
network.host: 192.168.7.52
http.port: 9200
cluster.initial_master_nodes: ["192.168.7.50"]
node.data: true
node.master: true
discovery.zen.ping.unicast.hosts: ["192.168.7.50:9300","192.168.7.51:9300","192.168.7.52:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"

3、创建data目录,并授权

mkdir -p /data/elasticsearch
chown elasticsearch.elasticsearch /data/elasticsearch

4、关闭所有台服务器的swap,swap一旦被使用,严重拖慢服务器速度。

swapoff -a 
sed -i 's/.*swap.*/#&/' /etc/fstab

5、修改各自的jvm大小,修改成如下状态,jvm大小一般取内存大小一半

grep Xm /etc/elasticsearch/jvm.options 
	## -Xms4g
	## -Xmx4g
	# Xms represents the initial size of total heap space
	# Xmx represents the maximum size of total heap space
	-Xms8g
	-Xmx8g

6、启动各自的elasticsearch,并设置开机自启

systemctl  enable elasticsearch && systemctl  restart elasticsearch.service

# 查看启动日志,日志文件名称为集群名称,目录为配置文件中设置的路径
tail -f /var/log/elasticsearch/es-cluster.log

7、验证启动情况:

[root@elasticsearch-7-50~]# curl 192.168.7.50:9200
{
  "name" : "192.168.7.50",
  "cluster_name" : "es-cluster",
  "cluster_uuid" : "W2IM207ST32ybjMokdPj5w",
  "version" : {
    "number" : "7.6.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
    "build_date" : "2020-02-06T00:09:00.449973Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[root@elasticsearch-7-50 ~]# curl 192.168.7.51:9200
{
  "name" : "192.168.7.52",
  "cluster_name" : "es-cluster",
  "cluster_uuid" : "W2IM207ST32ybjMokdPj5w",
  "version" : {
    "number" : "7.6.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
    "build_date" : "2020-02-06T00:09:00.449973Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[root@elasticsearch-7-50 ~]# curl 192.168.7.52:9200
{
  "name" : "192.168.7.52",
  "cluster_name" : "es-cluster",
  "cluster_uuid" : "W2IM207ST32ybjMokdPj5w",
  "version" : {
    "number" : "7.6.0",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
    "build_date" : "2020-02-06T00:09:00.449973Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

出现类似上述界面说明集群搭建成功!!!

标志:所有es都获取到相同的集群UUID,如:"cluster_uuid" : "W2IM207ST32ybjMokdPj5w"

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值