2016의 게시물 표시

nginx 설정정리

1. nginx 설정(universal drective) 위치 : /etc/nginx/nginx.conf user  nginx; #몇개의 thread가 사용될지 정의한다. cpu cores 수를 넣어주면 된다. worker_processes  6;   error_log  /var/log/nginx/error.log warn; pid        /var/run/nginx.pid; events {     # worker process 하나당 몇개의 connection을 처리할지 뜻한다. (최대처리량 = worker process * worker connection)     worker_connections  1024;  } http {     include       /etc/nginx/mime.types;     default_type  application/octet-stream;     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '                       '$status $body_bytes_sent "$http_referer" '                       '"$http_user_agent" "$http_x_forwarded_for"';     access_log  /var/log/nginx/access.log  main;     sendfile        on;     #tcp_nopush     on;     keepalive_timeout  65;     #gzip  on;    #http 설정 경로     include /etc/nginx/conf.d/*.conf;  }

siege : 경량 벤치마크 테스터

- 대규모 테스트 보다는 개발한 페이지 단위의 테스트에 더 적합하다. - 개발자가 개발하면서 동시에 테스트해 정량적 데이터를 기준으로 성능개선이 가능한 점이 편리한거 같다. 설치법  우분투 : sudo apt-get install siege centos(linux) : yum install siege 사용법  siege -b -t5s http://localhost:3000      -b : 앱의 벤치마킹 테스트 여부를 표시. 각 요청에 지연은 발생하지 않음      -c : 동시 연결개수 default 10 -c50(50개 연결)      -t : 벤치마킹 테스트 시간, H, M, S로 표기 - t10s(10초간)   테스트 결과 구분 설명 Transactions Http 요청횟수 Availability 서버가 성공적으로 처리하는 소켓 연결의 확률 Elapsed time 전체 siege 테스트 하는데 걸리는 시간 Data transferred siege가 시뮬레이션 된 브라우저에 전송하는 전체 데이터량. 이 데이터는 컨텐트뿐만 아니라 헤더 정보까지 포함. 헤더 정보를 포함하고 있으므로 siege가 표시하는 전체 데이터량은  서버가 전달하는 양보다 규모가 더 크다. 특정 설정 파일에 있는 임의의 URL을 사용하는 internet모드로 설정된 상황에서 전체 전송 데이터량은 동작할때마다 각각 달라진다. Response time siege가 시뮬레이션 된 브라우저의 각 요청에 대해 걸린 평균 응답시간 Transaction rate 서버가 초당 처리할수 있는 트랜잭션 개수 Throughput 서버에서 시뮬레이션 된 브라우저로 초당 전송되는 평균바이트단위의 데이터량 Concurrency 동시 연결할수 있는 평균 개수이고, 증가할때마다 서버의 성능은 저하됨 Successful transactions 서버가 400 이하의 응답코드를 반환하는 횟수 Failed transactions 서버가 400

MySQL에서 권한설정(펌)

MySQL 에서 root 암호 설정 mysql admin을 이용하여 root 암호 설정 MySQL 을 처음 설치하면 root 암호가 설정되어 있지 않기 때문에 반드시 설치 후 바로 root 암호를 먼저 설정해주세요.%%% root 암호를 설정하기 위해서는 $ mysql admin -u root -p password new-password 이러한 명령을 실행하면 됩니다. 실행하면 패스워드를 입력하라고 하는데 처음 root의 패스워드는 없으므로 그냥 엔터를 치시면 root 패스워드가 변경됩니다. update문을 이용하여 root 암호 설정 $ mysql -u root mysql mysql > update user set password = password('new-password') where user = 'root'; mysql > flush privileges; set password를 이용하여 root 암호 설정 mysql > set password for root = password('new-password'); 마지막으로 패스워드가 재대로 변경되었는지 테스트를 합니다. $ mysql -u root -p MySQL 에서 Database 보기와 생성 데이터베이스 보기 myslq> show databases; 데이터베이스 생성 mysql > create database DB명; MySQL 에서 새로운 사용자 추가 MySQL 에서 사용할 Database를 만든 후에 사용자를 추가하려면, 일단 root로 접속한 후 $ mysql (?h localhost) ?u root ?p Enter password: ******* mysql > use mysql mysql > INSERT INTO user VALUES('%', '사용자', PASSWORD('비밀번호'),

AOP 로깅과 성능측정 Interceptor

출처 : http://whiteship.tistory.com/1099 디버그 인터셉터 :: org.springframework.aop.interceptor.DebugInterceptor 성능 측정 인터셉터 :: org.springframework.aop.interceptor.PerformanceMonitorInterceptor 사용법은 ProxyFactoryBean으로 간단하게 설정하여 사용할 수 있습니다. < bean id="proxy"         class="org.springframework.aop.framework.ProxyFactoryBean">         <property name="target" ref="" />         <property name="interceptorNames">             <list>                 <value>global*</value>             </list>         </property> </bean> <bean id="global_debug"         class="org.springframework.aop.interceptor.DebugInterceptor" /> <bean id="global_performance"         class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor" /> <bean id="xstreamMarshaller"            class="com.namo.pt.common.oxm.CustomXStream

웹상에 퍼져있는 slf4j 연동관련 정리

일반적으로 사용되는 Facade 로깅 라이브러리는 JCL(http://commons.apache.org/logging/), SLF4J(http://www.slf4j.org/) 두개인거 같다. 이 두개의 라이브러리 모두 실제 로깅처리는 log4j 같은 실제 구현라이브러리들에 처리를 맡기는 구조이다. 자 그럼 이 두개의 라이브러리 중에 어떤걸 주로 쓰느냐 하면 SLF4J 라이브러리 이다. JCL은 실제 로그 구현체를 선택하는 시점이 런타임이라 다중 클레스로더(ClassLoader)를 사용하는 환경에서 문제가 될수 있고 런타임시점에 동작하기 때문에 성능상에 이슈 또한 있다고 한다. 더불어서 SLF4J는 로그 출력시 포멧팅을 지원하기 때문에 JCL을 사용할때의 아래와 같은 불편함을 해결해준다. 성능상 심하게는 30배정도 더 빠르다고 한다. 믿거나 말거나..-_- EX) JCL if( log.isDebugEnabled() ) {    log.debug(name + "님 안녕하세요"); } EX) SLF4J logger.deubg("{}님 안녕하세요", name); 이 두개의 예들은 같은 결과를 만들지만 보다시피 JCL을 사용할때 로그레벨을 확인하는 IF문이 SLF4J에는 빠져있다. 또한 SLF4J는 해당로그 레벨에서만 인자로 주어진(name) 값을 적용하기 때문에 로그레벨을 더이상 걱정할 필요가 없 Log4j-slf4j연동 log4j가 설정되어있다는 기준으로 보았을때 slf4j 는 퍼사드 객체임을 명심해야 한다. 그자체로 로깅기능보다는 메이븐 설정 <dependency>             <groupid>org.slf4j</groupid>             <artifactid>slf4j-api</artifactid>             <version>${o

[CentOS] Sonatype Nexus 이사하기(출처 - http://bestist.pe.kr/author/bestist)

$ NEXUS _HOME을 참고하여 sonatype-work 폴더를 백업한다.(설치계정에 sonatype-work 폴더에 생성된다) 1 $ tar cvf sonatype - work . tar sonatype - work / sonatype 사이트에서  nexus  파일을 받아 설치준비를 한다. 1 2 3 $ wget http : //www.sonatype.org/downloads/ nexus -latest-bundle.tar.gz $ tar xvf nexus - latest - bundle . tar . gz 백업 받았던 sonatype-work.tar를 working directory를 지정하여 풀어준후 환경설정을 한다. 1 2 3 4 $ vi . / conf / nexus . properties # Nexus section nexus - work = $ { bundleBasedir } / . . / sonatype - work / nexus nexus 는 root 사용자로 실행할 경우 보안이슈가 있으므로 별도로 사용자를 만들어 실행하는것을 추천한다. 1 2 3 4 $ useradd nexus # nexus 폴더의 권한을 nexus 에게 준다. $ chown - R nexus : nexus nexus nexus  실행 스크립트를 /etc/init.d로 복사한다. 1 $ cp . / bin / nexus / etc / init . d / nexus  실행 스크립트를 수정하며, 이때 v