Programming/JAVA2014. 7. 31. 16:06

서버 환경

CentOS 6.5

TOMCAT 7

java version "1.7.0_55"


1. 간단하게 vi catalina.sh 또는 vi setenv.sh 설정함

----------------------------------------

CATALINA_OPTS="$CATALINA_OPTS

-Djava.rmi.server.hostname=xxx.xxx.xxx.xxx 

-Dcom.sun.management.jmxremote

-Dcom.sun.management.jmxremote.port=9080

-Dcom.sun.management.jmxremote.rmi.port=9081

-Dcom.sun.management.jmxremote.authenticate=false

-Dcom.sun.management.jmxremote.ssl=false"

----------------------------------------


2. 인증 방식 넣기 (설정시 access,password파일 추가등록)

------------------------------------------------

CATALINA_OPTS="$CATALINA_OPTS

-Djava.rmi.server.hostname=xxx.xxx.xxx.xxx 

-Dcom.sun.management.jmxremote

-Dcom.sun.management.jmxremote.ssl=false

-Dcom.sun.management.jmxremote.port=9080

-Dcom.sun.management.jmxremote.rmi.port=9081

-Dcom.sun.management.jmxremote.authenticate=true

-Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access

-Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password

------------------------------------------------


※ 계정등록 ( 구글링해보니까 LDAP 연동 방법도 있는 듯 필요시 구글링해볼것!! )

https://code.google.com/p/tungsten-replicator/source/browse/trunk/commons/conf/sample.jmxremote.access?spec=svn1148&r=1148


vi jmxremote.access ( 계정에 맞게 readonly 또는 readwrite )

------------------------------------------------

admin readwrite \

      create javax.management.moitor.*,javax.management.timer.* \

      unregister

------------------------------------------------


vi jmxremote.password

------------------------------------------------

admin password

------------------------------------------------




3. 에러발생시 처리 방안

※ Error: Exception thrown by the agent : java.net.MalformedURLException: Local host name unknown: java.net.UnknownHostException: dev-was01: dev-was01: Name or service not known

 => vi /etc/hosts 아래 host 추가하면됨

     127.0.0.1   localhost dev-was01

※ shutdown시 Error: Exception thrown by the agent : java.lang.NullPointerException

 => CATALINA_OPTS 아닌 JAVA_OPTS 에 넣으면 Exception 에러발생


※ catalina-jmx-remote.jar 필요시 톰캣사이트에서 다운르도 후 lib폴더에 넣기!

 => http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.53/bin/extras/




4. Apache 메뉴얼 listener was configured in server.xml 추가하는 방법


URL : http://tomcat.apache.org/tomcat-7.0-doc/config/listeners.html

AttributeDescription
rmiRegistryPortPlatform

The port to be used by the JMX/RMI registry for the Platform MBeans. This replaces the use of thecom.sun.management.jmxremote.port system property that should not be set when using this listener.

rmiServerPortPlatform

The port to be used by the Platform JMX/RMI server.

rmiBindAddress

The address of the interface to be used by JMX/RMI server. This option is incompatible with setting the system propertycom.sun.management.jmxremote.ssl to true.

useLocalPorts

Should any clients using these ports be forced to use local ports to connect to the the JMX/RMI server. This is useful when tunnelling connections over SSH or similar. Defaults to false.

Using file-based Authentication and Authorisation

If this listener was configured in server.xml as:

  <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
          rmiRegistryPortPlatform="10001" rmiServerPortPlatform="10002" />

with the following system properties set (e.g. in setenv.sh):

  -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password
  -Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access
  -Dcom.sun.management.jmxremote.ssl=false

$CATALINA_BASE/conf/jmxremote.password containing:

admin letmein

$CATALINA_BASE/conf/jmxremote.access containing:

admin readwrite

then opening ports 10001 (RMI Registry) and 10002 (JMX/RMI Server) in your firewall would enable jconsole to connect to a Tomcat instance running behind a firewall using a connection string of the form:

service:jmx:rmi://<hostname>:10002/jndi/rmi://<hostname>:10001/jmxrmi

with a user name of admin and a password of letmein.



Posted by 시니^^
Programming/JAVA2014. 6. 25. 14:27

개발후 배포시 war로 압축해서 배포하는 그때


서버환경(개발/운영)에 따라서 DB접근 정보나 기타 cfg 설정이 다른 경우가 있다


그런 경우 PropertyPlaceholderConfigurer등 설정 정보를 다르게 보게 해야되는 데


구글링 해보니까 아래 Stackoverflow 몇가지를 제시하고있다. 


http://stackoverflow.com/questions/11735526/spring-loading-application-properties-based-on-tomcat-servlet-contect-definition


그중에 괜찮다고 생각되는 두가지 방안


1. 아래 방법처림 배포될 서버에 예상해서 설정해서 여러개로 구성하는 방법

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:your-production-config.properties</value>
            <value>file:C:/Users/${user.name}/test-application.properties</value>
        </list>
    </property>
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
    <property name="ignoreResourceNotFound" value="true"/>
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>        
</bean>


2. ${catalina.home} 변수 이용한 Tomcat 디렉토리의 conf에 설정을 따로 구성해두는 방안

<context:property-placeholder location="file:${catalina.home}/conf/myFirst.properties" ignore-unresolvable="true" />
<context:property-placeholder   location="classpath:second.properties"  ignore-unresolvable="true"  />
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
    <value>file:${catalina.home}/conf/dbpool.properties</value>
</property>
</bean>


개발환경에서 한개 서버에 버젼에 따라서 여러 톰캣을 띄워야 할 경우에는 2번 방법이 괜찮은 것 같다.

Posted by 시니^^
SERVER/Tomcat2014. 6. 19. 15:55

1. JDK 설치 안되었을때 설치할것!!
yum list java*jdk-devel
yum install java-1.7.0-openjdk-devel.x86_64


2. Tomcat 다운로드

http://tomcat.apache.org/download-70.cgi

wget http://apache.tt.co.kr/tomcat/tomcat-7/v7.0.53/bin/apache-tomcat-7.0.53.tar.gz

tar xvfz apache-tomcat-7.0.53.tar.gz 

cd apache-tomcat-7.0.53/bin/

./startup.sh  <==실행

./shutdown.sh <==종료


※ JDK 설치하고 Binary Distributions 다운받아서 실행하면 끝


Posted by 시니^^