Linux

▣ APR 이란?

 

   Apache Portable Runtime의 약자로 아파치 HTTP 2.x의 핵심인 라이브러리

 

▣ Tomcat Native Library란?

 

   Apache 웹 서버의 APR 라이브러리를 Tomcat에서 사용할 수 있게 하는 라이브러리

 

   - 톰캣 버전별 HTTP Connector

BIO Connector

Tomcat 7의 기본 Connector

org.apache.coyote.http11.Http11Protocol

Java Blocking API를 사용하여 구현(pure java)

NIO Connector

Tomcat 8 이후 기본 Connector Class

org.apache.coyote.http11.Http11NioProtocol

Java Non-blocking API를 사용하여 구현(pure java)

APR Connector  APR 라이브러리를 사용해 더 나은 성능의 Connector Class

org.apache.coyote.http11.Http11AprProtocol

JNI(Java Native Interface) 라이브러리를 사용하여 구현

 

▣ Tomcat Native Library 설치

 

   - Tomcat Native Library 설치 없이 Tomcat 9를 기동시켰을 경우 기동로그에 아래와 같은 메세지 출력 됨

 

이 메시지의 의미는 APR library를 찾지 못해서 HTTP NIO Connector를 실행 했다는 의미이다.

기능 상에는 문제가 없으나 더 좋은 성능을 내기 위해서 HTTP APR Connector 사용을 검토해야 한다.

 

   1) 패키지 설치(APR 컴파일 시 필요)

      yum –y install openssl-devel

      yum –y groupinstall “Development Tools”

      yum –y install expat-devel

 

   2) APR 다운로드 및 설치

     2-1) cd /opt

     2-2) wget http://mirror.navercorp.com/apache//apr/apr-1.7.0.tar.gz

     2-3) gzip –d apr-1.7.0.tar.gz

     2-4) tar –xvf apr-1.7.0.tar

     2-5) cd apr-1.7.0

     2-6) ./configure

해당   오류   발생할   경우  cp –arp libtool libtoolT  실행   후   다시  ./configure  실행

     2-7) make

     2-8) make install

 

    3) APR-util 다운로드 및 설치

     3-1) cd /opt

     3-2) wget http://mirror.navercorp.com/apache//apr/apr-util-1.6.1.tar.gz

     3-3) gzip –d apr-util-1.6.1.tar.gz

     3-4) tar –xvf apr-util-1.6.1.tar

     3-5) cd apr-util-1.6.1

     3-6) ./configure –-with-apr=/usr/local/apr

     3-7) make

     3-8) make install

 

    4) Tomcat-Native 설치

     4-1) cd /opt/tomcat9.0.24/bin

     4-2) gzip –d tomcat-native.tar.gz

     4-3) tar –xvf tomcat-native.tar

     4-4) cd tomcat-native-1.2.23-src/native

     4-5) ./configure --with-apr=/usr/local/apr --with-java-home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-0.el6_10.x86_64

Tomcat Native Library 는 OpenSSL 1.0.2 이상을 필요

    ※ 해당 오류 발생 시 openssl 최신버전 설치

      4-5-1) openssl version 확인

      4-5-2) cd /usr/local/src (다운로드 받을 폴더로 이동)

      4-5-3) wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz

      4-5-4) gzip -d openssl-1.1.1c.tar.gz

      4-5-5) tar xvf openssl-1.1.1c.tar

      4-5-6) cd openssl-1.1.1c

      4-5-7) ./config

      4-5-8) make

      4-5-9) make install

      4-5-10) /usr/local/ssl 생성 확인

      4-5-11) openssl version 확인(여전히 이전 버전으로 출력 )

      4-5-12) which openssl (현재 openssl 경로 확인. 대부분 /usr/bin/openssl 있음)

      4-5-12) 기존 파일 백업 (mv openssl /root/openssl_1.0.1_bakup )

      4-5-13) ln –s /usr/local/src/bin/openssl /usr/bin/openssl (새로 설치된 openssl 링크 걸기)

      4-5-14) openssl 버전 확인(업데이트 되었음)

      4-5-15) 4-5 재실행

 

    5) Tomcat catalina.sh에 apr 라이브러리 경로 추가

      CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"

 

※ 참고 URL

https://toma0912.tistory.com/61

 

APR 및 Tomcat Native Library (was 성능 향상)

안녕하세요. 오늘은 APR 및 tomcat native library를 설정하는 방법에 대해서 포스팅 하겠습니다. APR이란 Apache Portable Runtime의 약자이며 자세한 내용은 아래 링크를 참조하면 됩니다. 참조 : https://tomca..

toma0912.tistory.com

https://xinet.kr/?p=1669

 

tomcat 8.5 tomcat-native 설치 및 설정

Caused by: org.apache.catalina.LifecycleException: The configured protocol requires the APR/native library which is not availabletomcat 8.5 버전에서 HTTP/2 를 사용하려면 tomcat native를 이용하면 HTTP/2를 이용할 수 있다CEN...

xinet.kr

http://mirror.navercorp.com/apache/apr/

 

Index of /apache/apr

This downloads page includes only the sources to compile and build APR projects, using the proper tools. All of the release distribution packages have been digitally signed (using PGP or GPG) by the ASF committers that constructed them. There will be an ac

mirror.navercorp.com

https://www.openssl.org/source/

 

/source/index.html

The master sources are maintained in our git repository, which is accessible over the network and cloned on GitHub, at https://github.com/openssl/openssl. Bugs and pull patches (issues and pull requests) should be filed on the GitHub repo. Please familiari

www.openssl.org

 

너무 오래된 Tomcat 버전으로 서비스를 운영하고 있어서,

WAS성능 향상을 위해 부장님과 회의 끝에 Tomcat 7 -> Tomcat 9 버전으로 업데이트 하기로 하였다.

 

Tomcat 7 에서 Tomcat 9 로 버전 업데이트 시 발생한 이슈사항을 정리 하고자 한다.

 

1. Tomcat 7과 Tomcat 9의 Connector옵션의 maxPostSize 차이

 

Tocmat 7의 경우 maxPostSize의 MAX값은 '0'

Tomcat 9의 경우 maxPostSize의 MAX값은 '-1'

 

Tomcat 7의 옵션을 그대로 가져왔더니 발생한 이슈였다.

post로 전송되는 패킷의 크기가 '0'으로 세팅되어서 패킷 사이즈 오류가 발생하였다.

 

구글링 해보니 Tomcat 8버전 부터 maxPostSize의 MAX값은 '-1'로 수정되었다고 한다.

 

2. Connector 옵션의 packetSize 차이

 

Tomcat 7의 AJP Connector 옵션의 packetSize가 '65536'으로 MAX값으로 세팅 되어 있었고

이를 Tomcat 9의 Connector 옵션에도 packetSize를 동일하게 적용하였더니,

계속해서 502 Bad GateWay 오류가 발생하였다.

 

왜 오류가 날 까 확인해보니....(원인을 찾는데 상당한 시간이 소요되었다)

 

Apache 웹 서버의 workers.proprerties 파일의 worker.template.max_packet_size=65536 가 아래와 같이 주석처리가 되어 있었다. (Tomcat 7에서는 해당 부분을 무시하는 듯 하다)

 

cat workers.properties

#worker.template.max_packet_size=65536

 

해당 내용을 주석 해제 후 packetSize를 설정해주니 정상적으로 동작하였다.

=> apache>workers.properties>worker.template.max_packet_size와 tomcat>server.sml>connector(AJP)의 packetSize 속성 값은 반드시 동일해야 한다.!

 

만약 packetSize를 설정해주지 않을 경우 default 값인 8192로 동작하며

request 값의 패킷 사이즈가 8192가 넘어갈 경우 패킷 사이즈 오류가 발생한다.

 

따라서 packetSize 값을 Apache의 workers.properties와 Tomcat의 server.xml파일에

packetSize를 MAX 값으로 설정해주어야 한다.

 

 

3. JDK 버전 차이

 

Tomcat 9 는 JDK 1.8 이후 버전을 지원한다.

따라서 현재 서비스 되는 JDK의 버전을 1.6 -> 1.8로 업데이트 하였다.

 

 

그 외에는 특이사항 없이 WEB/WAS AJP설정, 도메인 별 Tomcat 인스턴스 추가 설정 등을 완료하였다.

 

※ 참고 URL

https://tomcat.apache.org/tomcat-9.0-doc/config/ajp.html

 

Apache Tomcat 9 Configuration Reference (9.0.24) - The AJP Connector

The proxyName and proxyPort attributes can be used when Tomcat is run behind a proxy server. These attributes modify the values returned to web applications that call the request.getServerName() and request.getServerPort() methods, which are often used to

tomcat.apache.org

https://tomcat.apache.org/tomcat-9.0-doc/config/http.html

 

Apache Tomcat 9 Configuration Reference (9.0.24) - The HTTP Connector

This Connector supports all of the required features of the HTTP/1.1 protocol, as described in RFCs 7230-7235, including persistent connections, pipelining, expectations and chunked encoding. If the client supports only HTTP/1.0 or HTTP/0.9, the Connector

tomcat.apache.org

 

1. java 설치

        1-1) java 홈페이지에서 리눅스 버전 java 다운로드

wget --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn/java/jdk/11.0.3+12/37f5e150db5247ab9333b11c1dddcd30/jdk-11.0.3_linux-x64_bin.tar.gz

        1-2) alternatives 환경설정 세팅

alternatives --install /usr/bin/java java /usr/local/java/jdk-11.0.3/bin/java 1
alternatives --install /usr/bin/java javac /usr/local/java/jdk-11.0.3/bin/javac 1
alternatives --install /usr/bin/java javaws /usr/local/java/jdk-11.0.3/bin/javaws 1
alternatives --set java /usr/local/java/jdk-11.0.3/bin/java
alternatives --set javac /usr/local/java/jdk-11.0.3/bin/javac
alternatives --set javaws /usr/local/java/jdk-11.0.3/bin/javaws>

        1-3) 환경설정 확인

alternatives --list

 

2. tomcat 설치

        2-1) tomcat 홈페이지에서 리눅스 버전 java 다운로드

wget http://mirror.apache-kr.org/tomcat/tomcat-8/v8.5.40/bin/apache-tomcat-8.5.40.tar.gz

        2-2) iptables 8080포트 허용

vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT

       2-3) vi /etc/profile에 JAVA_HOME / CATALINA_HOME 설정

 

3. mod_jk.so 설치

        3-1) gcc / gcc-c++ / httpd-devel 설치

yum install gcc gcc-c++ httpd-devel

        3-2) tomcat 홈페이지에서 connector JK 설치

wget -c http://mirror.apache-kr.org/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.46-src.tar.gz

        3-3) 압축 풀은 후 make 명령어 실행 

        /home/was/tomcat-connectors-1.2.46-src/native 에서 명령어 2개 실행

./configure --with-apxs=/usr/bin/apxs
make && make install

        3-4) 설치 확인

find / -name mod_jk.so

        3-5) Selinux 보안설정 변경

chcon -u system_u -r object_r -t httpd_modules_t /etc/httpd/modules/mod_jk.so

 

4. Apache - Tomcat 연동

        4-1) /etc/httpd/conf.d/httpd-jk.conf 만들기

LoadModule jk_module modules/mod_jk.so #mod_jk.so 모듈 Load
<IfModule jk_module>
	JkWorkersFile conf.d/workers.properties # AJP 설정 / 포트설정 / host 설정
	JkLogFile logs/mod_jk.log  # 로그경로
	JkLogLevel info # 로그레벨
	JkShmFile run/mod_jk.shm
	JkMountFile conf.d/uriworkermap.properties # 확장자 설정(WAS Tomcat으로 태울 확장자)
</IfModule>

        4-2) /etc/httpd/conf.d/workers.properties 만들기

worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=192.168.25.40
worker.worker1.port=8009

        4-3) /etc/httpd/conf.d/uriworkermap.properties 만들기

/*.do=worker1
/*.jsp=worker1

        4-4) /etc/httpd/conf DocumentRoot 추가

DocumentRoot "/opt/apache-tomcat-8.5.40/webapps/ROOT"
<Directory "/opt/apache-tomcat-8.5.40/webapps/ROOT">
	AllowOverride All
	Require all granted
</Directory>

        4-5) Selinux 보안 설정(ls -alZ /var/www / ls-alZ /opt/apache-tomcat-8.5.40/webapps/ROOT 비교)

    

chcon -R --type=httpd_sys_content_t /opt/apache-tomcat-8.5.40/webapps/ROOT

        4-6) tomcat 기본 8080 포트 주석처리(/opt/apache-tomcat-8.5.40/conf/server.xml)

<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->

 

5. DocumentRoot 경로의 chmod 설정

 chmod -R 711 /opt/apache-tomcat-8.5.40/webapps (O)

     -> DocumentRoot 경로의 한 단계 아래의 Depth에 설정해주어야 한다.

        DocumentRoot 경로에 설정 후 안 돼서 이상한 거만 1시간 넘게 만짐... 

chmod -R 711 /opt/apache-tomcat-8.5.40/webapps/ROOT (X)

 

기타)

웹 서버 경로 : /etc/httpd

WAS 경로 : /opt/apache-tomcat-8.5.40

웹 서버 로그경로 : /var/log/httpd

WAS 로그경로 : /opt/apache-tomcat-8.5.40/catalina.2019-07-07.log

파일, 폴더 소유자 변경 : chown -R was:was /opt/apache-tomcat-8.5.40/webapps/ROOT

 

참고 페이지 : 

https://suwoni-codelab.com/linux/2017/05/29/Linux-CentOS-Apache-Tomcat/

https://offbyone.tistory.com/332

https://goddaehee.tistory.com/77

 

1. 네트워크 설정

   centos 7버전 부터 ifconfig 가 기본 설치 되어 있지 않음.

   -> ip addr 명령어 실행해서 이더넷이 뭐로 잡혀있나 확인

이더넷 enp3s0 으로 네트워크 설정

    -> ifup enp3s0

 

ping 8.8.8.8 (구글 ip 호출로 네트워크 확인)

2. 네트워크 자동 세팅

   PC 절전/종료 후에도 네트워크가 자동으로 세팅되도록 설정

   vi /etc/sysconfig/network-scripts/ifcfg-enp3s0 에서 ONBOOT=yes로 수정

   service network restart 실행

 

3. ifconfig 설치

   ip명령어 보다는 ifconifg 명령어가 보기가 더 편하고 익숙하다.

   -> yum -y install net-tools

 

4. telnet 설치

   원격 터미널 작업을 하기 위해 telnet 설치

   -> yum -y install telnet-server

   telnet 활성화

   -> chkconfig telnet on

 

5.  모니터 덮개 닫을 경우 절전모드 해제

   -> vi /etc/systemd/logind.conf에서 HandleLidSwitch=ignore 설정

 

6.  배터리 잔량 확인 할 수 있는 upower 설치

    -> yum -y install upower

 

7. alias 등록

-> vi /home/계정/.bashrc

            alias bat = 'upower -i $(upower -e | grep BAT) | grep --color=never -E "state|to\ full|to\ empty|percentage"'

            바로 적용 : source ~/.bashrc 

 

8.  apache 설치 및 방화벽 설정

참고) https://opentutorials.org/module/1701/10228

 

Centos 7 - 아파치(Apache) 설치 - 나만의 Web Server 만들기

 ※ 명령어 입력시 앞에 #은 프롬프트를 의미하므로 #까지 입력하시면 않됩니다. 최초 접속을 하면 네트워크에 연결이 되어 있는지 간단한 테스트를 시행합니다. # ping 168.126.63.1 네트워크가 연결이 않되어 있으면 연결시켜 줍니다.  그런후 update 시켜 줍니다. # yum -y update FTP  서버 설치 # yum -y install vsftpd !- vsftpd 설치 # systemctl enable vsftpd.service !-

opentutorials.org

9. iptables 세팅, firewalld 설정 삭제

참고)  http://blog.plura.io/?p=4519

 

java.net.BindException: Address already in use (8390)
WAS 올릴 때 다음과 같은 에러 발생 시 

해당 포트번호의 프로세스 확인 후
netstat -anp | grep LISTEN | grep :포트번호

해당프로세스 kill -9 해준다.

crontab 설정

2019. 2. 22. 11:11

crontab -l   : 현재 크론탭 옵션 보기
crontab -e  : 크론탭 설정


첫번재 인수 : 0~59 minute
두번재 인수 : 0~23 hour
세번재 인수 : 1~31 day of month
네번재 인수 : 1~12 month
다섯번째 인수 : 0~6 요일

ex)
0 3 * * *
매일 새벽 3시 실행

https://ttend.tistory.com/547


해당 URL참고

- 해당 디렉토리 트리에서 심볼릭링크 찾기


find . -type l -printf "%p --> %l\n" 


+ Recent posts