博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ELK部署搭建
阅读量:2196 次
发布时间:2019-05-02

本文共 3668 字,大约阅读时间需要 12 分钟。

缘由:由于现在工作中使用了ELK作为日志收集,给研发提供查看日志情况,加上集团机房搬迁,所有服务重新迁移部署,借此机会,将ELK整个环境重新部署了一遍,以此记录一下。

ELK+kafka日志系统原理(介质为日志)

Windows/linux的logstash(客户端)--->kafka(队列)--->kakfa上的logstash(也是一个客户端)--->ES(存储)--->kibana(界面)

 

日志/消息整体流向filebeat => kafka=> logstash => elasticsearch => kibana

The Elastic Stack - 它不是个软件件,ElasticsearchLogstashKibana 开源软件的集合,对外是作为个⽇志管理系统的开源案。它可

以从任何来源,任何格式进⾏⽇志搜索,分析获取数据,并实时进行展示。像盾牌(安全),监护者(警报)和Marvel(监测)一样为你的品提供更

多的可能。

  Elasticsearch:搜索,提供分布式全搜索引擎

  Logstash: 志收集,管理,存储

  Kibana 志的过滤web 展示

  Filebeat:监控志⽂件、转发

二、环境介绍

 

1linux版本

  redhat664位)

2ELK版本

  elasticsearch5.4.1

  logstash5.4.1

  kibana5.4.1

  filebeat5.4.1

从中获取最新版软件包软件包列表:

3JAVA版本

ELK 5.x版本对JDK的最低要求是1.8

 

三、环境配置

1. jdk(删除系统自带的openjdk)

# yum -y remove java

2. 配置jdk环境变量(jdk1.8 已安装到/opt/jdk1.8 )

# vim/etc/profile.d/java.sh

exportJAVA_HOME=/opt/jdk1.8

exportPATH=$PATH:$JAVA_HOME/bin

3、引用环境变量

[root@hhh opt]#source /etc/profile.d/java.sh

[root@hhh opt]# java-version

java version"1.8.0_144"

Java(TM) SE RuntimeEnvironment (build 1.8.0_144-b01)

Java HotSpot(TM)64-Bit Server VM (build 25.144-b01, mixed mode)

4、关闭防火墙

[root@hhh opt]#chkconfig iptables off

[root@hhh opt]#chkconfig iptables --list

iptables              0:关闭        1:关闭        2:关闭        3:关闭        4:关闭        5:关闭        6:关闭

5、关闭selinux

[root@hhh opt]#setenforce 0

四、安装

1、安装Elasticsearch

1)解压

[root@hhh opt]# tar-zxvf elasticsearch-5.4.1.tar.gz

2)编辑配置

[root@hhh opt]# vimelasticsearch-5.4.1/config/elasticsearch.yml

network.host:172.20.0.5

http.port: 9200

http.cors.enabled:true

http.cors.allow-origin:"*"

bootstrap.system_call_filter:false

3) 修改系统最⼤⽂件数和进程数

[root@hhh opt]#  vim /etc/security/limits.conf

* hard nproc 65536

* soft nproc 65536

* hard nofile 65536

* soft nofile 65536

 

[root@hhh opt]# vim/etc/security/limits.d/90-nproc.conf

* soft nofile 65536

* soft nproc 65536

 

[root@hhh opt]#  vim /etc/sysctl.conf

vm.max_map_count=655360

 

4) 启动命令(root权限启动)

新建运行用户

[root@hhh opt]#useradd elasticsearch

[root@hhhopt]# passwd elasticsearch

启动

[root@hhh opt]#./elasticsearch-5.4.1/bin/elasticsearch -d

如果报错:

main ERROR Could not register mbeansjava.security.AccessControlException: access denied("javax.management.MBeanTrustPermission" "register")

改变elasticsearch文件夹所有者到当前用户

sudo chown -R noroot:noroot elasticsearch

查看启动,查看监听端口:

curl测试:

2. 安装elasticsearch-head插件

1)安装node(解析环境和java一样) npm(类似于mvn打包)

下载地址:https://nodejs.org/en/download/

配置:

[root@hhhprofile.d]# vim /etc/profile.d/node.sh

exportNODE_HOME=/opt/node 

exportPATH=$PATH:$NODE_HOME/bin 

exportNODE_PATH=$PATH:$NODE_HOME/lib/node_modules

2)安装grunt

# vim ~/.npmrc

registry =

strict-ssl = false

npminstall –g grunt–cli

3)下载head二进制包

#wget

4)解压

[root@hhh opt]#unzip elasticsearch-head-master.zip

[root@hhh opt]# cdelasticsearch-head-master

npm依赖安装

[root@hhhelasticsearch-head-master]# npm install (超时请设置代理

npm config set proxy

npmconfig set https-proxy )

如果速度较慢或者安装失败,可以使用国内镜像:

npminstall -g cnpm --registry=https://registry.npm.taobao.org

5)修改Elasticsearch配置文件

编辑elasticsearch-5.1.1/config/elasticsearch.yml,加入以下内容:

http.cors.enabled:true

http.cors.allow-origin: "*"

6)修改Gruntfile.js

找到下面connect属性,新增hostname:

connect: {

 server: {

 options: {

 hostname: “IP",

 port: 9100,

 base: '.',

 keepalive: true

 }

 }

}

7)启动命令(也可以后台启动

[root@hhhelasticsearch-head-master]# ./node_modules/grunt/bin/grunt server

8)访问9100端口:

后台启动操作:

nohup grunt server & exit

如果想关闭head插件,使用linux查找进程命令:

ps aux|grep head

结束进程

Kill 进程号

 

3、安装kinana

1)解压

[root@hhh opt]# tar-zxvf kibana-5.4.1-linux-x86_64.tar.gz

2)配置

server.port: 5601

server.host:“IP"

elasticsearch.url:""

3)启动

./bin/kibana

4)查看端口监听情况

5)查看页面

4、安装logstash(如果filebeat 直接输⼊到elasticsearch 则不⽤安装

1)解压

[root@hhh opt]# tar-zxvf logstash-5.4.1.tar.gz

2)配置

制定一个模板

<<web.conf>>

3)启动

./bin/logstash-f config/web.conf

 

转载地址:http://ompub.baihongyu.com/

你可能感兴趣的文章
如何分析SQL语句
查看>>
结构化查询语言(SQL)原理
查看>>
SQL教程之嵌套SELECT语句
查看>>
日本語の記号の読み方
查看>>
计算机英语编程中一些单词
查看>>
JavaScript 经典例子
查看>>
判断数据的JS代码
查看>>
js按键事件说明
查看>>
AJAX 初次体验!推荐刚学看这个满好的!
查看>>
AJAX 设计制作 在公司弄的 非得要做出这个养的 真晕!
查看>>
Linux 查看文件大小
查看>>
Java并发编程:线程池的使用
查看>>
redis单机及其集群的搭建
查看>>
Java多线程学习
查看>>
检查Linux服务器性能
查看>>
Java 8新的时间日期库
查看>>
Chrome开发者工具
查看>>
【LEETCODE】102-Binary Tree Level Order Traversal
查看>>
【LEETCODE】106-Construct Binary Tree from Inorder and Postorder Traversal
查看>>
【LEETCODE】202-Happy Number
查看>>