Mar 25, 2015 - jconsole 활용도와 로컬 셋팅 방법입니다

jvm 에 대한 현재 상태를 분석하기 위해, 서버 셋팅은 jmxremote 수정 및 tomcat의 catalina.sh 을 수정합니다.

$JRE_HOME/lib/management/jmxremote.password.template 파일을 $JRE_HOME/lib/management/jmxremote.password 로 복사합니다.

복사한 파일 안에 계정에 비밀번호를 생성합니다.

monitorRole 비밀번호
controlRole 비밀번호
아이디까지 바꿔야하는 경우에는 $JRE_HOME/lib/management/jmxremote.access 파일에 아이디를 추가해야합니다.

기본 설정은 다음과 같습니다.

monitorRole readonly
controlRole readwrite
/usr/local/tomcat6/bin/catalina.sh 파일에 하단 내용을 추가합니다.
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8999 -Djava.rmi.server.hostname=host.ip -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"

jconsole은 java에서 지원하는 무료 java monitoring 툴입니다.

로컬 셋팅 방법은 다음과 같습니다.

[java가 설치된 경로]/lib/jconsole.jar 을 실행시키거나,
[java가 설치된 경로]/bin/jconsole.exe 을 실행시킵니다.

Remote Process : host.ip:8999
Username / Password
monitorRole/monitorRole2014)#(      : 모니터링 계정
controlRole/controlRole2014)#(        : 컨트롤 계정

활용도는 현재로서는 2가지 용도로 사용될 예정입니다.

  1. mysql 커넥션 확인 용도 현재 Idle 갯수를 알 수 있는 numIdle 과 활성화 여부인 numActive 등을 알 수 있습니다.

maxActive : 최대 active connection 개수 maxIdle : 최대 idle connection 개수 minIdle : 최소 idle connection 개수 maxWait : 최대 connection 대기 시갂 numActive : 현재 active connection 개수 numIdle : 현재 idle connection 개수

  1. JAVA 단에서 발생하는 Deadlock 상황 확인

2018.06.27 추가 사항

-Djava.rmi.server.hostname=host.ip

초창기에는 외부에서 접속가능하도록

monitorRole readonly
controlRole readwrite

에 대한 jmxremote.access 에 대한 파일을 수정했습니다. 그러나 현재는 회사 내부의 ip와 전체 서버의 ip가 하나의 망으로 구현되어있어, 별도의 jmxremote.access 설정이 없이, 바로 host.ip를 도메인주소가 아닌, host ip로 연결하여 테스트가 가능하게 되었습니다.

현재는, jconsole 보다, jvisualvm 을 더 자주 사용합니다.

Sep 19, 2014 - ASP 에서 3DES 암호화하는 방법

ASP 3DES 로 검색을 하면 뜨는 http://www.example-code.com/asp/3des.asp 의 소스를 보면

set crypt = Server.CreateObject("Chilkat.Crypt2")
success = crypt.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    '  Unlock failed.
    Response.Write crypt.LastErrorText & "<br>"

End If

문제는 Chilkat.Crypt2 는 유료다. 유료화된 암호화 툴을 쓸수가 없기 때문에 인터넷을 검색해보니 Platform SDK: CAPICOM 라는 것을 찾을 수 있었다. 우선 http://www.microsoft.com/ko-kr/download/details.aspx?id=25281 로 가서 다운로드를 받는다. CAPICOM 2.1.0.1과 여기서 사용되는 샘플에 필요한 재배포 가능 파일을 포함하는 다운로드입니다. CAPICOM은 디지털 서명 데이터, 서명 코드, 디지털 서명 확인, 개인 정보를 위한 데이터 보호, 데이터 해시, 데이터 암호화/해독 등에 사용할 수 있습니다. 다운받고 설치하면 해.결! 소스는 매우 간단하다. 인터넷을 조금만 검색하면 소스를 찾을 수 있다.

<%
Const CAPICOM_ENCRYPTION_ALGORITHM_RC2 = 0 ' Use RSA RC2 encryption. 
Const CAPICOM_ENCRYPTION_ALGORITHM_RC4 = 1 ' Use RSA RC4 encryption. 
Const CAPICOM_ENCRYPTION_ALGORITHM_DES = 2 ' Use DES encryption. 
Const CAPICOM_ENCRYPTION_ALGORITHM_3DES = 3 ' Use triple DES encryption. 

strTestMessage = "Hello World!"
strPassphrase = "A#0x?\$dE<"	' NIEMALS die Passphrase "herumliegen" lassen
Set xEncrypt = Server.CreateObject("CAPICOM.EncryptedData")
xEncrypt.Content = strTestMessage
xEncrypt.SetSecret strPassphrase
xEncrypt.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_3DES
strEncryptedMsg = xEncrypt.Encrypt()
Response.Write strEncryptedMsg & "<br/>"
%>

<%
strPassphrase = "A#0x?\$dE<"	' NIEMALS die Passphrase "herumliegen" lassen
Set xEncrypt = Server.CreateObject("CAPICOM.EncryptedData")
xEncrypt.SetSecret strPassphrase
xEncrypt.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_3DES
xEncrypt.Decrypt(strEncryptedMsg)
strPlainText = xEncrypt.Content
Response.Write strPlainText
%>

물론 필자는 dll 파일이 등록이 안되서 매우 고생을 했지만!! 어떻게 해결했는지는 비.밀! (티스토리에서 github 으로 옮기면서 비.밀 이라고 적어놨는데, 어떻게 했는지 기억이 안난다. 해당 기능은 asp 쪽의 세션을 훔쳐서 불법으로 뭔가를 다운받기 위한 오덕스러운 짓이었던걸로 기억해서, 비밀로 한거 같은데..)

Sep 3, 2014 - DB 현재 날짜에서 3일전을 검색하기

DB 현재 날짜에서 3일전을 검색하기

SELECT * FROM 테이블 WHERE 컬럼 >=(CURDATE()-INTERVAL 3 DAY);
SELECT * FROM 테이블 WHERE 컬럼 >=dateadd(day,-3,getdate())