Linux——ELK集群搭建
1、ES基础环境搭建
一、下载并安装GPG KEY
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
二、添加yum仓库
vim /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseUrl=http://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
其中gpgcheck是检测其有没有GPG-KEY,保证他没被别人串改
有了yum源,刷新下
yum makecache
三、安装elasticsearch
yum install -y elasticsearch redis nginx java
redis说明收集日志的时候需要缓存
java说明用java编写的
四、安装相关测试软件
下载安装epel源:epel-release-latest-7.noarch.rpm
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
五、测试java环境
Java -version
需要安装jdk可以查看https://www.cnblogs.com/su-ke/p/13851104.html
六、配置部署
elk-node1的配置\
1、修改配置文件
#自定义日志存储目录
mkdir -p /data/es-data
vim /etc/elasticsearch/elasticsearch.yml //追加配置下面内容
#组名(同一组,组名必须一致)
cluster.name: iot-paas
#结点名称(建议和主机名一致)
node.name:elk-node1
#数据存放的路径 (别人的日志)
path.data:/data/es-data
#日志存放的路径 (自己的日志)
path.logs:/var/log/elasticsearch/
#锁住内存,不被使用到交换分区法(通常在内存不足时,休眠的程序内存信息会交换到交换分区)
bootstrap.memory_lock:true
network.host:0.0.0.0 #网络设置
http.port:9200 #端口
elk-node2的配置
discovery.zen.ping.multicast.enabled: false #关闭多播
discovery.zen.ping.unicast.hosts: ["ip1", "ip2"]
给es文件赋权限
chown -R elasticsearch.elasticsearch /data/
systemctl start elasticsearch.service
systemctl enable elasticsearch.service
systemctl status elasticsearch
web页面测试下,http://服务器ip+端口
安装插件1:查看
/usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head
chown -R elasticsearch.elasticsearch /usr/share/elasticsearch/plugins
systemctl restart elasticsearch
web页面测试下,http://服务器ip+端口/_plugin/head/
安装插件2:管理
/usr/share/elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf
chown -R elasticsearch.elasticsearch /usr/share/elasticsearch/plugins
systemctl restart elasticsearch
web页面测试下,http://服务器ip+端口/_plugin/kopf/#!/cluster
ps
aux |
grep
elasticsearch
查看es版本
Logstash
需要部署在应用服务器上
下载并安装GPG KEY
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
vim /etc/yum.repos.d/logstash.repo
[logstash-2.1]
name=Logstash repository for 2.1.x packages
baseurl=http://packages.elastic.co/logstash/2.1/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
yum install -y logstash