• ELKStack之使用Redis作为消息队列


    redis消息队列

    安装redis

    yum -y install redis

    修改配置文件

    修改ip

    后台运行

    启动

    systemctl start redis

    查看

    lsof -i:6379

    连接

    redis-cli -h 10.13.85.9

    cd /etc/logstash/conf.d/

    vim redis.conf

    input{
        stdin {}
    }
    
    output{
        redis{
        	host => "10.13.85.9"
    	port => "6379"
    	db => "6"
    	data_type => "list"
    	key => "demo"
        }
    }
    

    启动

    /opt/logstash/bin/logstash -f redis.conf

    另外开一个窗口启动redis连接

    redis-cli -h 10.13.85.9

    select 6

    验证可以写一个收集apache日志的配置文件

    vim apache.conf

    input{
        file{
            path => "/var/log/httpd/access_log"
            start_position => "beginning"
        }
    }
    output{
        redis{
            host => "10.13.85.9"
            port => "6379"
            db => "6"
            data_type => "list"
            key => "apache-accesslog"
        }
    }
    

    启动

    /opt/logstash/bin/logstash -f apache.conf

    查看最好一行

    生产中可以在另外一台服务器启动一个logstash收集redis里面的数据

    在另外服务器上面

    vim /etc/logstash/conf.d/indexer.conf

    input{
        redis{
        	host => "10.13.85.9"
    	port => "6379"
    	db => "6"
    	data_type => "list"
    	key => "demo"
        }
    
    }
    
    output{
        stdout{
        	codec => rubydebug
        }
    }
    

    启动如果成功了加filter处理apache

    input{
        redis{
        	host => "10.13.85.9"
    	port => "6379"
    	db => "6"
    	data_type => "list"
    	key => "demo"
        }
    }
    
    filter{
        grok{
            match => { "message" => "%{COMBINEDAPACHELOG}" }
        }
    
    }
    
    
    output{
        elasticsearch{
        	hosts => ["10.13.85.9:9200"]
    	index => "apache-accesslog-%{+YYYY.MM.dd}"
        }
    }
    

    启动

    /opt/logstash/bin/logstash  -f indexer.conf

    作业:消息队列kafka

  • 相关阅读:
    CSS学习笔记07 盒子模型
    [Android]AndFix使用说明
    [Android]自定义控件LoadMoreRecyclerView
    [算法]Plus One
    [Android]android Service后台防杀
    [Android]android studio预览视图时报错
    [算法]删除无序单链表中值重复出现的节点
    [算法] 将单链表的每K个节点之间逆序
    [Android]热修复框架AndFix测试说明
    [算法]单链表的选择排序
  • 原文地址:https://www.cnblogs.com/minseo/p/7092164.html
Copyright © 2020-2023  润新知