k8s-部署elk日志系统
1. k8s-部署elk日志系统
-
安装JDK
[root@linux-node1 ~]# rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm [root@linux-node1 ~]# yum install java-1.8.0-openjdk –y [root@linux-node1 ~]# java -version openjdk version "1.8.0_65" OpenJDK Runtime Environment (build 1.8.0_65-b17) OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)
-
Elasticsearch部署
Elasticsearch首先需要Java环境,所以需要提前安装好JDK,可以直接使用yum安装。也可以从Oracle官网下载JDK进行安装。开始之前要确保JDK正常安装并且环境变量也配置正确:
-
下载并安装GPG key
[root@elk-stack-01 elk]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
-
添加yum仓库
[root@elk-stack-02 config]# vim /etc/yum.repos.d/elasticsearch.repo [root@elk-stack-02 config]# cat /etc/yum.repos.d/elasticsearch.repo [elasticsearch] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=0 autorefresh=1 type=rpm-md
-
安装elasticsearch
[root@elk-stack-01 elk]# yum install --enablerepo=elasticsearch elasticsearch
-
启动
[root@elk-1 ~]#systemctl start elasticsearch.service
-
设置开机启动
[root@elk-1 ~]#/bin/systemctl daemon-reload [root@elk-1 ~]#/bin/systemctl enable elasticsearch
-
-
安装logstash部署与配置
和elasticsearch一样,在开始部署logStash之前也需要你的环境中正确的安装的jdk。可以下载安装oracle的jdk或者使用yum安装openjdk-
下载并安装GPG key
[root@elk-1 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
-
添加yum仓库
[root@elk-1 ~]# vim /etc/yum.repos.d/logstash.repo [root@elk-1 ~]# cat /etc/yum.repos.d/logstash.repo [logstash-7.x] name=Elastic repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
-
安装logstash
[root@elk-1 ~]# yum install -y logstash
-
启动
[root@elk-1 ~]#/bin/systemctl daemon-reload [root@elk-1 ~]#systemctl start logstash.service
-
设置开机启动
[root@elk-1 ~]#/bin/systemctl enable logstash
-
-
kibana 简介
kibana是为elasticsearch设计的开源分析和可视化平台。你可以使用kibana来搜索,查看存储在elasticsearch索引中的数据并与之交互。你可以很容易实现高级的数据分析和可视化,以图表的形式展现出来。
-
下载并安装GPG key
[root@elk-1 ~]# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
-
添加yum仓库
[root@elk-1 ~]# vim /etc/yum.repos.d/kibana.repo [root@elk-1 ~]# cat /etc/yum.repos.d/kibana.repo [kibana-7.x] name=Kibana repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
-
安装kibana
[root@elk-1 ~]# yum install -y kibana
-
启动
[root@elk-1 ~]#/bin/systemctl daemon-reload [root@elk-1 ~]# /bin/systemctl start kibana
-
设置开机启动
[root@elk-1 ~]#/bin/systemctl enable kibana
-
-
安装Beats的Filebeat收集日志插件
filebeat主要是,来收集客户端日志,并把收集日志发送到logstash进行日志分析,在让kebana做分析
-
下载并安装GPG key
[root@elk-1 ~]# rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
-
添加yum仓库
[root@jenkins-master ~]# vim /etc/yum.repos.d/filebeat.repo [root@jenkins-master ~]# cat /etc/yum.repos.d/filebeat.repo [elastic-7.x] name=Elastic repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
-
安装filebeat插件
[root@elk-1 ~]# yum install -y filebeat
-
启动
[root@elk-1 ~]#systemctl start filebeat
-
设置开机启动
[root@elk-1 ~]#systemctl enable filebeat
-