EFK 环境搭建

1、环境准备

-rw-r--r-- 1 root root 318808405 Jan 17 19:50 elasticsearch-7.10.2-linux-x86_64.tar.gz
-rw-r--r-- 1 root root    921421 Jan 26 20:51 elasticsearch-head-master.zip
-rw-r--r-- 1 root root  34059708 Jan 17 19:48 filebeat-7.10.2-linux-x86_64.tar.gz
-rw-r--r-- 1 root root 249171053 Jan 18 19:36 kibana-7.10.2-linux-x86_64.tar.gz  
-rw-r--r-- 1 root root  21390448 Jan 25 21:37 node-v14.15.4-linux-x64.tar.xz
-rw-rw-r-- 1 root root  34059708 Jan 19 19:21 filebeat-7.10.2-linux-x86_64.tar.gz
-rw-rw-r-- 1 root root 249171053 Jan 20 21:43 kibana-7.10.2-linux-x86_64.tar.gz

2、部署 java 环境

Elasticsearch 的运行需要 java 环境

[root@VM-0-15-centos java]# tar -zxvf jdk-8u271-linux-x64.tar.gz -C /usr/local/

编辑 /etc/profile,修改环境变量

[root@VM-0-15-centos java]# vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_271
export JRE_HOME=/usr/local/jdk1.8.0_271/jre
export CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
[root@VM-0-15-centos efk]# source /etc/profile

3、部署 elasticsearch

  1. 解压
[root@VM-0-15-centos efk]# tar -zxvf elasticsearch-7.10.2-linux-x86_64.tar.gz
[root@VM-0-15-centos efk]# mv elasticsearch-7.10.2 /usr/local/elasticsearch
  1. Elasticsearch 使用 root 用户启动会报错,创建一个普通用户来启动 Elasticsearch
[root@VM-0-15-centos efk]# useradd elastic
  1. 修改 elasticsearch 目录的属主和属组
[root@VM-0-15-centos efk]# cd /usr/local
[root@VM-0-15-centos efk]# chown -R elastic.elastic elasticsearch
  1. 修改配置文件
[root@VM-0-15-centos efk]# vim elasticsearch/config/elasticsearch.yml
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: '*'
cluster.initial_master_nodes: ["node-1"]
  1. 切换为普通用户,尝试启动:
[root@VM-0-15-centos efk]# su - elastic
[elastic@VM-0-15-centos elasticsearch]$ cd /usr/local/elasticsearch/bin
[elastic@VM-0-15-centos bin]$ ./elasticsearch
  1. 启动异常处理

elasticserach部署的时候,日志 WARN 部分显示的警告信息,有时候会升级为 ERROR,然后服务就启不起来;

错误1:

ERROR:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535];

解决办法:

[root@VM-0-15-centos efk]# vim /etc/security/limits.conf 
#在配置文件中添加如下参数:
* soft nofile 65535 
* hard nofile 65535

错误2:

ERROR:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决办法:

[root@VM-0-15-centos efk]# vim /etc/sysctl.conf
## 在配置文件中添加如下参数:
vm.max_map_count=262144

执行命令:

[root@VM-0-15-centos efk]# sysctl -p
  1. 修改占用内存大小
[root@VM-0-15-centos config]# vim jvm.options
#Xms表示总堆空间的初始大小
#Xmx表示总堆空间的最大大小
-Xms512m
-Xmx512m
  1. 本地测试
[root@VM-0-15-centos config]# curl '127.0.0.1:9200'
{
  "name" : "node-1",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "EE2LTXCHSJS9K-cgOHB3jQ",
  "version" : {
    "number" : "7.10.2",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "747e1cc71def077253878a59143c1f785afa92b9",
    "build_date" : "2021-01-13T00:42:12.435326Z",
    "build_snapshot" : false,
    "lucene_version" : "8.7.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
  1. 设置 elasticsearch 为后台启动,并指定 PID 文件
[elastic@VM-0-15-centos bin]$ ./elasticsearch -p ./elasticsearch-pid -d

4、部署 kibana

  1. 解压
[root@VM-0-15-centos efk]# tar -zxvf kibana-7.10.2-linux-x86_64.tar.gz
[root@VM-0-15-centos efk]# mv kibana-7.10.2-linux-x86_64 /usr/local/kibana
  1. 修改配置文件
[root@VM-0-15-centos efk]# cd /usr/local/kibana/
[root@VM-0-15-centos kibana]# vim config/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
kibana.index: ".kibana"
  1. 启动 kibana
[root@VM-0-15-centos kibana]# cd bin
[root@VM-0-15-centos bin]# ./kibana
  1. 后台启动
[root@VM-0-15-centos bin]# nohup ./kibana &

在这里插入图片描述

  1. 后台停止
fuser -n tcp 5601
kill -9  端口

5、部署 filebeat

  1. 解压
[root@VM-0-15-centos efk]# tar -zxvf filebeat-7.10.2-linux-x86_64.tar.gz
[root@VM-0-15-centos efk]# mv filebeat-7.10.2-linux-x86_64 /usr/local/filebeat
  1. 编辑配置文件
[root@VM-0-15-centos efk]# cd /usr/local/filebeat
[root@VM-0-15-centos filebeat]# vim filebeat.yml
filebeat.inputs:
- type: log
  paths:
          - /home/spring/*.log
  multiline.pattern: '^\d{4}\-\d{2}\-\d{2}\s\d{2}:\d{2}:\d{2}'
  multiline.negate: true #多行匹配模式后配置的模式是否取反,默认false
  multiline.match: after #定义多行内容被添加到模式匹配行之后还是之前,默认无,可以被设置为after或者before

setup.kibana:
  host: "localhost:5601"

output.elasticsearch:
  hosts: ["localhost:9200"]
  1. 后台启动 filebeat
[root@VM-0-15-centos filebeat]# nohup ./filebeat -c filebeat.yml &

6、部署 elasticsearch-head

6.1部署nginx
  1. 解压
[root@VM-0-15-centos efk]# tar -zxvf node-v14.15.4-linux-x64.tar.xz -C  /usr/local/node
  1. 编辑 /etc/profile,修改环境变量
[root@VM-0-15-centos java]# vim /etc/profile
export NODE_HOME=/usr/local/node/node-v14.15.4-linux-x64
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$NODE_HOME/bin
[root@VM-0-15-centos efk]# source /etc/profile
  1. 安装cnpm
npm install -g cnpm -- registry=https:// registry . npm. taobao. org
6.2 部署elasticsearch-head
  1. 新建组件文件夹
    7.10.2版本的elasticsearch 不允许将组件安装在elasticsearch下的plugins目录
    我们需要新建目录
[root@VM-0-15-centos elasticsearch]# mkdir assembly
  1. 将解压好的 elasticsearch-head-master文件放入assembly

3.修改配置文件

[root@VM-0-15-centos elasticsearch-head-master]# vim Gruntfile.js

 	connect: {
                        server: {
                                options: {
                               			 # 添加hostname
                                        hostname:'*',
                                        port: 9100,
                                        base: '.',
                                        keepalive: true
                                }
                        }
                }
  1. 安装依赖
[root@VM-0-15-centos elasticsearch-head-master]# cnpm install
  1. 启动
[root@VM-0-15-centos elasticsearch-head-master]# cnpm run star

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值