네이버 뉴스 개편하느라 고생들 많으신 듯 합니다.

서버는 아파치웹서버 2.2.4와 mod_jk/1.2.20 커넥터로 JSP,서블릿을 처리하는 아파치톰캣에 연결되어 있군요. 현재 메시지는 톰캣 서버가 내려가 있는 상태.

댓글 영역 서버가 memo.news.naver.com 이군요.
제 사이트의 코멘트들도 memo라고 명명했었는데.
잘 되시길 바랍니다.

사용자 삽입 이미지
어제 또 테러 들어왔습니다. board의 글은 지원도 okboard_deleted 라는 테이블로 이관되어 백업이 되지만, memo글에 대한 백업은 system out log 쌓이는 것 외에는 DB백업은 이뤄지지 않고 있습니다. 해서 memo글은 거의 지우지 않는 편인데, 어제 fsf 라는 닉네임의 메모글 2개를 삭제했습니다.
이 정도 되면 아예 그쪽 네트워크를 차단합니다. 톰캣의 admin에서 이를 지원해주는 UI가 있기 때문에 그리 어렵지 않습니다.
Ip Allow and Deny

Ip Allow and Deny


Allow Ip 를 쓰게되면 해당 대역의 IP만 접근가능하고, Deny IP 를 쓰면 해당 대역의 IP들은 거부당합니다. IP 거부 , IP 차단을 프로그램에서 해 주지 않아도 되는 것이죠. 더구나 톰캣을 재시동하지 않고, 바로 적용됩니다.

자체 정화가 될 것이라 생각지는 않습니다. 그렇다면 운영자는 존재할 필요 없죠. 짬통게시판(http://www.okjsp.pe.kr/bbs?act=LIST&bbs=trash)을 만들어 격리시킨 이유도 비슷합니다. 사용자의 기분을 나빠지지 않도록 보호하기 위해서 격리시키는 것이죠.

찌질이들이 지구 상에서 없어지는 날은 오지 않을 것입니다. 자기 안에 있는 찌질함을 표출했기 때문에 찌질이라 말을 듣는 것이니까요. 제 안에도 찌질함이 많이 있는 것을 봅니다. 다만 드러내기를 꺼릴 뿐이죠.

사는 게 쉽지만은 않습니다.
포트가 네 개 있는데,
8080 은 http 서비스 포트,
8443은 SSL이니 사용안하면 주석처리하시고,
8009는 apache httpd와 같은 웹서버와 내부 연결 포트니까 웹서버 유무에 따라 처리하시고,
8005는 shutdown 포트입니다.

인트로
Introduction

배치자는, 이름이 의미하듯이, 톰캣 서버에 웹 애플리케이션을, 정적으로(서버가 기동하기 전에 설치된 애플리케이션) 또는 동적으로 (톰캣 매니저 웹 애플리케이션이나 이미 배치된 애플리케이션들과 연계하여), 배치하거나 제거하는 역할을 합니다.
The deployer, which as its name imply, allows deploying and undeploying web applications to the Tomcat server, either statically (the application is setup before the server is started), or dynamically (in conjunction with the Tomcat Manager web application or manipulating already deployed applications).

컨텍스트 기술서
Context descriptors

컨텍스트 XML 기술서는 XML 데이터 조각입니다. 메인서버 설정 파일(conf/server.xml)에서 정상적으로 보여질 수 있는 유효한 컨텍스트 엘리먼트를 포함합니다. 그리고 이것은 톰캣에서 다양한 관리 도구를 통해서 쉽게 자동화된 조작이 가능합니다. 호스트에서 컨텍스트 기술서의 위치는 $CATALINA_HOME/conf/[enginename]/[hostname]/foo.xml 입니다. 주의할 것은 파일의 이름은 웹 애플리케이션 이름에 맞지 않아도 되지만, 톰캣이 컨텍스트 기술서를 생성하게 되면 컨텍스트 기술서의 이름은 웹 애플리케이션과 동일하게 맞춰집니다.
A Context XML descriptor is a fragment of XML data which contains a valid Context element which would normally be found in the main server configuration file (conf/server.xml), and allows easy and automated manipulation of web applications by the various management tools available in Tomcat. For a given host, the Context descriptors are located in $CATALINA_HOME/conf/[enginename]/[hostname]/foo.xml. Note that while the name of the file is not tied to the webapp name, Tomcat will create Context descriptors which match the webapp name whenever it will generate a Context descriptor.

컨텍스트 기술서는 컨텍스트의 모든 환경설정 파라미터의 정의가 가능합니다. 예를 들면 네이밍 자원과 세션 매니저 설정같은 것이죠. 또 한 가지 말하자면, 컨텍스트 엘리먼트에 있는 docBase 값은 .WAR 파일을 참조하거나 .WAR파일의 압축이 풀려진 디렉토리를 지정할 수 있습니다.
Context descriptors allow defining all aspects and configuration parameters of a Context, such as namign resources and session manager configuration. It should be noted that the docBase specified in the Context element can refer to either the .WAR or the directory which will be created when the .WAR is expanded or the .WAR itself.

from: http://tomcat.apache.org/tomcat-5.0-doc/deployer-howto.html

톰캣 시작할 때 디플로이
Deploying on Tomcat startup

host의 "deployOnStartup" 프로퍼티 값이 true이면 host appBase 폴더에 있는 웹 애플리케이션들은 디플로이 됩니다. 디플로이 프로세스는 다음과 같습니다:
  • 컨텍스트 XML 선언은 제일 처음 디플로이 됩니다.
  • 컨텍스트 XML 선언으로 참조되지 않은 펼쳐진 웹 애플리케이션들이 그 다음으로 디플로이 됩니다; 만일 .WAR파일과 연관이 되어있고, 그 .WAR파일이 새 것이라면, 펼쳐진 디렉토리는 제거되고, 웹 애플리케이션은 .WAR 파일 압축이 풀리면서 재 디플로이 될 것입니다.
  • .WAR 파일들이 디플로이 됩니다.
만약 매칭되는 컨텍스트 XML 파일이 없다면, 디플로이되는 웹 애플리케이션마다 해당 컨텍스트 XML이 생성될 것입니다.
 
The webapps which are present in the host appBase will be deployed if the host "deployOnStartup" property is true. The deployment process is the following:

The Context XML declarations will be deployed first

Expanded web applications not referenced by Context XML declarations will then be deployed; if they have an associated .WAR file and it is newer than the expanded web application, the expanded directory will be removed and the webapp will be redeployed from the .WAR

.WAR files will be deployed

For each deployed web application, a matching Context XML descriptor will be created unless one exists already.

from: http://tomcat.apache.org/tomcat-5.0-doc/deployer-howto.html

운영중인 톰캣에 배치
Deploying on a running Tomcat server

만약 host의 "autoDeploy" 프로퍼티가 true이면, 호스트는 필요할 때마다 동적으로 웹 애플리케이션을 배치 또는 업데이트하려고 시도합니다. host는 자동 리로딩 작업에 필요한 백그라운드 처리가 필요할 것인데, 기본적으로 설정되어 있습니다.
If the host "autoDeploy" property is true, the host will attempt to deploy and update web applications dynamically, as needed. The host will need to have background processing enabled for automatic reloading to work, which is the default.

다음을 포함합니다:

  • host appBase 폴더에 복사된 WAR파일의 배치
  • host appBase 폴더에 복사된 펼쳐진 웹 애플리케이션의 배치
  • WAR파일이 갱신되었을 경우 WAR파일로부터 배치된 웹 애플리케이션의 재배치:
    펼쳐있는 웹 애플리케이션이 제거되고, WAR파일이 다시 압축이 풀립니다. 만약 host의 옵션이 WAR파일은 압축해제되지 않도록 설정되었다면 그렇게 되지 않고, 그런 경우에는 웹 애플리케이션은 단순이 재배치 됩니다.
  • /WEB-INF/web.xml 파일이 갱신된 경우 웹 애플리케이션의 재배치
  • 배치된 웹 애플리케이션의 컨텍스트 XML 파일이 갱신된 경우 웹 애플리케이션의 재배치
  • $CATALINA_HOME/conf/[enginename]/[hostname]/ 폴더에 컨텍스트 XML 파일(이전에 배치된 애플리케이션의 컨텍스트 경로와 일치하는 이름을 가진)이 추가된 경우 웹 애플리케이션의 재배치

주의: 웹 애플리케이션 리로딩은 로더에서 설정될 수 있고, 그런 경우 로드된 클래스는 변경에 대해서 추적됩니다.

This includes:
Deployment of WARs which are copied to the host appBase.
Deployment of expanded web applications which are copied to the host appBase.
Redeployment of a web application which has been deployed from a WAR when the WAR is updated: the expanded web application is removed, and the WAR is expanded again. This will not happen if the host is configured so that WARs are not expanded, in which case the webapp will be simply redeployed.
Redeployment of the web application if the /WEB-INF/web.xml file is updated.
Redeployment of the web application if the context XML file from which the web application has been deployed is updated.
Redeployment of the web application if a context XML file (with a name corresponding to the context path of the previously deployed application) is added in the $CATALINA_HOME/conf/[enginename]/[hostname]/ folder.
Note: Web application reloading can also be configured in the loader, in which case loaded classes will be tracked for changes.
from: http://tomcat.apache.org/tomcat-5.0-doc/deployer-howto.html

클라이언트 디플로이어 패키지를 사용해서 디플로이하기
Deploying using the Client Deployer Package
번역 translated by kenu_AT_okjsp.pe.kr

클라이언트 디플로이어는 운영이나 개발 서버에 웹 애플리케이션을 검증, 컴파일, 배치시킬 수 있는 패키지입니다. 이 기능은 자동 배치를 위해서 톰캣 매니저를 사용한다는 것은 알아야 겠죠.
The client deployer is a package which can be used to validate, compile, and deploy a web application to a production or development server. It should be noted that this feature uses the Tomcat manager for automatic deployment.

이 디플로이어는 카탈리나 매니저 앤트 태스크, 배치 전에 JSP 컴파일을 하기 위한 재스퍼 페이지 컴파일러, 그리고 웹 애플리케이션 배치 기술서를 검증하는 태스크를 포함하고 있습니다. 검증 태스크(org.apache.catalina.ant.ValidatorTask 클래스)는 파라미터 하나만 받습니다: 웹 애플리케이션의 기본 경로
The deployer includes the Catalina manager Ant tasks, the Jasper page compiler for JSP compilation before deployment, as well as a task which validates the webapp's deployment descriptor. The validator task (class org.apache.catalina.ant.ValidatorTask) allows only one parameter: the base path of an expanded web application.

디플로이어는 입력으로 펼쳐진 웹 애플리케이션을 이용합니다(아래에 나와 있는 디플로이어의 프로퍼티 목록 참조). 디플로이어가 프로그램으로 배치하게 되는 웹 애플리케이션은 톰캣에 특화된 배치 설정을 포함할 수도 있습니다. /META-INF/context.xml 안에 있는 컨텍스트 설정 XML 파일이죠.
The deployer uses an unpacked web application as input (see the list of the properties used by the deployer below). A web application which is programatically deployed with the deployer may include Tomcat specific deployment configuration, by including a Context configuration XML file in /META-INF/context.xml.

디플로이어 패키지는 다음과 같은 앤트 스크립트 타겟을 사용할 수 있습니다:

  • compile (default): 웹 애플리케이션을 컴파일하고 검증합니다. 독립적으로 사용될 수 있고, 실행중인 톰캣 서버가 없어도 됩니다. 컴파일된 애플리케이션은 오직 관련된 톰캣 5.0.x버전의 서버에서만 실행됩니다. 다른 버전에서는 동작한다고 보장할 수 없습니다. 재스퍼에 의해 생성된 코드는 실행 컴포넌트에 의존하기 때문입니다. 또 하나 알아야 할 것은 이 compile 타겟은 웹 애플리케이션의 /WEB-INF/classes 폴더 안에 있는 모든 자바 소스는 자동으로 모두 컴파일 해 버린다는 것입니다.
  • deploy: (컴파일 되든 안되든) 웹 애플리케이션을 톰캣 서버로 배치합니다.
  • undeploy: 웹 애플리케이션을 제거.
  • start: 웹 애플리케이션을 시작.
  • reload: 웹 애플리케이션을 릴로드.
  • stop: 웹 애플리케이션을 정지.

The deployer package includes a ready to use Ant script, with the following targets:
compile (default): Compile and validate the web application. This can be used standalone, and does not need a running Tomcat server. The compiled application will only run on the associated Tomcat 5.0.x server release, and is not guaranteed to work on another Tomcat release, as the code generated by Jasper depends on its runtime component. It should also be noted that this target will also compile automatically any Java source file located in the /WEB-INF/classes folder of the web application.
deploy: Deploy a web application (compiled or not) to a Tomcat server
undeploy: Undeploy a web application
start: Start web application
reload: Reload web application
stop: Stop web application

다음 프로퍼티는 시스템 프로퍼티나 또는 디플로이어 패키지의 루트 폴더에 있는 deployer.properties 파일을 통해서 지정할 수 있습니다:

  • build: 기본적으로 사용되는 빌드 폴더는 ${build}/webapp${path} 입니다. compile 타겟의 실행이 마친 후, 웹 애플리케이션 WAR 파일은 ${build}/webapp${path}.war 에 만들어집니다.
  • webapp: 컴파일되고 검증되고, 압축이 풀린 웹 애플리케이션이 담길 폴더. 기본 폴더명은 myapp 입니다.
  • path: 웹 애플리케이션의 배치될 컨텍스트 경로. 기본값은 /myapp.
  • url: 실행중인 톰캣 서버의 매니저 웹애플리케이션에 접근할 수 있는 절대 URL. 여기를 통해서 웹 애플리케이션을 배치(설치) 또는 제거할 수 있습니다. 정해지지 않으면 디플로이어는 로컬호스트에서 돌아가는 톰캣인스턴스의 주소 http://localhost:8080/manager로 접근하려 할 것 입니다.
  • username: 톰캣 매니저 연결용 username.
  • password: 톰캣 매니저 연결용 password.

The following properties can be specified, either as system properties, or by using a deployer.properties file located in the root folder of the deployer package:
build: The build folder used will be, by default, ${build}/webapp${path}. After the end of the execution of the compile target, the web application WAR will be located at ${build}/webapp${path}.war.
webapp: Folder containing the expanded web application which will be compiled and validated. By default, the folder is myapp.
path: Deployed context path of the web application, by default /myapp.
url: Absolute URL to the manager web application of a running Tomcat server, which will be used to deploy and undeploy the web application. By default, the deployer will attempt to access a Tomcat instance running on localhost, at http://localhost:8080/manager.
username: Username to be used to connect to the Tomcat manager.
password: Password to be used to connect to the Tomcat manager.

from: http://tomcat.apache.org/tomcat-5.0-doc/deployer-howto.html

Apache Tomcat 트레이아이콘에서 Configure... 를 선택하면 서비스에 등록된 Apache Tomcat의 세부 설정을 조정할 수 있습니다. 2001년 Tomcat 3.x에 비하면 많이 좋아졌죠.
Configure 의 내용을 살짝 알아보겠습니다.

1. General

Apache Tomcat service General

Apache Tomcat service General

Display name:에는 서비스에 등록된 이름입니다. Descriptiion:도 마찬가지로 서비스 창에서 확인할 수 있습니다. Startup type: 을 Automatic 으로 하시면 윈도우 재시동시 Apache Tomcat 서비스가 자동으로 시작됩니다.
Service Status: 에서 확인할 수 있는 정보는 아래 4개의 버튼 Start, Stop, Pause, Restart 와 관계가 있습니다.

2. LogOn
Apache Tomcat service LogOn

Apache Tomcat service LogOn

LogOn 탭은 그다지 많이 사용하지 않을 듯 합니다. 윈도우 XP 계정을 보통 하나로 사용하기 때문이죠. 그래서 skip 합니다. ^^;

3. Logging
가장 많이 신경이 쓰이는 부분이 서버의 로그입니다. 에러메시지도 로그에 상세히 남으니까 작업하면서 로그 파일이 어디에 어떻게 쌓이고 있는지 아는 것이 개발자의 필수사항이죠.
Apache Tomcat service Logging

Apache Tomcat service Logging

로그 레벨은 Error, Warning, Debug, Info 4가지입니다.
Log path: 에 지정된 폴더 경로는 로그 파일들이 쌓이는 곳입니다.
Log prefix:는 로그 파일명의 접두어를 지정하는 곳입니다.
Redirect Stdout:System.out.println(); 으로 찍히는 로그가 쌓이는 파일입니다. auto로 놔두시면 로그파일이 날짜별로 쌓이게 됩니다. 아마도 이 파일을 가장 많이 열어보실 것 같네요. 유닉스나 윈도우의 tail 명령으로 창을 띄어 놓아도 괜찮을 겁니다. 가장 원시적인 디버깅 방법이지만, 저에겐 아직도 꽤 유용합니다.
Redirect Stderr: 은 System.err.println(); 으로 찍히는 로그가 쌓이게 됩니다. 역시 그냥 auto로 놔두셔도 좋습니다.

4. Java
Apache Tomcat은 Java Application입니다. 때문에 JVM(Java Virtual Machine) 이 필요합니다. 꼭 jdk(Java Development Kit) 일 필요는 없고, jre(Java Runtime Environment)로 동작가능합니다. jdk와 jre의 차이점은 javac(java compiler; *.java 파일을 *.class 바이트코드로 컴파일해주는 프로그램)의 유무입니다. jre에는 없습니다. 단순히 class 바이트코드를 실행하는 환경만 제공하는 것이죠. 그렇다면 좀 예민하신 분들은 이런 의문이 생길 수 있습니다. "어, 그럼 jsp가 변환된 servlet 은 누가 컴파일하지?" 해답은 Apache Tomcat 서버에 포함된 라이브러리 중에서 eclipse 쪽에서 만들어진 컴파일러가 포함되어 있다는 것입니다.
하지만, 개발자라면 jdk를 깔아서 작업하시길 권장합니다.

사용자 삽입 이미지

Apache Tomcat service Java

Java Classpath: 에는 Apache Tocmat 이 기동할 때 필요한 *.jar 파일들 경로가 들어가 있습니다. bootstrap.jar 에는 Apache Tomcat 의 시작 어플리케이션, 즉 main() 메소드가 있는 클래스가 있습니다.
Java Options: 는 JVM이 뜰 때 필요한 각종 파라미터를 지정할 수 있습니다. -D... 로 시작하는데, JVM이 인식하는 환경변수라고 생각하시면 됩니다. System.getProperty("catalina.home"); 과 같은 코드로 여기에 설정된 변수의 값을 가져다 쓸 수 있습니다.
Initial memory pool:, Maximum memory pool:, Thread stack size: 정보는 톰캣 서비스시 OutOfMemoryError가 날 경우 적당히 조절해 주면 됩니다. 아무 값도 없을 경우 필자의 경험상 64 MB 정도를 Maximum 으로 사용하는데, 이 값을 128 MB이나 256 MB 등으로 적당히 올려주시면 됩니다. 메모리 크게 잡는다고 좋지는 않으니 튜닝하면서 적당한 것을 찾아보십시오.

5. Startup
톰캣 시작시 옵션을 줄 수 있는 곳입니다. 아까 Classpath:에 있는 bootstrap.jar 파일 내에 있는 org.apache.catalina.startup.Bootstrap 클래스 파일을 실행합니다.
Apache Tomcat service Startup

Apache Tomcat service Startup


6. Shutdown
Startup 과 마찬가지 클래스를 호출하는데, 인수만 start 대신 stop 으로 들어갑니다.
Apache Tomcat service Shutdown

Apache Tomcat service Shutdown


이상으로 Apache Tomcat service의 세부 설정에 대해서 알아봤습니다. 톰캣자체의 문서가 작지 않기 때문에 세세한 내용을 원하신다면 찾아보실 수 있습니다. http://tomcat.apache.org/ 주의하실 것은 버전(jdk, tomcat, os)을 무시할 수 없으니 잘 확인하고 문서를 보셔야 할 것입니다.
개발만하기도 벅찬데, JSP 문법 따라잡기도 벅찬데 톰캣까지, 아니 웹로직이나 OC4j, 웹스피어, 그리고 국산 WAS인 제우스까지 사용법을 아시려면 머리 뽀개지실 겁니다. ^^; 톰캣은 Servlet컨테이너만 있고, EJB컨테이너는 없으니 그나마 다행일 지도 모릅니다. 회사에서 구입하신 WAS라면 교육보내달라고 하십시오. 그리고 알차게 기술지원 받으시는 것이 개발에 집중하는데 도움이 될 것입니다.
JBoss라구요? 흐흐흐 알아서 하십시오. 문서많습니다. ^^; 영어문서는... ㅋㅋ

다음 글 부터는 다시 JSP 쪽의 글을 쓰도록 하겠습니다.

+ Recent posts