[Redis] 패턴을 통한 데이터 삭제 2015-03-31

Redis는 기본적으로 패턴을 활용한 삭제를 지원하지 않는다. SQL과 다른점이다.

Redis를 활용한 개발시 데이터를 초기화 하고자 할경우 개발언어로 스크립트를 구성할 수도 있지만 다음과 같이 패턴을 활용하여 삭제하면 편리하다.

 

For Linux

redis-cli keys "{PATTERN}" | xargs redis-cli del

 

For Windows : 삭제해야할 키값을 파일에 저장 후 루프문을 활용

{redisPath}\redis-cli keys "{PATTERN}" > C:\tmp.txt
FOR /F %k in (C:\tmp.txt) DO {redisPath}\redis-cli del %k

 

[JAVA] log4j Level 설정 2015-03-23

log4j에서는 6단계의 Event Level로 구분하여 로그를 기록하는데 Config Level의 설정에 따라 다음과 같이 로그를 설정 할 수 있다.
log4j

>>> LEVEL 설정

ALL – The ALL has the lowest possible rank and is intended to turn on all logging.
=> 모든 로깅.
TRACE – The TRACE Level designates finer-grained informational events than the DEBUG
=> 세밀
DEBUG – The DEBUG Level designates fine-grained informational events that are most useful to debug an application.
=> 디버깅.
INFO – The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.
=> 강조 정보.
WARN – The WARN level designates potentially harmful situations.
=> 경고.
ERROR – The ERROR level designates error events that might still allow the application to continue running.
=> 오류.
FATAL – The FATAL level designates very severe error events that will presumably lead the application to abort.
=> 심각한 오류.
OFF – The OFF has the highest possible rank and is intended to turn off logging.
=> 로깅 해제.

>>> 출력 패턴(ConversionPattern) 설정

%m: 로그 내용 출력
%p: debug, info, warn, error, fatal 등의 priority 출력
%r: 어플이 시작 후 이벤트가 발생하는 시점까지의 경과시간 밀리세컨드로 출력
%c: package 출력
%c{n}: n(숫자) 만큼의 package를 가장 하단 부터 역으로 출력
예) %c{2} 일때 a.b.c 는 b.c 로 출력된다.
%n: 개행문자 출력. 플렛폼에 따라 \r\n 또는 \n 출력.
%d: 이벤트 발생 날짜 출력 ( 프로그램의 실행속도를 느리게 한다.)
예) %d{HH:mm:ss} 또는 %d{dd MMMM yyyy HH:mm:ss}
%C: 호출자의 클래스명 출력
예) %C{2} 일때 a.b.c.TestClass 는 c.TestClass 로 출력된다.
%M: method 이름.
%F: 프로그램 파일명.
%l: caller의 정보
%L: caller의 라인수
%x: thread와 관련된 NDC(nested diagnostic context)
%X: thread와 관련된 MDC(mapped diagnostic context)
%%: % 표시를 출력
%t: 쓰레드 이름

[Linux – CentOS] 디스크 마운트 2015-03-12

클라우드 서비스 이용중 디스크가 90%가 넘었다.

console> df -h

disk_mount1

분명 100G로 알고 있었는데…?

클라우드 설정에서 분명히 20G + 80G의 디스크가 사용중이다.

정상적으로 마운트 되지 않은것으로 보인다.

디스크가 정상인식되었는지 확인하자.

console> fdisk -l

disk_mount2

디스크는 인식되었으나 마운트 되지 않아 사용할 수 없는 상황이었다.

디스크 사용을 위해 다음과 같이 마운트 하자

 

# 디스크 형식에 맞춰 포맷
console> mkfs.ext4 /dev/xvdb

disk_mount3

# 디스크 마운트 : 폴더를 생성한 이후 마운트
console> mount /dev/xvdb /data

disk_mount4

# 디스크 마운트 확인

console> df -h

disk_mount5

console> mount

disk_mount6

# 이상태로 사용할 수 있으나 재부팅시 다시 마운트 해줘야 한다. 자동 마운트 되도록 설정한다
console> vi /etc/fstab

disk_mount7

# 설정이 완료되었다.