1)
스마트카 상태 정보 원본 파일 이름 : SmartCarStatusInfo 20160101.txt
적재된 데이터 파일 이름 : car-batch-log.xxxxxxxxxx.log
수집 및 적재를 위한 시스템 설정 내용
SmartCar_Agent.sources = SmartCarInfo_SpoolSource DriverCarInfo_TailSource
SmartCar_Agent.channels = SmartCarInfo_Channel DriverCarInfo_Channel
SmartCar_Agent.sinks = SmartCarInfo_HdfsSink DriverCarInfo_KafkaSink
-> HDFS Sink 정보를 설정하기 위한 SmartCarInfo_HdfsSink 리소스를 선언하였다.
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.type = spooldir
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.spoolDir = /home/pilot-pjt/working/car-batch-log
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.deletePolicy = immediate
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.batchSize = 1000
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.interceptors = timeInterceptor typeInterceptor collectDayInterceptor filterInterceptor
-> 3개의 interceptor가 추가 됐다.
-> timeInterceptor - 타임스태프 활용
-> typeInterceptor - 로그 유형에 해당하는 상수값을 정의
-. collectDayInterceptor - 수집 일자를 추가
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.interceptors.timeInterceptor.type = timestamp
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.interceptors.timeInterceptor.preserveExisting = true
-> timeInterceptor의 설정이다. 이렇게 타임스탬프 Interceptor를 추가하고 나면 플럼의 이벤트 헤더에 현재 타임 스탬프가 설정되어 필요 시 헤더로부터 타임스탬프 값을 가져와 활용할 수 있다.
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.interceptors.typeInterceptor.type = static
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.interceptors.typeInterceptor.key = logType
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.interceptors.typeInterceptor.value = car-batch-log
-> 'typeIntercertor'의 설정이다. 플럼의 해당 이벤트 내에서 사용할 상수를 선언하고 값을 설정한다.
-> 'logType'이라는 상수를 선언했고 값은 'car-batch-log'로 설정했다.
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.interceptors.collectDayInterceptor.type = com.wikibook.bigdata.smartcar.flume.CollectDayInterceptor$Builder
->'collectDayInterceptor'의 설정이다. 플럼 이벤트 바디에 수집된 당일의 작업 날짜(YYYYMMDD)를 추가하기 위한 인터셉터다.
...................<중간 생략>.................
SmartCar_Agent.sources.SmartCarInfo_SpoolSource.channels = SmartCarInfo_Channel
SmartCar_Agent.sinks.SmartCarInfo_HdfsSink.channel = SmartCarInfo_Channel
-> HDFS Sink인 SmartCarInfo_HdfsSink를 Memory Channel인 SmartCarInfo_Channel과 연결했다.
..................<이하 생략>.................
$ mv /home/pilot-pjt/working/SmartCar/SmartCarStatusInfo 20160101.txt /home/pilot-pjt/working/car-batch-log/
-> SmartCarStatusInfo는 데이터 분석 파일이다.
$ tail -f /var/log/flume-ng/flume-cmf-flume-AGENT-server02.hadoop.com.log
-> .....flume-cmf-flume-AGENT-server02.hadoop.com.log에 수집되는 과정을 보여준다.
반대로,
.../flume-cmf-flume-AGENT-server02.hadoop.com.log/ 에서
../car-batch-log/로는 적재되는 과정을 보여준다.
2) 나의 컴퓨터에는 파일과 주소록을 찾을 수 없다고 나온다. 나중에 다시 해봐야 겠다.
$ hdfs dfs -ls -R /pilot-pjt/collect/car-batch-log/
-> 적재 중인 스마트카의 로그 파일을 확인한다.
$ hdfs dfs -cat "출력된 디렉터리/파일명.log"
-> 파일의 경로는 파일럿 실행일자와 환경에 따라 다르게 만들어진다.
$ hdfs dfs -tail /pilot-pjt/collect/car-batch-log/wrk_date=20190414/car-batch-log.xxxxxxxxxx.log
->각 행의 20190414는 수집일자 정보로서, 플럼의 인터셉터가 붙여넣은 추가 정보이다.
3)
나중에 하겠습니다.
'보안관리운영' 카테고리의 다른 글
보안관리운영_수집 전체 과정 (0) | 2019.04.06 |
---|---|
보안관리운영_2 (0) | 2019.03.24 |
보안관리운영_1 (0) | 2019.03.07 |