CentOS7下搭建多节点Elasticsearch集群

CentOS7下搭建多节点Elasticsearch集群

三个CentOS服务器主机与IP地址映射为:
kafka1 10.177.33.45
kafka2 10.177.33.46
kafka3 10.177.33.47
ELK系统:Elasticserach和filebeat分别部署在三台服务器上,Elasticsearch-head,logstash,Kibana部署在kafka3上,可以把kafka1和kafka2看作生产服务器,file beat负责采集数据,传输到应用服务器kafka3上对数据进行过滤存储展示,kafka3上的filebeat同样可以采集数据。分为生产服务器和应用服务器是因为filebeat占用内存少,而logstash占用内存大,这样部署可以减轻生产服务器的压力。

CentOS7下安装Elasticsearch-7.3.2搭建方法:
https://blog.csdn.net/zhengzaifeidelushang/article/details/102482562
重要注意事项:搭建时候遇到的坑,必须在每个虚拟服务器上解压Elasticsearch压缩包安装,不能在一个服务器安装成功后,直接通过scp发送Elasticsearch安装包到另外两个服务器,因为目录中data和log会保存数据信息,造成节点无法自动加入es集群

Elasticsearch配置文件

10.177.33.45节点Elasticsearch配置文件

cluster.name: AAC-esuser
node.name: kafka1
node.master: true
node.data: true
network.host: 10.177.33.45
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["10.177.33.45:9300", "10.177.33.46:9300", "10.177.33.47:9300"]
cluster.initial_master_nodes: ["kafka1", "kafka2", "kafka3"]
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping_timeout: 1m
http.cors.enabled: true
http.cors.allow-origin: "*"

10.177.33.46节点Elasticsearch配置文件

cluster.name: AAC-esuser
node.name: kafka2
node.master: true
node.data: true
network.host: 10.177.33.46
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["10.177.33.45:9300", "10.177.33.46:9300", "10.177.33.47:9300"]
cluster.initial_master_nodes: ["kafka1", "kafka2", "kafka3"]
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping_timeout: 1m
http.cors.enabled: true
http.cors.allow-origin: "*"

10.177.33.47节点Elasticsearch配置文件

cluster.name: AAC-esuser
node.name: kafka3
node.master: true
node.data: true
network.host: 10.177.33.47
http.port: 9200
transport.tcp.port: 9300
discovery.seed_hosts: ["10.177.33.45:9300", "10.177.33.46:9300", "10.177.33.47:9300"]
cluster.initial_master_nodes: ["kafka1", "kafka2", "kafka3"]
discovery.zen.minimum_master_nodes: 2
discovery.zen.ping_timeout: 1m
http.cors.enabled: true
http.cors.allow-origin: "*"

启动es集群

1.修改elasticsearch-head配置文件
修改如下内容
this.base_uri = this.config.base_uri || this.prefs.get(“app-base_uri”) || “http://10.177.33.47:9200”

vim _site/app.js

services.Cluster = ux.Class.extend({
	defaults: {
		base_uri: null
	},
	init: function() {
		this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://10.177.33.47:9200";
		},

2.搭建成功后,分别在三台服务器elasticsearch的bin目录下启动elasticsearch

./elasticsearch

3.kafka3上启动elasticsearch-head

grunt server

启动成功后如图所示

kafka3被选为主节点,kafka1、kafka2、kafka3都为数据节点可以存储数据
CentOS7下搭建多节点Elasticsearch集群_第1张图片

你可能感兴趣的:(ELK)