TCP RST 보내기TCP RST 보내기

Posted at 2012. 12. 28. 10:02 | Posted in Server

tcp 소켓을 닫을때 일반적으로는 normal tcp termination(4way closing handshake) 과정을 거치게 된다.

이 때, 소켓을 먼저 close한 쪽에 TIME_WAIT 상태로 소켓이 남아 있게 된다.

만약 서버가 먼저 close한 경우 TIME_WAIT 소켓이 가득차서 더 이상의 소켓을 accept 할 수 없는 상황이 발생할 수 있다.

이럴 때의 대안으로 normal tcp termination이 아닌 abortive close로 TIME_WAIT이 발생하지 않도록 할 수 있다.

(TIME_WAIT 상태가 왜 있는지 정확히 알고, 특정 상황에서만 사용하자.)


SO_LINGER with timeout 0

로 설정하고 close()를 호출하면 TCP FIN 대신 RST 이 나간다.

peer는 그 유명한 "Connection reset by peer" 에러가 발생하게 된다.


상세는 다음 글을 참조하자.

according to "UNIX Network Programming" third edition page 202-203, setting SO_LINGER with timeout 0 prior to calling close() will cause the normal termination sequence not to be initiated.


http://stackoverflow.com/a/13088864


//

[mybatis] selectOne vs selectList[mybatis] selectOne vs selectList

Posted at 2012. 12. 21. 10:26 | Posted in 개발이야기

org.mybatis.spring.SqlSessionTemplate

- selectOne

  • 쿼리의 결과가 없으면 null을 반환한다. 또한, 쿼리의 결과로 레코드가 하나만 나와야 한다.
  • DB에 하나의 레코드만 있는 경우 사용. 그렇지 않으면 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException 이 발생한다.

- selectList

  • 쿼리의 결과를 List<E>로 반환한다. 결과가 없으면, 빈 List를 반환한다.
  • selectList()가 null을 반환하지는 않는다.



//

curl 활용하기curl 활용하기

Posted at 2012. 12. 21. 10:02 | Posted in 개발이야기

<post 호출>

curl -d @data.txt http://localhost:8080

curl -d "12345" http://localhost:8080

curl -X POST -d "12345" http://localhost:8080

curl -H "Accept: application/json" -H "Content-Type: application/json" --fail -d @data.txt http://localhost:8080



<file download>

curl -O http://redis.googlecode.com/files/redis-2.6.9.tar.gz

curl -o taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701


wget http://redis.googlecode.com/files/redis-2.6.9.tar.gz

wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701


//

윈도우7 파일권한 설정하기윈도우7 파일권한 설정하기

Posted at 2012. 12. 9. 13:50 | Posted in OS/MS Windows

다른데서 사용하던 하드디스크를 꽂아서 사용할 때 파일 소유권이 없다거나, 권한이 없다거나 할 때

다음 도구를 사용해서 일괄 권한 편집이 가능하다.

"탐색기 메뉴 > 속성 > 보안 > 편집" 으로 들어가서 해줘도 되나, 번거롭다.


takeown: 소유권 가져오기(설정하기)


> takeown /F "파일 또는 폴더" /R /D Y

    /F: 파일

    /R: Recursive

    /D: Prompt (Y/N)

    /A: 현재 사용자가 아닌 관리자에 소유권을 준다.


icacls: 접근권한 설정하기(ACL설정)


> icacls "파일 또는 폴더" /grant deepblue:F /T

> icacls "파일 또는 폴더" /grant deepblue:(R,W) /T    특정 사용자에게 허용

> icacls "파일 또는 폴더" /grant Administrator:F /T   관리자에게 허용

> icacls "파일 또는 폴더" /grant Everyone:F /T        모든사용자에게 허용

    /T: Recursive

//

sar 간단 정리sar 간단 정리

Posted at 2012. 11. 12. 01:21 | Posted in OS/Unix/Linux

sar 에서 날짜가 깨져서 나올때, (mpstat, vmstat 등 다른 도구들도 마찬가지)

LC_TIME=C 로 설정하면 됨. (LC_TIME= 하면 원래대로 돌아감. LC_ALL 또는 LANG 의 값을 사용하게 됨.)

LANG 또는 LC_ALL=C로 해도 무방. 자세한건 locale 설정 방법 검색 ㄱㄱ


sar [-u] 가 기본

sar -s <hh:mm:ss> -e <hh:mm:ss>  로 시작/끝 시간 지정할 수 있다.

sar <interval> <count> 로 정해진 주기로 자동 호출되게 할 수 있다.

sar -f /var/log/sa/sa16  해당날짜(16일)의 통계를 본다.


sar -A  모든 정보 출력

sar -c  새롭게 만들어져 활동하고 있는 프로세스

sar -n DEV | EDEV | SOCK  네트워크 통계 (DEV: network device 통계, EDEV: network device 에러 통계, SOCK: socket 통계)

sar -q  실행 대기 중인 프로세스를 점검. 시스템의 load average를 나타낸다.


각 옵션별 상세 설명은 여기 참조: http://www.cubrid.com/zbxe/71317


//

대용량 데이터 분산, scale-out 에 대한 메모대용량 데이터 분산, scale-out 에 대한 메모

Posted at 2012. 10. 8. 14:14 | Posted in Server

gywn.net 의 텀블러와 Gizzard 분석 내용.

- http://gywn.net/2012/05/how_to_shard_big_data_in_tumblr/

http://gywn.net/2012/03/new-tweet-store/

- http://gywn.net/2012/03/gizzard-a-library-for-creating-distributed-datastores/


대용량 시스템을 위한 데이타베이스 아키텍쳐-Sharding & Query Off Loading

http://bcho.tistory.com/670


id sharding (인스타그램)

-http://charsyam.wordpress.com/2011/12/04/instagram-%EC%97%90%EC%84%9C-id-%EC%83%A4%EB%94%A9%ED%95%98%EA%B8%B0/



<TBD>...





//

HBase에서 사용하는 hash functionHBase에서 사용하는 hash function

Posted at 2012. 10. 5. 23:22 | Posted in OpenSource

http://javasourcecode.org/html/open-source/hbase/hbase-0.90.3/org/apache/hadoop/hbase/util/Hash.java.html

  /**
   * This utility method converts String representation of hash function name
   * to a symbolic constant. Currently two function types are supported,
   * "jenkins" and "murmur".
   * @param name hash function name
   * @return one of the predefined constants
   */
  public static int parseHashType(String name) {
    if ("jenkins".equalsIgnoreCase(name)) {
      return JENKINS_HASH;
    } else if ("murmur".equalsIgnoreCase(name)) {
      return MURMUR_HASH;
    } else {
      return INVALID_HASH;
    }
  }

//

3G 모바일 네트워크에 대한 이해3G 모바일 네트워크에 대한 이해

Posted at 2012. 9. 20. 14:49 | Posted in Article

3G 모바일 네트워크에 대한 이해(NHN개발자블로그)

http://helloworld.naver.com/helloworld/111111


3G 네트워크에 대한 이야기+a (deview 2012)

http://deview.kr/2012/xe/index.php?mid=track&document_srl=397&time_srl=260


살펴보고 내용 정리하기.




//

Forward Proxy & Reverse ProxyForward Proxy & Reverse Proxy

Posted at 2012. 9. 19. 17:35 | Posted in Server

Forward Proxy

클라이언트가 타겟서버의 주소를 프록시에 전달하여, 프록시가 요청된 내용을 가져오는 방식

  예) 클라이언트 Proxy 설정에 proxy.com을 설정하고, 주소창에 target.com을 입력하여 브라우징.


Reverse Proxy

프록시 서버로 요청을 보내면 프록시 서버가 '배후'서버로 요청하여 내용을 가져오는 방식. 이 때 Reverse는 "거꾸로, 역전"이 아닌 "배후, 뒷쪽"의 의미임. 클라이언트는 '배후' 서버를 알 수 없다.

  예) 클라이언트가 proxy.com에 요청하면 프록시 서버가 target.com 서버로 요청하여 결과를 반환.

  예) 많이 쓰는 nginx의 proxy_pass 설정은 reverse proxy 이다.

//

grinder 사용팁grinder 사용팁

Posted at 2012. 9. 16. 15:23 | Posted in 개발이야기

grinder-3.8 버전 사용.

(이리 저리 해보고 해결한 것들만 메모함.)


grinder에 있는 jython 보다 높은 버전 사용하고 싶은 경우,

--> grinder/lib/jython-xxx.jar 를 빼고, property 및 실행 스크립트에 jython 설치 경로 및 classpath에 지정해 줬더니 되더라..

요렇게..

JYTHON_HOME=/usr/share/jython

JYTHON_CONFIG="-Dpython.home=$JYTHON_HOME -Dpython.path=$JYTHON_HOME/Lib"

CLASSPATH=$CLASSPATH:$JYTHON_HOME/jython.jar

java -cp $CLASSPATH $JYTHON_CONFIG net.grinder.Grinder


symbolic link 파일을 dist위치에 두고 배포하니 Agent에서 어러남.


agent 실행시 필요 jar 파일 미리 배포해둬야 한다. classpath에도 미리 잡아놔야 하고..

--> classpath에 ./lib/*.jar 와 같은식으로는 안먹네.. 모두 나열해주니 됨.


grinder.logger --> (grinder.hostID)-0.log 파일에 기록됨.


agent terminal에서 확인하려면 stdout으로 출력해서 보라.


grinder.statistics.delayReports = 1 는 TestRunner __init__ 에서 한번만하고, on/off 하지 않는다.


jython 스크립트 맨 밑줄에 공백 라인 한줄 넣어야 하더라..


jython 스크립트에 한글 쓰니 non-ascii character가 있다고 나불나불..

--> 첫째줄에 요렇게 넣어주면..

# _*_ coding: utf8 _*_



참고하기 좋은 글: http://www.cubrid.com/zbxe/71339

//