SERVER/Etc2016. 11. 15. 16:32

1. 실제 여유 메모리 측정

리눅스의 경우 사용한 메모리에 대해서 캐쉬 영역에 반환하지않고 잡아 두고있음

그래서 서버 메모리 free 사이즈가 거의 없는 경우라고 판단 할 수 있음

실제로는 여유 메모리는 buffer_cache의 free로 보면됨


$ free -m -t
             total       used       free     shared    buffers     cached
Mem:         16042      15218        823          0        257       4649
-/+ buffers/cache:      10312       5730
Swap:         2043         14       2029
Total:       18086      15233       2852

자세한 설명은 아래 링크 참고

http://zetawiki.com/wiki/리눅스 명목메모리사용률, 실질메모리사용률


2. swap 사용 최소화

위에 보면 Buffer free가 있는데도 swap 발생하는 이슈가 있는 데 해당 이슈의 경우

swapoff 하던지 아니면 아래 같이 최소화 하는 방안이 있다.

#SWAP 사용량 최소화로 변경 (값범위 0 ~ 100 / 기본값 60 ) $ sysctl vm.swappiness=1 vm.swappiness = 1 #재부팅시에도 적용 $ vi /etc/sysctl.conf vm.swappiness = 1 #현재 swap 초기화 $ swapoff -a $ swapon -a #메모리 확인 $ free -m -t total used free shared buffers cached Mem: 16042 15168 874 0 258 4666 -/+ buffers/cache: 10244 5798 Swap: 2043 0 2043 Total: 18086 15168 2918

자세한 설명은 아래 링크 참고

 - http://zetawiki.com/wiki/리눅스_swappiness


3. 캐쉬 메모리 해체

0: 기본

1: Page cache를 해제 한다.

2: inode, dentry cache를 해제 한다.

3: Page cache, inode cache, dentry cache를 모두 해제 한다.

# Page cache 반환 처리

$ free -m -t
             total       used       free     shared    buffers     cached
Mem:         16042      15218        823          0        257       4649
-/+ buffers/cache:      10312       5730
Swap:         2043         14       2029
Total:       18086      15233       2852

$ echo 1 > /proc/sys/vm/drop_caches $ free -m -t total used free shared buffers cached Mem: 16042 10522 5519 0 2 359 -/+ buffers/cache: 10160 5881 Swap: 2043 0 2043 Total: 18086 10522 7563

자세한 설명은 아래 링크 참고

 - http://tumblr.lunatine.net/post/28546340998/faq-linux-메모리-효율을-위한-vfscachepressure

 - http://zetawiki.com/wiki/리눅스_캐시_메모리_비우기

Posted by 시니^^
SERVER/Nginx2015. 12. 10. 04:31

http://nginx.org/en/docs/http/ngx_http_ssi_module.html


보통은 웹어플리케이션단에서 include 기능을 지원하기 때문에 별 의미가 없을 수 있지만


요즘 같이 api 서버 따로 만들고 웹UI 개발쪽에서 html / css 작업 개별로 할 경우에


굳이 ws에 추가 어플리케이션을 깔지 않고 nginx만으로도 아래와 같이 include가 구현이 가능하다.



 include

Includes the result of another request into a response. The command has the following parameters:
file
specifies an included file, for example:
<!--# include file="footer.html" -->



그 이외에도 다양한 Command 처리가 많으니까 참고하면 좋을 듯하다.


Posted by 시니^^
SERVER/Nginx2015. 12. 10. 04:25

http://nginx.org/en/docs/http/ngx_http_sub_module.html


Example Configuration

location / {
    sub_filter '<a href="http://127.0.0.1:8080/'  '<a href="https://$host/';
    sub_filter '<img src="http://127.0.0.1:8080/' '<img src="https://$host/';
    sub_filter_once on;
}


위와 같이 특정 url 주소를 라이브 환경과 개발환경등 서버 셋팅환경에 따라서 다르게 적용해야되는 경우 활용하기 좋다


특히 개발존에서 CDN URL 로 개발하고 실제 해당 url들은 내부개발망 자체 img 나 js url를 보도록 한다던지 하면 소스 업로드할 때 소스 수정부분을 덜 수 있는 방안중에 하나 이기도 하다.

물론 어플리케이션단에서 빌드시 자동화 해놓았다면 크게 신경 쓸 내용은 아니지만...


그리고 해당 모듈을 이용하기 위해서는 설치시 --with-http_sub_module 지정을 해줘야만 한다.  

Posted by 시니^^
SERVER/Nginx2015. 12. 10. 04:19

http://nginx.org/en/docs/http/ngx_http_geo_module.html


nginx conf에서 아래 형태와 같이 각각의 아이피 별로 변수값을 지정 할 수 있다.

Example Configuration

geo $geo {
    default        0;

    127.0.0.1      2;
    192.168.1.0/24 1;
    10.1.0.0/16    1;

    ::1            2;
    2001:0db8::/32 1;
}


그래서 해당 변수를 이용해서 아래와 같이 특정 아이피 경우 Rewrite 시킨다던지 location 처리를 다르게 등 여러 방안으로 이용 할 수 있다. 점검시에 내부 아이피만 처리하고 외부 아이피는 notice페이지로 리다이렉트 시키다던지등 상황에 따라서 잘 활용하면 좋을 듯하다.


if ( $request_uri ~ /test_page ){ set $geo 1; } if ( $geo = 0 ){ rewrite ^ /test_page?; } if ($geo = 2) { proxy_pass http://ttt; break; }



Posted by 시니^^
SERVER/Etc2015. 1. 13. 11:05

iftop

 -  좀 오래되긴 한 툴인데 성능 테스트 할때 간단하게 네트워크로 들어오는 트래픽 실시간으로 체크하기 좋음



설치 방법은 Centos경우 간략하게 하면됨..
$ yum install iftop
왜만해서 저장소에 되어있을텐데 없으면 구글링하면 저장서 정보 많이 나옴

아니면 아래와 같이 소스 받아서 소스 설치 가능

$ sudo yum -y install ncurses-devel libpcap-devel $ wget http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.17.tar.gz $ tar xvfvz iftop-0.17.tar.gz $ cd iftop-0.17 $ ./configure $ make $ make install


그리고 옵션 명령어로 네트워크 카드 인터페이스 별로 지정가능하다.
$ iftop -i eth0

추가적인 정보는 -h 옵션으로 확인 가능하다.
$ iftop -h 






Posted by 시니^^
SERVER/Nginx2014. 8. 29. 15:28
IE나 크롬 개발자 도구로 Response Headers 보게 되면  아래와 같이 서버버젼과 PHP버젼이 적나하게 보이는 경우가 있다
항상 버젼 업데이트를 한다고 하면 문제 없겠지만 늘 버그/보안취약점이 나와서 버젼 업데이트가 되고 있는 중에 
해당 버젼을 확인하고 취약점을 해킹하는 경우가 발생한다 그래서 해당 정보의 경우 숨기는 게 보다 안전하다고 생각된다.

  1. Cache-Control:
    no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  2. Connection:
    keep-alive
  3. Content-Type:
    text/html; charset=UTF-8
  4. Date:
    Fri, 29 Aug 2014 06:22:59 GMT
  5. Expires:
    Thu, 19 Nov 1981 08:52:00 GMT
  6. Pragma:
    no-cache
  7. Server:
    nginx/1.6.1
  8. Transfer-Encoding:
    chunked
  9. X-Powered-By:
    PHP/5.5.15


※ X-Powered-By:PHP/5.5.15 삭제

vi /etc/php.ini

expose_php = Off <== OFF로 변경


※ Nginx 숨기기

http://wiki.nginx.org/HttpCoreModule#server_tokens

vi /etc/nginx/nginx.conf

server_tokens off; <==내용추가함


=> php와 nginx수정하였다면 php-fpm과 nginx 재시작해줘야됨


※ Nginx라는 서버이름을 바꾸고 싶을때

1. HttpHeadersMoreModule 추가모듈설치 하여서 셋팅

http://wiki.nginx.org/HttpHeadersMoreModule#Installation

※ 소스설치시 추가하면됨

./configure --prefix=/opt/nginx --add-module=/path/to/headers-more-nginx-module

※ set the Server output header 

    more_set_headers 'Server: my-server';


2. 컴파일전에 소스코드에서 해당내용 삭제 또는 변경 

http://forum.nginx.org/read.php?11,1646

vi /path/to/nginx-0.*/src/http/ngx_http_header_filter_module.c lines 48 and 49:

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

static char ngx_http_server_string[] = "Server: nginx" CRLF;

static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;

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


※ Apache 경우

vi /etc/httpd/conf/httpd.conf

ServerTokens Prod

ServerSignature Off

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

ServerTokens Prod[uctOnly] => Server: Apache
ServerTokens Major => Server: Apache/2
ServerTokens Minor => Server: Apache/2.0
ServerTokens Min[imal] => Server: Apache/2.0.41
ServerTokens OS : Server => Apache/2.0.41 (Unix)
ServerTokens Full : Server => Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.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 시니^^
SERVER/Nginx2014. 5. 21. 15:01

http://wiki.nginx.org/Install


Nginx yum install( CentOS6 )


1) nginx 에서 제공해주는 저장소 등록

$ rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

Retrieving http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

warning: /var/tmp/rpm-tmp.U4wAT5: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY

Preparing...                ########################################### [100%]

   1:nginx-release-centos   ########################################### [100%]

$ ll /etc/yum.repos.d/

-rw-r--r--  1 root root  113 Oct 14  2011 nginx.repo

$ yum repolist

nginx                                                              nginx repo                                                                        56

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

CentOS 5.x :

wget http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm

rpm -Uvh nginx-release-centos-5-0.el5.ngx.noarch.rpm

CentOS 6.x :

wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

rpm -Uvh nginx-release-centos-6-0.el6.ngx.noarch.rpm

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


2) yum install

$ yum install nginx

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

 Package                           Arch                             Version                                     Repository                         Size

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

Installing:

 nginx                             x86_64                           1.6.0-1.el6.ngx                             nginx                             335 k


3) conf 설정파일

$ vi /etc/nginx/nginx.conf

$ vi /etc/nginx/conf.d/default.conf


4) Nginx 실행 및 명령어

$ /etc/init.d/nginx 

Usage: nginx {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}

$ /etc/init.d/nginx start

Starting nginx: [  OK  ]

$ ps aux | grep nginx

root     30106  0.0  0.0  45040  1124 ?        Ss   14:52   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

nginx    30107  0.0  0.0  45412  1732 ?        S    14:52   0:00 nginx: worker process  


 

 

 

※ 소스설치

소스파일 다운로드 : http://nginx.org/en/download.html 

컴파일 옵션 참조 : http://wiki.nginx.org/InstallOptions





Posted by 시니^^
SERVER/Etc2014. 5. 21. 11:22

미디어 위키 갤러리페이지 보니까 너무 느려서 답답하고 브라우져가 뻗음......


확인결과 썸네일 기능이 전혀 사용하지 않아서 원본이미지가......ㄷㄷㄷ


그래서 찾아보니 썸네일 기능을 제공하는 듯하다


http://www.mediawiki.org/wiki/Manual:Installing_third-party_tools

Image thumbnailing

Image thumbnailing requires either ImageMagick or GD library. ImageMagick is recommended since it produces better quality thumbnails. It can be downloaded from http://www.imagemagick.org. GD can be downloaded fromhttp://boutell.com/gd.

ImageMagick

MediaWiki can be configured to use ImageMagick to do dynamic resizing and thumbnailing of images. ImageMagick is available for Windows, Unix, Mac OS, and Linux from http://www.imagemagick.org/script/index.php. Once ImageMagick is installed, you must enable ImageMagick and point MediaWiki to the convert or convert.exe program on your computer in LocalSettings.php like this:

$wgUseImageMagick = true;
#$wgImageMagickConvertCommand = 'C:/ImageMagick/convert.exe'; # for windows
$wgImageMagickConvertCommand = '/usr/bin/convert'; # for linux

For information on configuring MediaWiki for images in general see Manual:Image Administration and Manual:Configuration settings#Images. For information on installing ImageMagick on Windows, see Manual:Newcomers guide to installing on Windows#ImageMagick.


보니까  ImageMagick 깔려있어야되는 듯함


※ 설치과정

1) ImageMagick 설치

yum install ImageMagick

========================================================================================================= Package                      Arch                  Version                               Repository              Size

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

Installing:

 ImageMagick                  x86_64                6.5.4.7-7.el6_5                       updates                1.7 M

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


2) 홈디렉토리에 LocalSettings.php 설정파일에서 썸네일 기능 활성화 주석제거

$wgUseImageMagick = true; 
$wgImageMagickConvertCommand = "/usr/bin/convert";

//리눅스 프로세스 리스트 보니까....썸네일 자체가 백엔드에서 Shell 로 돌는듯하다.

//window서버의 경우 위에 for windows 참조


3) 썸네일 불가 에러 발생 이미지 용량 너무큼.. thumbnail Shell 처리시 사이즈가 설정 메모리 용량 초과

$wgMaxShellMemory라는 게 있다!! 아래 링크참조

http://www.mediawiki.org/wiki/Manual:$wgMaxShellMemory


그래서 LocalSettings.php 에 아래 MaxShellMemory 변수값 추가함

$wgMaxShellMemory = 1024000;

//Note: 102400 KB = 100 MB, 307200 KB = 300 MB, etc.

//나 같은 경우 MaxUploadSize 와 동일하게 맞추어주었다

//회사 내부적이나 공개용이 아닌 일부 소수 사용자간에 사용되는 위키라면 넉넉하게 설정해 놓는 게 좋을듯함


Posted by 시니^^
SERVER/Etc2014. 4. 2. 12:03

※ Linux에 Subversion(svn) SERVER YUM으로 빠르고 간단하게 설치하기


1. yum install 설치

$ yum install subversion


2. SVN 저장소 생성

$ mkdir /data/svn


3. 프로젝트 폴더생성

$ svnadmin create --fs-type fsfs /data/svn/project

※ --fs-type 저장소타입 fsfs(기본값) 또는 bdb | CREATE 옵션에 자세한 것은 생략!


4. 권한설정

$ vi /data/svn/project/conf/svnserve.conf

※ 기본적으로 다 주석처리되어있으니 아래 내용 추가

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

[general]

anon-access=none #read:미인증자 읽기가능, none:미인증자 접근불가

auth-access=write  #인증사용자 쓰기권한 부여

password-db=passwd #id/pw등록된 파일 

#realm=project_name #저장소 인증시 나오는 타이틀명

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


5. 인증계정 등록

$ vi /data/svn/project/conf/passwd 

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

[users]

userid=password

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


6. svnserver config파일 확인

$ view /etc/init.d/svnserve <==참고 

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

# processname: svnserve

# config: /etc/sysconfig/svnserve

# pidfile: /var/run/svnserve.pid

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


7. conifg에 저장소 threads 등록

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

OPTIONS="--threads --root /data/svn"

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


8. 데몬실행

$ /etc/init.d/svnserve start

Starting svnserve: [  OK  ]


9. 프로세스확인

$ ps aux | grep svn

root      4876  0.0  0.1 174848  1040 ?        Ss   12:10   0:00 /usr/bin/svnserve --daemon --pid-file=/var/run/svnserve.pid --threads --root /data/svn


10. 포트확인

$ netstat -atnp | grep svn

tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      4876/svnserve


11. 윈도우에서 TortoiseSVN 접속 확인

URL : svn://ipadders/project


끝~!!!

Posted by 시니^^