ELK搭建 手把手引导

ES:

1、下载安装包并解压
tar -zxvf elasticsearch-8.1.3-linux-x86_64.tar.gz
2、修改配置文件
cluster.name: es-application
node.name: node1
#对所有IP开放
network.host: 0.0.0.0
#HTTP端口号
http.port: 9200
#elasticsearch数据文件存放目录
path.data: /home/kbj/elasticsearch/data
#elasticsearch日志文件存放目录
path.logs: /home/kbj/elasticsearch/logs

xpack.security: 
  enabled: false
xpack.security.http.ssl:
  enabled: false
xpack.security.transport.ssl:
  enabled: false

# 对kibana或有集群时配置对应ip
discovery.seed_hosts: ["10.1.59.125"]
cluster.initial_master_nodes: ["node1"]

# 开启跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
3、 因为ElasticSearch使用非root用户启动,所以创建一个用户
# 创建用户
useradd testuser
# 设置密码
passwd testuser
# 赋予用户权限
chown -R testuser:testuser /usr/elasticsearch/
4、切换到普通用户并启动

./bin/elasticsearch -d

使用ps -ef | grep elasticsearch 查看是否有进程启动

这时候可能会报错:

bootstrap check failure [1] of [2]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
bootstrap check failure [2] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

a:使用root用户修改 /etc/security/limits.conf ,添加(此段配置间隔统一用空格,否则有可能不生效):

testuser soft nofile 65536
testuser hard nofile 65536
testuser soft nproc 4096
testuser hard nproc 4096

退出重新登录你刚创建的普通用户,使用以下命令可查看是否配置成功

$ ulimit -Hn
65536
$ ulimit -Sn
65536

b:使用root用户 vi /etc/sysctl.conf,添加 vm.max_map_count=655360 ,然后使用 sysctl -p 以生效

logstash:

1、下载并解压

tar -zxvf logstash-8.1.3-linux-x86_64.tar.gz

2、新增一个日志输入输出规则文件log.config
input {
    file {  
        path => "/home/kbj/apps/logs/api_test/*.log"  
        type => 'api_log'
        start_position => beginning
    }
}

output {
    elasticsearch {
        hosts => "10.1.59.128:9200"
        index => "uapi_log-%{+YYYY.MM.dd}"
    }
}
3、启动并检查
# 启动
$ nohup ./bin/logstash -f log.config &

#检查有无ERROR日志并解决
$ tail -100f nohup.out

# 检查进程是否已启动
$ ps -ef | grep logstash

kibana:

1、下载并解压

tar -zxvf kibana-8.1.3-linux-x86_64.tar.gz

2、修改配置./config/kibana.yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://10.1.59.128:9200"]
3、启动并检查
# 启动
$ nohup ./bin/kibana &

#检查有无ERROR日志并解决
$ tail -100f nohup.out

浏览器访问http://ip:5601/,注意关闭服务器防火墙或者针对网段配置

4、建立匹配规则

在这里插入图片描述
在这里插入图片描述

5、在 Discover 菜单查看数据
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值