ELK部署搭建

缘由:由于现在工作中使用了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

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

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.1.tar.gz

https://artifacts.elastic.co/downloads/kibana/kibana-5.4.1-linux-x86_64.tar.gz

https://artifacts.elastic.co/downloads/logstash/logstash-5.4.1.tar.gz

https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.4.1-linux-x86_64.tar.gz

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 = https://registry.npm.taobao.org/

strict-ssl = false

npminstall –g grunt–cli

3)下载head二进制包

#wget https://codeload.github.com/mobz/elasticsearch-head/zip/master

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 proxyhttp://server:port

npmconfig set https-proxy http://server:port

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

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:"http://IP:9200"

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

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值