[转] flume使用(六):后台启动及日志查看
【From】 https://blog.csdn.net/maoyuanming0806/article/details/80807087
处理的问题
flume 普通方式启动会有自己自动停掉的问题,这可能是linux的进程机制把他停掉的原因。
普通运行方式:
./flume-ng agent -c ../conf -f ../conf/g01-taildir-avro-sink.conf -n agent1 -Dflume.root.logger=INFO,console
flume后台运行
nohup加在原命令头,&加在原命令尾部
nohup ./flume-ng agent -c ../conf -f ../conf/g01-taildir-avro-sink.conf -n agent1 -Dflume.root.logger=INFO,console &
有人说直接加 & 就可以了,对,但是再加上nohup可以把原本在console输出的运行日志输出在nohup.out中
flume运行日志查看
这里介绍两种方式
nohup后台启动查看控制台日志
以nohup 和 & 组合的运行方式,会将原本在console的输出定向到flume的bin目录下的nohup.out文件中。
大多flume博文都有介绍flume的启动命令,但是命令都是将运行日志打印在控制台,这是入门级的demo运行方式,实际上flume原本就配置了运行日志输出位置,如下小节说明
flume运行日志根据log4j.properties配置输出
在flume的配置文件目录及 conf 目录中有log4j.properties配置文件,其实就已经配置了flume启动日志输出位置。
【log4j.prpoerties】
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# # Define some default values that can be overridden by system properties.
#
# For testing, it may also be convenient to specify
# -Dflume.root.logger=DEBUG,console when launching flume. #flume.root.logger=DEBUG,console
flume.root.logger=INFO,LOGFILE
flume.log.dir=./logs
flume.log.file=flume.log log4j.logger.org.apache.flume.lifecycle = INFO
log4j.logger.org.jboss = WARN
log4j.logger.org.mortbay = INFO
log4j.logger.org.apache.avro.ipc.NettyTransceiver = WARN
log4j.logger.org.apache.hadoop = INFO
log4j.logger.org.apache.hadoop.hive = ERROR # Define the root logger to the system property "flume.root.logger".
log4j.rootLogger=${flume.root.logger} # Stock log4j rolling file appender
# Default log rotation configuration
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.LOGFILE.MaxFileSize=100MB
log4j.appender.LOGFILE.MaxBackupIndex=
log4j.appender.LOGFILE.File=${flume.log.dir}/${flume.log.file}
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%t] (%C.%M:%L) %x - %m%n # Warning: If you enable the following appender it will fill up your disk if you don't have a cleanup job!
# This uses the updated rolling file appender from log4j-extras that supports a reliable time-based rolling policy.
# See http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/rolling/TimeBasedRollingPolicy.html
# Add "DAILY" to flume.root.logger above if you want to use this
log4j.appender.DAILY=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.DAILY.rollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
log4j.appender.DAILY.rollingPolicy.ActiveFileName=${flume.log.dir}/${flume.log.file}
log4j.appender.DAILY.rollingPolicy.FileNamePattern=${flume.log.dir}/${flume.log.file}.%d{yyyy-MM-dd}
log4j.appender.DAILY.layout=org.apache.log4j.PatternLayout
log4j.appender.DAILY.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} %-5p [%t] (%C.%M:%L) %x - %m%n # console
# Add "console" to flume.root.logger above if you want to use this
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d (%t) [%p - %l] %m%n
然而大多博文的命令都是如此:……. -Dflume.root.logger=INFO,console
./flume-ng agent -c ../conf -f ../conf/g01-taildir-avro-sink.conf -n agent1 -Dflume.root.logger=INFO,console
其中 -Dflume.root.logger=INFO,console
就表示将运行日志输出到控制台。
那么把该条删除就可以按照log4j的配置输出到对应日志文件中
注意,如果没有输出到对应日志文件,那么看下flume的lib包中是否含有log4j的依赖jar包
log4j-1.2..jar
slf4j-api-1.6..jar
slf4j-log4j12-1.6..j
---------------------
作者:maoyuanming0806
来源:CSDN
原文:https://blog.csdn.net/maoyuanming0806/article/details/80807087
版权声明:本文为博主原创文章,转载请附上博文链接!
[转] flume使用(六):后台启动及日志查看的更多相关文章
- 尝试解决IDea 启动项目后,后台疯狂输出日志。
今天启动项目的时候,昨天下班前还好好,然后今天就炸了.后台疯狂输出日志.. 就类似这种,大批量的刷.其实项目已经正常启动了,就是疯狂的刷日志. 2019-03-29 08:42:53 [DEBUG] ...
- 【Linux.Python】Python进程后台启动
嗯,比较忧伤. 前几天写了个tornado,启动了,很开心,后来每天要用时都发现it是kill掉的.好吧,是我太蠢啦.百度了下资料 python的启动方式: 1 python yourfile.py ...
- jar包后台启动--nohup篇
直接java -jar TestHttps-0.0.1-SNAPSHOT.jar的话是前段启动,但是窗口关闭之类的程序也就关闭了 我们可以nohup java -jar TestHttps-0.0.1 ...
- linux下后台启动springboot项目
linux下后台启动springboot项目 我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn p ...
- springboot:基础学习一 linux下后台启动springboot项目
我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn package”进行打包时,会打包成一个可以直接 ...
- 后台启动es head,关闭shell后es head自动关闭
后台启动head命令:grunt server & 注意:加上&虽然执行了后台启动,但还是有日志打印出来,使用ctrl+c可以退出.这时如果直接关闭shell, head进程就会终止 ...
- linux下后台启动springboot项目(转载)
我们知道启动springboot的项目有三种方式: 运行主方法启动 使用命令 mvn spring-boot:run”在命令行启动该应用 运行“mvn package”进行打包时,会打包成一个可以直接 ...
- flink---实时项目--day01--1. openrestry的安装 2. 使用nginx+lua将日志数据写入指定文件中 3. 使用flume将本地磁盘中的日志数据采集到的kafka中去
1. openrestry的安装 OpenResty = Nginx + Lua,是⼀一个增强的Nginx,可以编写lua脚本实现⾮非常灵活的逻辑 (1)安装开发库依赖 yum install -y ...
- 后台启动weblogic成功后,在web浏览器上无法访问
后台启动weblogic成功后,在web浏览器上无法访问,可尝试重启服务器.
随机推荐
- Linux的磁盘分区(一)
磁道:track 扇区:sector 磁头:head 柱面:cylinder 每个扇区,512字节 每个磁道划分为63个扇区 逻辑磁头(盘面)数设为255 一个柱面的大小 =255 * 63 * 51 ...
- [翻译]Writing Custom DB Engines 编写定制的DB引擎
Writing Custom DB Engines 编写定制的DB引擎 FastReport can build reports not only with data sourced from ...
- asp.net 使用Oracle数据库
asp.net下使用oracle会发生“未能加载文件或程序集‘Oracle.DataAccess’或它的某一个依赖项”的错误.这说明Oracle的驱动没有安装好,或者版本不对的错误. 1.检查Orac ...
- 不写代码也能爬虫Web Scraper
https://www.jianshu.com/p/d0a730464e0c web scraper中文网 http://www.iwebscraper.com/category/%E6%95%99% ...
- bootstrap-table简单使用
开发项目时总想着能不能有一款插件包含分页,查询等常用功能,后来发现了bootstrap-table 直接看代码和效果图 <!DOCTYPE html> <html lang=&quo ...
- 清除浏览器缓存meta标签
<meta http-equiv="Cache-Control" content="no-cache" /> <meta http-equiv ...
- SQL Server数据库的基础脚本编程
数据库脚本的基础编程 Go批量处理语句 用于同时处理多条语句 use指定数据库或表 use master --创建数据库 go use Student --创建表(Student)表示数据库 go 创 ...
- 【转】Leader-Follower线程模型
上图就是L/F多线程模型的状态变迁图,共6个关键点: (1)线程有3种状态:领导leading,处理processing,追随following (2)假设共N个线程,其中只有1个leading线程( ...
- cesium随笔 — 简单实现获取三维范围(包括相机高度)
代码 // 获取当前三维范围 function getCurrentExtent() { // 范围对象 var extent = {}; // 得到当前三维场景 var scene = viewer ...
- Webpack vs Rollup
本文由作者余伯贤授权网易云社区发布. 2017年4月份的时候,Facebook将React的构建工具换成了Rollup.很多人就有疑问了,Webpack不也是Facebook团队开发的吗,为什么不使用 ...