CentOS 7.x 아파치 모듈 컴파일 에러시



CentOS 7.2 최소설치를 했더니 아파치 모듈을 컴파일 하려고 하니 안되는게 너무 많다.


gcc 컴파일도 안되고, configure: error: apxs missing 이라고 뜨고


make 도 안되고


관련된 패키지를 설치해주자.


yum -y install gcc gcc-c++ kernel-devel httpd-devel




7.2 버전의 최소설치는 정말 최소설치인가 보다. 안되는게 너무 많다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

저렴한 코노하 VPS를 이용할 계획이라면 여기를 눌러서 가입하면 1000엔 쿠폰이 발급됩니다.


그냥 바로 사이트에서 가입하면 쿠폰이 발급이 안됩니다~


그리고 아래 처럼 지인에게 추천해서 조건이 만족되면 본인에게도 2000엔 쿠폰이 증정됩니다.



아래의 내용은 코노하 도움말 내용입니다.




지인에게 ConoHa를 소개하기(선물 쿠폰 받기)

고객님께서 소개하신 지인분이 ConoHa를 이용하기 시작하면 2000엔 상당의 쿠폰을 드립니다.

고객님 전용 소개 URL을 지인에게 공유하여 많은 지인에게 ConoHa를 소개해 주세요.

소개 인원에 제한은 없습니다.


[지인 소개 순서]

1. "지인 소개" 화면 우측 위의 "+소개"를 클릭

2. 공유 방법을 선택하여 SNS에 올리거나 직접 메일 주소를 입력하여 소개 메일 전송

3. 지인이 고객님 전용 URL을 통해 ConoHa 계정을 등록

4. 소개한 지인의 ConoHa 계정에 1000엔 상당의 쿠폰이 증정됨

5. 소개한 지인이 ConoHa 서비스를 2000엔어치 이용

6. 소개인(고객님)의 ConoHa 계정에 2000엔 상당의 쿠폰이 증정됨


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 인터넷 속도 테스트 팁



리눅스에서 인터넷 속도가 어느 정도 나오는지 테스트 하는 방법입니다.


다음카카오 서버라서 꽤나 빠릅니다.


다운로드 샘플은 CentOS 7.2 최소설치 이미지입니다.


테스트 서버는 코노하 VPS


[root@conoha ~]# wget http://ftp.daumkakao.com/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso

--2016-04-14 14:01:27--  http://ftp.daumkakao.com/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso

Resolving ftp.daumkakao.com (ftp.daumkakao.com)... 113.29.189.165

Connecting to ftp.daumkakao.com (ftp.daumkakao.com)|113.29.189.165|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 632291328 (603M) [application/x-iso9660-image]

Saving to: ‘CentOS-7-x86_64-Minimal-1511.iso’


100%[======================================>] 632,291,328 10.9MB/s   in 55s


2016-04-14 14:02:22 (10.9 MB/s) - ‘CentOS-7-x86_64-Minimal-1511.iso’ saved [632291328/632291328]



다운로드 속도가 10.9MB/s 가 나왔네요. bps로 계산하면 87.2Mbps 입니다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 logrotate 장점 및 단점



리눅스에서 웹호스팅을 운영하다 보면 /var/log/httpd 에 엄청난 로그들이 쌓인다.


에러라도 발생한 경우엔 더욱 더 심하게 쌓이는데 계속 쌓이다 보면 하드 디스크 용량이 꽉 차서 서버가 느려질 수 있다.


/var 디렉토리만 파티션을 따로 잡아서 다른 서비스에는 지장이 안 생기게도 할 수 있겠지만,


이럴때 logrotate 를 활용하면 cron 에 의해 하루에 한번씩 로그들을 정리해서 하드 공간을 확보해 줄 수가 있다.


그런데 다운로드를 서비스 하는 웹호스팅을 운영 중이라면 logrotate 가 실행되면 그 타이밍에 다운로드 받다가 도중에 끊어지는 경우가 발생한다.


이유는 logrotate 가 실행되고 난 뒤에 아파치를 reload 하기 때문인데 이를 graceful 로 바꿔도 마찬가지다.


/etc/logrotate.d/httpd 파일의 내용을 보면


/var/log/httpd/*log {

    missingok

    #notifempty

    daily

    sharedscripts

    #delaycompress

    compress

    postrotate

        /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true

    endscript

    rotate 7

}


systemctl reload httpd.service 가 있어서 아파치가 reload 된다.


물론 새벽에 조용한 시간대에 사용자가 없는 경우라면 아무런 문제가 되지 않겠지만 혹시나 사용자가 있다면 다운로드 되다가 파일이 뚝 끊어져 다운로드가 종료가 되어 버린다. ( ps : CentOS 7.x 버전은 이상이 없음을 확인하였다. 아파치 2.2.x 버전대가 문제가 있는 걸까? )


이런 경우를 피할려면 /etc/logrotate.d/httpd 파일을 지우고 쉘스크립트를 따로 만들어주면 된다.


조금 귀찮긴 하지만 말이다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

리눅스 좀비 프로세스 죽이기



리눅스를 운영하다 보면 가끔씩 좀비 프로세스가 생길때가 있다.


아래 예제는 사실상 좀비 프로세스는 아니다. addconn 부모가 pluto 이고 pluto 는 ipsec 데몬에서 호출된 실행파일이다.



[root@conoha ~]# ps aux | grep Z

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND

root     14923  0.0  0.0      0     0 ?        Z    Apr11   0:00 [addconn] <defunct>

root     22986  0.0  0.0 112648   956 pts/0    R+   17:50   0:00 grep --color=auto Z


defunct 로 표시되는 것은 부모 프로세스를 kill 해야 죽는다.


pstree 명령어로 부모 프로세스를 알아보자.


[root@conoha ~]# pstree -pu

systemd(1)─┬─NetworkManager(13132)─┬─dhclient(13137)

           │                       ├─{NetworkManager}(13133)

           │                       └─{NetworkManager}(13135)

           ├─abrt-watch-log(641)

           ├─abrtd(620)

           ├─agetty(661)

           ├─agetty(662)

           ├─atd(654)

           ├─auditd(597)───{auditd}(606)

           ├─crond(652)

           ├─dbus-daemon(628,dbus)

           ├─firewalld(13217)───{firewalld}(13574)

           ├─httpd(17181)─┬─httpd(18200,apache)

           │              ├─httpd(18204,apache)

           │              ├─httpd(18205,apache)

           │              ├─httpd(18206,apache)

           │              ├─httpd(18207,apache)

           │              ├─httpd(18208,apache)

           │              └─httpd(21746,apache)

           ├─irqbalance(643)

           ├─lsmd(639,libstoragemgmt)

           ├─lvmetad(484)

           ├─master(1838)─┬─pickup(22907,postfix)

           │              └─qmgr(1856,postfix)

           ├─mysqld_safe(15498,mysql)───mysqld(15671)─┬─{mysqld}(15673)

           │                                          ├─{mysqld}(15674)

           │                                          ├─{mysqld}(15675)

           │                                          ├─{mysqld}(15676)

           │                                          ├─{mysqld}(15677)

           │                                          ├─{mysqld}(15678)

           │                                          ├─{mysqld}(15679)

           │                                          ├─{mysqld}(15680)

           │                                          ├─{mysqld}(15681)

           │                                          ├─{mysqld}(15682)

           │                                          ├─{mysqld}(15684)

           │                                          ├─{mysqld}(15685)

           │                                          ├─{mysqld}(15686)

           │                                          ├─{mysqld}(15687)

           │                                          ├─{mysqld}(15688)

           │                                          ├─{mysqld}(15689)

           │                                          ├─{mysqld}(15697)

           │                                          └─{mysqld}(15698)

           ├─ntpd(651,ntp)

           ├─pluto(14890)─┬─_pluto_adns(14922)

           │              ├─addconn(14923)

           │              └─{pluto}(14897)

           ├─polkitd(770,polkitd)─┬─{polkitd}(777)

           │                      ├─{polkitd}(779)

           │                      ├─{polkitd}(781)

           │                      ├─{polkitd}(782)

           │                      └─{polkitd}(784)

           ├─pptpd(14619)

           ├─qemu-ga(642)

           ├─rngd(621)

           ├─rsyslogd(627)─┬─{rsyslogd}(636)

           │               └─{rsyslogd}(637)

           ├─smartd(619)

           ├─sshd(1269)───sshd(22915)───bash(22917)───pstree(23049)

           ├─systemd-journal(471)

           ├─systemd-logind(622)

           ├─systemd-udevd(491)

           ├─tuned(1271)─┬─{tuned}(1454)

           │             ├─{tuned}(1458)

           │             ├─{tuned}(1461)

           │             └─{tuned}(1468)

           ├─wpa_supplicant(772)

           └─xl2tpd(14894)


14923의 부모 프로세스 ID 는 14890 이다.


kill -9 14890 명령어로 좀비 프로세스가 사라져야 하나 위의 pluto는 죽여도 다시 살아난다.


[root@conoha ~]# find / -name pluto

/run/pluto

/etc/sysconfig/pluto

/etc/pam.d/pluto

/var/log/pluto

/usr/libexec/ipsec/pluto


pluto 가 ipsec 서비스 관련 프로세스임을 알았다.


ipsec을 종료시키고 확인해보자.


[root@conoha ~]# systemctl stop ipsec.service

[root@conoha ~]# pstree

systemd─┬─NetworkManager─┬─dhclient

        │                └─2*[{NetworkManager}]

        ├─abrt-watch-log

        ├─abrtd

        ├─agetty

        ├─atd

        ├─auditd───{auditd}

        ├─crond

        ├─dbus-daemon

        ├─firewalld───{firewalld}

        ├─httpd───7*[httpd]

        ├─irqbalance

        ├─login───bash

        ├─lsmd

        ├─lvmetad

        ├─master─┬─pickup

        │        └─qmgr

        ├─mysqld_safe───mysqld───18*[{mysqld}]

        ├─ntpd───ntpd

        ├─polkitd───5*[{polkitd}]

        ├─qemu-ga

        ├─rngd

        ├─rsyslogd───2*[{rsyslogd}]

        ├─smartd

        ├─sshd───sshd───bash───pstree

        ├─systemd-journal

        ├─systemd-logind

        ├─systemd-udevd

        ├─tuned───4*[{tuned}]

        └─wpa_supplicant


이제 사라졌다.





블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

블로그스팟에 open graph 넣는 방법



기본적으로 블로그스팟 헤더에 og:url 과 og:image 두 가지의 정보는 헤더에 포함이 되어 있다.


단, 템플릿에 <b:include data='blog' name='all-head-content'/> 이 코드가 있다면 말이다.


url 과 image 외에 다른 open graph 정보도 넣어보자.


템플릿 편집화면을 열어서 아래 박스친 부분을 넣어주면 된다.



블로그스팟 Open Graph 넣는 방법블로그스팟 Open Graph 넣는 방법



      <meta content='article' property='og:type'/>

      <!--<meta expr:content='data:blog.url' property='og:url'/>-->

      <meta expr:content='data:blog.title' property='og:site_name'/>

      <meta expr:content='data:blog.pageTitle' property='og:title'/>

      <b:if cond='data:blog.metaDescription'>

      <meta expr:content='data:blog.metaDescription' property='og:description'/>

      </b:if>

      <b:if cond='data:blog.postImageUrl'>

      <!--<meta expr:content='data:blog.postImageUrl' property='og:image'/>-->

      </b:if>


og:url 과 og:image 는 기본적으로 나오기에 주석처리를 하였다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

아파치 access_log 로그에 ::1 안 나오게 하는 방법



로그에 ::1 ipv6 로그가 쌓이는게 영 신경쓰인다면 로그에 안쌓이게 해보자.


/etc/httpd/conf/httpd.conf 파일에서 아래부분을 찾아서 수정해주고 저장


   #CustomLog "logs/access_log" combined

    SetEnvIf Remote_Addr "^::1" no_log

    CustomLog "logs/access_log" combined env=!no_log


아파치 재시작 ( CentOS 7.x )

# systemctl restart httpd.service


6.x 버전이라면


service httpd restart


또는


apachectl restart



이제 나중에 로그가 쌓였는지 확인하면 된다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

MySQL Too many open files 에러 처리 방법



테스트 환경 : CentOS 7.2 / MariaDB 5.5.47


mysql 에러 로그에 "[ERROR] Error in accept: Too many open files" 이부분이 있다면 open_files_limit 수치를 올리면 된다.


그리고 ulimit -n 으로 시스템의 open files 수치 확인

1024로 나온다면 4096으로 바꿔보자.


일시적인 방법

# ulimit -n 4096

이 방법은 재접속 또는 재부팅하면 다시 이전으로 값이 돌아간다.


영구적인 방법

# vi /etc/security/limits.conf

*    -    nofile    4096

* - nofile 4096 내용 추가후 reboot (재접속 또는 재부팅)


MySQL 에서 open files limit 확인하기


show variables like 'open_files_limit';


Variable_name Value

open_files_limit 1024


1024 로 나온다면 이 수치를 4096으로 올려보자.


vi /etc/my.cnf


[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd


open_files_limit=4096


[mysqld_safe]

log-error=/var/log/mariadb/mariadb.log

pid-file=/var/run/mariadb/mariadb.pid


#

# include all files from the config directory

#

!includedir /etc/my.cnf.d



open_files_limit=4096 을 추가하고 저장


mysql 재시작


# systemctl restart mariadb.service


open files limit 재 확인


show variables like 'open_files_limit';


Variable_name Value

open_files_limit 4096



위 방법으로 안될때는 https://ivps.tistory.com/298 여기를 참고하세요.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

CentOS 7.x 아파치 2.4.x 다운로드 속도 제한하기



CentOS 에 국한 되는 것은 아니고 아파치 2.4 버전대에 해당되는 기능이다.


2.2 버전대에서는 cband 모듈로 트래픽 제한을 하였었는데


2.4 버전에서는 따로 모듈을 설치하지 않고도 속도 제한이 가능하다.



아무것도 건들지 않은체로 속도 테스트를 해보도록 하겠다.


[root@conoha html]# dd if=/dev/zero of=/var/www/html/100M.bin bs=1M count=100

100+0 records in

100+0 records out

104857600 bytes (105 MB) copied, 0.110541 s, 949 MB/s

[root@conoha html]# cd

[root@conoha ~]# wget http://conoha.ivps.kr/100M.bin

--2016-04-09 10:40:25--  http://conoha.ivps.kr/100M.bin

Resolving conoha.ivps.kr (conoha.ivps.kr)... 133.130.126.29

Connecting to conoha.ivps.kr (conoha.ivps.kr)|133.130.126.29|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 104857600 (100M) [application/octet-stream]

Saving to: ‘100M.bin’


100%[======================================>] 104,857,600  408MB/s   in 0.2s


2016-04-09 10:40:26 (408 MB/s) - ‘100M.bin’ saved [104857600/104857600]


100MB 사이즈의 파일을 만들어서 로컬호스트에서 wget 으로 다운로드 해보니 408MB/s 속도가 나왔다.


로컬이라서 빠른 것은 당연하겠지만 아무튼 속도 제한이 걸린 것으로 볼 수가 없는 속도가 나온다.


[root@virtualbox ~]# wget conoha.ivps.kr/100M.bin

--2016-04-11 10:48:49--  http://conoha.ivps.kr/100M.bin

Resolving conoha.ivps.kr (conoha.ivps.kr)... 133.130.126.29

Connecting to conoha.ivps.kr (conoha.ivps.kr)|133.130.126.29|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 104857600 (100M) [application/octet-stream]

Saving to: ‘100M.bin’


100%[======================================>] 104,857,600 8.71MB/s   in 12s


2016-04-11 10:49:20 (8.63 MB/s) - ‘100M.bin’ saved [104857600/104857600]


이번엔 다른 네트워크의 VirtuaBox 기반 vps 에서 다운로드 받은 결과다. 8.63MB/s 가 나왔다. 69.04Mbps 속도가 나온다.



이제 속도를 제한해 보도록 하겠다.


vi /etc/httpd/conf.modules.d/00-base.conf 파일에서 아래 부분을 찾아서 주석해제


#LoadModule ratelimit_module modules/mod_ratelimit.so


vi /etc/httpd/conf.d/ratelimit.conf 파일에 아래 부분 내용 저장


<IfModule mod_ratelimit.c>
    <Location />
        SetOutputFilter RATE_LIMIT
        SetEnv rate-limit 500
    </Location>
</IfModule>

500 은 500Kbps 의 의미이다. Location 은 특정 디렉토리를 지정할 수도 있다. 위에는 / 루트이므로 전체가 속도 제한이 된다.


아파치 재시작하고 다운로드 속도 테스트를 해보자.


[root@conoha ~]# systemctl restart httpd

[root@conoha ~]# wget http://conoha.ivps.kr/100M.bin

--2016-04-09 10:56:20--  http://conoha.ivps.kr/100M.bin

Resolving conoha.ivps.kr (conoha.ivps.kr)... 133.130.126.29

Connecting to conoha.ivps.kr (conoha.ivps.kr)|133.130.126.29|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 104857600 (100M) [application/octet-stream]

Saving to: ‘100M.bin.3’


100%[======================================>] 104,857,600  522KB/s   in 3m 25s


2016-04-09 10:59:45 (500 KB/s) - ‘100M.bin.3’ saved [104857600/104857600]


정확하게 500KB/s 속도가 나왔다.


속도 제어가 되고 있다는 결과이다.


로컬에서 받더라도 제한이 걸리며, 전체 트래픽에 대한 제한이 아닌 1 커넥션당 제한속도이다.



아파치 2.2 버전대라면 여기를 http://itrooms.tistory.com/111 참고해서 트래픽 제어가 가능하다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

아파치 웹서버 성능검사 도구



리눅스에서 웹서버 벤치마크(스트레스) 테스트 명령어 ab 라는 툴이 있습니다. 


웹서버의 성능 및 예상하는 동시접속자 수를 버틸 수 있는지 테스트 하는데 사용되며 튜닝에 이용되기도 합니다.


ab 명령어가 없다고 나오면 아래와 같이 설치하면 됩니다.


[root@virtualbox ~]# yum install httpd-tools

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirror.navercorp.com

 * epel: mirror.premi.st

 * extras: mirror.navercorp.com

 * updates: mirror.navercorp.com

Resolving Dependencies

--> Running transaction check

---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos will be installed

--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-tools-2.4.6-40.el7.centos.x86_64

--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-tools-2.4.6-40.el7.centos.x86_64

--> Running transaction check

---> Package apr.x86_64 0:1.4.8-3.el7 will be installed

---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


================================================================================

 Package            Arch          Version                     Repository   Size

================================================================================

Installing:

 httpd-tools        x86_64        2.4.6-40.el7.centos         base         82 k

Installing for dependencies:

 apr                x86_64        1.4.8-3.el7                 base        103 k

 apr-util           x86_64        1.5.2-6.el7                 base         92 k


Transaction Summary

================================================================================

Install  1 Package (+2 Dependent packages)


Total download size: 277 k

Installed size: 584 k

Is this ok [y/d/N]: y

Downloading packages:

(1/3): apr-1.4.8-3.el7.x86_64.rpm                          | 103 kB   00:00

(2/3): httpd-tools-2.4.6-40.el7.centos.x86_64.rpm          |  82 kB   00:00

(3/3): apr-util-1.5.2-6.el7.x86_64.rpm                     |  92 kB   00:20

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

Total                                               13 kB/s | 277 kB  00:20

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : apr-1.4.8-3.el7.x86_64                                       1/3

  Installing : apr-util-1.5.2-6.el7.x86_64                                  2/3

  Installing : httpd-tools-2.4.6-40.el7.centos.x86_64                       3/3

  Verifying  : apr-util-1.5.2-6.el7.x86_64                                  1/3

  Verifying  : httpd-tools-2.4.6-40.el7.centos.x86_64                       2/3

  Verifying  : apr-1.4.8-3.el7.x86_64                                       3/3


Installed:

  httpd-tools.x86_64 0:2.4.6-40.el7.centos


Dependency Installed:

  apr.x86_64 0:1.4.8-3.el7             apr-util.x86_64 0:1.5.2-6.el7


Complete!



테스트 방법은 아래와 같습니다.


[root@virtualbox ~]# ab -c 20 -n 500 http://conoha.ivps.kr/phpinfo.php

This is ApacheBench, Version 2.3 <$Revision: 1430300 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking conoha.ivps.kr (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Finished 500 requests



Server Software:        Apache/2.4.6

Server Hostname:        conoha.ivps.kr

Server Port:            80


Document Path:          /phpinfo.php

Document Length:        91191 bytes


Concurrency Level:      20

Time taken for tests:   10.072 seconds

Complete requests:      500

Failed requests:        55

   (Connect: 0, Receive: 0, Length: 55, Exceptions: 0)

Write errors:           0

Total transferred:      45704945 bytes

HTML transferred:       45595445 bytes

Requests per second:    49.64 [#/sec] (mean)

Time per request:       402.864 [ms] (mean)

Time per request:       20.143 [ms] (mean, across all concurrent requests)

Transfer rate:          4431.65 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:       65   87  13.5     93     125

Processing:   207  300  88.0    296     805

Waiting:       66  107  48.5     96     304

Total:        276  387  94.9    392     905


Percentage of the requests served within a certain time (ms)

  50%    392

  66%    401

  75%    411

  80%    422

  90%    489

  95%    551

  98%    691

  99%    735

 100%    905 (longest request)



500번 요청해서 55번 실패했다는 로그입니다.



▶ 옵션설명


-c 옵션 : 동시 요청수 (아래의 -n 횟수 보다 이하의 수여야 한다.)


-n 옵션 : 요청 횟수


# ab -c 20 -n 500 http://conoha.ivps.kr/phpinfo.php


동시에 20명이 요청하는데 합산해서 요청 수가 500 이라는 의미 ( 20 x 25 = 500 )


-c 5 -n 100 : 5 x 20 = 100


-c 100 -n 100 : 100 x 1 = 100


-c 3 -n 100 : 3 x 33 + 1 = 100




이제 아파치 튜닝중 하나인 mod_cache 모듈을 활용해서 cache 기능을 활성화 시켜서 테스트 해보도록 하겠습니다.


▶아파치 mod_cache 기능


아파치 2.2.x 버전은 두번째 줄에 아마도 mod_disk_cache.c 로 해주어야 합니다.


아래는 2.4.x 버전용인데 차이는 mod_disk_cache 이냐 mod_cache_disk 이냐 입니다.


아래의 내용을 /etc/httpd/conf/httpd.conf 파일에 추가해주던지 아니면


/etc/httpd/conf.d/cache.conf 파일을 신규로 생성해서 저장해 주면 됩니다.


<IfModule mod_cache.c>

    <IfModule mod_cache_disk.c>

        CacheEnable disk /

        CacheRoot /var/cache/mod_cache/tmp

        CacheDirLevels 2

        CacheDirLength 1

        CacheMaxFileSize 300000

        CacheMinFileSize 1

        #CacheIgnoreCacheControl On

        CacheIgnoreNoLastMod On

        CacheIgnoreQueryString Off

        CacheIgnoreHeaders None

        CacheLastModifiedFactor 0.1

        CacheDefaultExpire 300

        CacheMaxExpire 86400

        #CacheStoreNoStore On

        #CacheStorePrivate On

    </IfModule>

</IfModule>


이제는 위에 지정한 /var/cache/mod_cache/tmp 폴더를 만들어 줍니다. 물론 apache 접근 권한이 가능한 경로라면 자동으로 만들어집니다.


[root@conoha conf.d]# cd /var/cache

[root@conoha cache]# ll

total 4

drwx------  2 root root   22 Apr  7 11:01 ldconfig

drwxr-xr-x 34 root root 4096 Apr  7 03:33 man

drwxr-xr-x  3 root root   19 Apr  7 10:36 yum

[root@conoha cache]# mkdir -m700 mod_cache

[root@conoha cache]# mkdir -m700 mod_cache/tmp

[root@conoha cache]# chown -R apache.apache mod_cache


디렉토리를 생성해 주었다면 이제는 아파치를 재시작 해주고 테스트 하면 됩니다.


아파치 재시작은 CentOS 6.x 버전은 service httpd restart

7.x 버전은 systemctl restart httpd.service


[root@virtualbox ~]# ab -c 20 -n 500 http://conoha.ivps.kr/phpinfo.php

This is ApacheBench, Version 2.3 <$Revision: 1430300 $>

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/


Benchmarking conoha.ivps.kr (be patient)

Completed 100 requests

Completed 200 requests

Completed 300 requests

Completed 400 requests

Completed 500 requests

Finished 500 requests



Server Software:        Apache/2.4.6

Server Hostname:        conoha.ivps.kr

Server Port:            80


Document Path:          /phpinfo.php

Document Length:        91191 bytes


Concurrency Level:      20

Time taken for tests:   17.398 seconds

Complete requests:      500

Failed requests:        2

   (Connect: 0, Receive: 0, Length: 2, Exceptions: 0)

Write errors:           0

Total transferred:      45720566 bytes

HTML transferred:       45595498 bytes

Requests per second:    28.74 [#/sec] (mean)

Time per request:       695.910 [ms] (mean)

Time per request:       34.795 [ms] (mean, across all concurrent requests)

Transfer rate:          2566.37 [Kbytes/sec] received


Connection Times (ms)

              min  mean[+/-sd] median   max

Connect:       64   86  66.6     77    1135

Processing:   405  589 253.8    564    2083

Waiting:       63  156 232.0     92    1496

Total:        472  675 266.6    658    2182


Percentage of the requests served within a certain time (ms)

  50%    658

  66%    669

  75%    677

  80%    690

  90%    921

  95%   1334

  98%   1658

  99%   1770

 100%   2182 (longest request)


Failed requests 가 눈에 띄게 줄어들었습니다.


테스트 서버가 ConoHa VPS 서버인데다 램(1GB) 등 하드웨어 사양이 좀 딸려서 좀 더 심한 테스트를 하지 못한 점은 양해바랍니다.





블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,