웹 트래픽 로그 순위 추출

Posted by 주원이^^
2016. 11. 3. 11:43 리눅스/스크립트
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#!/bin/bash
stty erase ^H
check="no"
#출력 기본값
view_number="20"

declare -a http_log_size_array
declare -a http_log_ip_array
declare -a http_log_filename_array

_comm() {
apache_log_file=""

#같은파일 중복제거 , 카운트
http_log_cnt="`cat $2 | awk '!x[$7]++' | sort -rn -k 10 | wc -l`"

#같은파일 중복제거, 문자열 내용 변수저장
IFS=$'\n' http_log_text=(`cat $2 | awk '!x[$7]++' | sort -rn -k 10`)

view_number=$1

#트래픽합산결과
total_sum=`cat $2 | awk '{sum += $10} END {print sum/1024000,"MByte"}'`

#리스트 배열에 담기 ip,filename,size 3개
#line 한줄출력
k="0"
http_log_number="0"

for value in "${http_log_text[@]}"; do
 if [[ $k -ge $view_number ]]; then
  break;
 fi

 echo "number : $k        total_number : $view_number "
 http_log_filename=`echo $value | awk '{print $7}'`
 http_log_ip=`echo $value | awk '{print $1}'`
 http_log_size=`echo $value | awk '{print $10}'`

 http_log_filename_array[$http_log_number]=${http_log_filename}
 http_log_ip_array[$http_log_number]=${http_log_ip}
 http_log_size_array[$http_log_number]=`echo ${http_log_size} | awk '{sum += $1} END {print sum/1024000,"MByte"}'`

 k=`expr $k + 1`
 http_log_number=`expr $http_log_number + 1`
 clear
done

#트래픽 용량 출력
echo -ne "Total Traffic $1 List
"
m=0

#트래픽 출력

for ((j=1;j<=$view_number;j++)); do
  echo  "${j}) ${http_log_filename_array[$m]} ${http_log_ip_array[$m]} ${http_log_size_array[$m]}"

  m=`expr $m + 1`
done

echo -ne "
1) Menu  2) Log File modify 3) View number modify x) exit
select number "

read select_comm
 case $select_comm in
  1)
   clear
   _default_select
   ;;
  2)
   if [[ ! -z $http_log_file_menu ]]; then
    http_log_dir="${http_log_file_menu}"
    http_log_dir_list="`ls $http_log_dir | grep log$`"
    http_log_dir_cnt=`ls $http_log_dir | grep log$ | wc -l`
    for ((i=1;i<=$http_log_dir_cnt;i++)); do
     http_log_dir_list=`ls $http_log_dir | grep log$ | sed -n "${i},${i}p"`
     http_log_dir_array[$i]=$http_log_dir_list
     echo "${i}) $http_log_dir_list"
    done
    echo "select log file number?"
    read http_log_file_number
    http_log_file="${http_log_dir}/${http_log_dir_array[$http_log_file_number]}"
   fi
   _comm "$view_number" "$http_log_file"
   ;;
  3)
   echo -ne " before : $view_number
modify number?"
                        read modify_view_number
                        view_number=`echo $modify_view_number | sed 's/[^0-9]//g'`
    
   clear
   _comm "$view_number" "$http_log_file"

   ;;
  x)
   exit
   ;;
 esac
}

_default_select() {
clear
while [ $check=no ]; do
echo -ne "
================ Default Information ================
1)Http Log File : $http_log_file

ex) /usr/local/apache/logs/transferlog

2)View number : $view_number

s) Start        x) Exit
======================================================
select number?"
read menu_select
        case $menu_select in
                1)
   echo -ne "
1)/usr/local/apache/logs/transferlog 2)input Dir
select number?"
#폴더 선택 및 파일 선택
   read http_log_file_menu
    case $http_log_file_menu in
     1)
      http_log_dir="/usr/local/apache/logs/transferlog"
      http_log_dir_list="`ls $http_log_dir | grep log$`"
      http_log_dir_cnt=`ls $http_log_dir | grep log$ | wc -l`
      for ((i=1;i<=$http_log_dir_cnt;i++)); do
       http_log_dir_list=`ls $http_log_dir | grep log$ | sed -n "${i},${i}p"`
       http_log_dir_array[$i]=$http_log_dir_list
       echo "${i}) $http_log_dir_list"
      done
      echo "select log file number?"
      read http_log_file_number
      http_log_file="${http_log_dir}/${http_log_dir_array[$http_log_file_number]}"
      _default_select
      ;;
     2) 
      echo "input your directory "
      read http_log_file_menu
      if [[ ! -z $http_log_file_menu ]]; then
       http_log_dir="${http_log_file_menu}"
       http_log_dir_list="`ls $http_log_dir | grep log$`"
       http_log_dir_cnt=`ls $http_log_dir | grep log$ | wc -l`
       for ((i=1;i<=$http_log_dir_cnt;i++)); do
        http_log_dir_list=`ls $http_log_dir | grep log$ | sed -n "${i},${i}p"`
        http_log_dir_array[$i]=$http_log_dir_list
        echo "${i}) $http_log_dir_list"
       done
       echo "select log file number?"
       read http_log_file_number
       http_log_file="${http_log_dir}/${http_log_dir_array[$http_log_file_number]}"
      fi
      _default_select
      ;;
    esac


   _default_select
   ;;
                2)
                        echo -ne "View number?"
                        read tmp_view_number
                        tmp2_view_number=`echo $tmp_view_number | sed 's/[^0-9]//g'`
                        if [[ ! -z "$tmp2_view_number" ]]; then
                                view_number=${tmp2_view_number}
                                _default_select
                        else
                                _default_select
   fi
                        ;;

  x)
   exit
   ;;
   
  *)
  clear
  if [[ ! -z $http_log_dir ]] && [[ ! -z $view_number ]]; then
   _comm "$view_number" "$http_log_file"
  fi
  _default_select
  ;;

        esac
clear
_default_select
done
}

_default_select

 

log.txt

 

'리눅스 > 스크립트' 카테고리의 다른 글

system 정보보기 스크립트  (0) 2017.01.31
ssh_bruteforce 자동차단  (0) 2016.11.04
apache 자동다운받기  (0) 2016.03.04
mysql replication 상태체크  (0) 2016.01.13
폴더내 파일 소문자로 일괄변경  (0) 2015.07.16

nginx 부하분산

Posted by 주원이^^
2016. 11. 1. 16:03 리눅스/웹서버(WAS)
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

 

1. Proxy에 대하여

Proxy 서버는 클라이언트가 자신을 통해서 다른 네트워크 서비스에 연결하게 중계해주는 소프트웨어다.

 

 프락시 서버 개요

 

웹 서비스를 예로 들어보자. 클라이언트(웹 브라우저)는 웹 서버에 직접 연결하는 대신에 프락시 서버에 연결해서 웹 페이지를 요청한다. 이 요청을 읽은 프락시 서버는 웹 서버에 요청을 전달하고, 응답을 받아서 클라이언트에 전송한다. 인터넷 서비스의 규모가 커지면서, 분산 시스템으로 서비스가 구성되는 경우가 많다. 프락시 서버를 이용하면 분산 시스템을 뒤에 숨기는 방식으로 시스템을 단순화 할 수 있다.

 

클라우드 기반 시스템에 서비스를 구축할 경우, 분산 시스템으로 구축하는 경우가 많다. 클라우드 시스템 구축의 핵심 요소며, 사용자 입장에서도 이래 저래 응용할 거리가 많다.

 

2. 클라우드 환경에서의 프락시

가상화와 클라우드 관련된 일을 하고 있다. 과거에는 직접 만드는 일을 했었고, 최근 들어서는 클라우드 인프라 위에서 서비스를 만드는 일을 하고 있다. 클라우드를 기반으로 하는 서비스들은 높은 확률로 분산이 된다. 또한 서비스를 구성하는 자원(데이터베이스, 인스턴스, 컨테이너 등)은 인터넷으로 부터 격리된 공간에 만들어 진다. 따라서 인터넷으로 부터의 요청을 받아서 내부(AWS의 경우 VPC)의 분산된 자원에 요청을 전송하는 프락시가 매우 중요하다.

 

다양한 프락시 타입 중에서 HTTP를 기반으로 하는 리버스 프락시에 대해서 살펴볼 생각이다.

 

3. 리버스 프락시

리버스 프락시는 일반적인 인터넷 서비스에서 널리 사용하고 있다. 리버스 프락시는 유저의 요청을 받아서 반대편(reverse)네트워크에 있는 인터넷 서버에 전달 하는 일을 한다. 리버스 프락시 서버는 단순히 요청을 전달하기만 할 뿐으로 요청의 처리는 뒷단에 있는 웹 서버들이 맡아서 한다. 따라서 하나의 리버스 프락시 서버가 여러 웹 서버로 요청을 전달하도록 구성 할 수 있다. 예컨데 로드 밸런서로의 역할을 수행 할 수 있다. 실제 HAProxy, NginX, Apache 웨서버들이 가지고 있는 리버스 프락시 기능을 이용해서 소프트웨어 기반의 로드밸런싱 환경을 구축하기도 한다.

 

소프트웨어 기반인 만큼 전용 로드밸런서 보다는 성능이 떨어질 수 있지만, 저렴한 비용과 이에 따르는 무지막지한 확장성으로 단점을 커버하고 있다. 클라우드 환경에서 사용할 로드밸런서라면 소프트웨어로 구축하는게 거의 당연하게 여겨진다.

 

4. 리버스 프락시 테스트 환경

처음엔 오픈소스 프락시로 HAProxy를 생각했다. HAproxy는 로드밸런서로 사용하기에는 괜찮은 선택이었으나 다양한 활용이 필요한 리버스 프락시로 사용 하기에는 기능에 한계가 있었다. 그래서 NginX를 사용하기로 했다. NginX외에 Apache를 사용 할 수도 있었겠는데, 웹서버로서의 다양한 기능 보다는 NginX의 성능이 더 중요했다.

 

VirtualBox로 테스트 환경을 만들었다.

 

 Reverse Proxy를 위한 테스트 환경

 

  • 두 개의 호스트 전용 네트워크를 만들었다. 하나는 외부에 연결하기 위해서 사용하고 다른 하나는 내부에 있는 웹 서버에 연결하기 위해서 사용한다.
  • Proxy server는 유저의 요청을 받아서 밑에 있는 web-01과 web-02로 요청을 중계한다.

5. 정적 리버스 프락시 서버 구성

가장 기본적인 리버스 프락시 구성이다. 일반적인 로드밸런서라고 보면 된다. upstream영역에 프락시 대상 호스트의 목록을 설정하면 된다. upstream은 proxy할 타겟 서버를 설정하기 위해서 사용한다.
1
2
3
4
upstream test_proxy {
server web-01;
server web-02;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
test_proxy는 upstream의 이름이다. NginX는 하나 이상의 upstream으로 구성할 수 있으며, 이름으로 구분할 수 있다.

 

이제 test_proxy를 upstream으로 사용하도록 server 설정을 변경하면 된다. 아래는 완전한 설정파일이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# cat /etc/nginx/sites-available/default
upstream test_proxy {
server web-01;
server web-02;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://test_proxy;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
location / 에 대한 모든 요청에 대해서, test_proxy로 중계하라고 설정했다.

 

5.1. 로드 밸런싱 메서드

Nginx는 4개의 로드밸런싱 메서드를 제공한다.

 

라운드로빈(Round-robin)은 기본으로 사용하는 메서드로 모든 서버에 동등하게 요청을 분산한다.
1
2
3
4
upstream test_proxy {
server web-01;
server web-02;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

least_conn은 연결이 가장 작은 서버로 요청을 보낸다.
1
2
3
4
5
6
upstream test_proxy {
least_conn;
server web-01;
server web-02;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

ip_hash는 클라이언트 IP주소를 기준으로 요청을 분배한다. IP주소가 같다면, 동일한 서버로 요청을 전송한다.
1
2
3
4
5
6
upstream test_proxy {
ip_hash;
server web-01;
server web-02;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

hash는 유저가 정의한 key나 변수 혹은 이들의 조합을 해시해서 분산한다. key로 소스 IP나 포트 URI 등을 사용 할 수 있다.
1
2
3
4
5
6
upstream test_proxy {
hash $request_uri consistent;
server web-01;
server web-02;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
hashconsistent파라메터를 사용 할 수 있다. consistent를 사용하면 Ketama 컨시스턴시 해시 알고리즘을 이용해서 upstream 그룹에 서버가 추가 되거나 삭제 될 때, 키의 분배를 최소화 함으로써 캐시 실패를 줄일 수 있다.

 

least_time메서드는 NginX Plus에서 지원한다. 평균 레이턴시와 연결을 기준으로 검사해서 로드가 적은 서버로 요청을 보낸다.
1
2
3
4
5
6
upstream test_proxy {
least_time header;
server web-01;
server web-02;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
header는 첫번째 바이트를 받을 때까지의 지연, last_byte는 모든 요청을 받을 때까지의 지연시간을 기준으로 삼는다.

 

6. 프락시 응용

정적 프락시는 upstream 서버가 결정되 있다. 일반적인 웹 서비스라면 이 정도로 사용하는데 문제 없을 것이다. server가 추가되거나 삭제 할 경우 upstream 그룹을 수정해야 하겠지만 수정이 빈번하지 않으니 문제될게 없다.

 

하지만 클라우드 환경에서는 프락시 설정이 동적으로 이루어져야 할 필요가 있다. 컨테이너 기반으로 웹 서비스를 제공한다면, 빈번하게 프락시 설정이 바뀔 수 있을 것이다. 웹 서비스들이 수시로 올라올 테고, 웹 서비스를 위한 도메인 이름도 계속 변경될 것이다. 이런 환경에서의 프락시 응용에 대해서 살펴보려 한다.

 

6.1. 도메인 이름 기반 dynamic Proxy

Slack이나 Jira와 같은 클라우드 기반의 인터넷 서비스를 한다고 가정해보자. 유저가 클라우드 서비스를 구축하면, 도메인도 함께 만들어줘야 할 것이다. 예컨데 jira라면, user-01.jira.com, user-02.jira.com과 같이 유저별로 도메인을 제공해야 한다. 대략 아래와 같은 구성이 될 것이다.

 

 Domain Name 기반 Proxy

 

이 방식의 서비스를 위해서는 DNS 서버의 도움이 필요하다. DNS 서버에 아스테리크(*)도메인에 대해서 Proxy 서버를 CNAME 혹은 A 레코드에 등록한다. 호스팅 업체를 통해서 DNS 서비스를 받는다면, 아스테리크를 지원하는지 확인을 해야 한다. 대부분이 아스테리크를 지원하지만 몇 몇 지원하지 않는 호스팅 업체도 있다.

 

이 서비스는 다음과 같이 작동 한다. Jira를 기준으로 설명한다.
  1. 유저가 user_01이라는 이름으로 jira 서비스를 구입했다. Jira는 user_01.jira.com 도메인을 유저에게 할당한다.
  2. Jira는 user_01.jira.com을 위한 서비스 인스턴스를 만들고 내부 DNS에 이 정보를 등록한다.
  3. 유저가 브라우저로 user_01.jira.com에 접속하려 한다.
  4. ns.jira.com에 네임 정보를 요청한다. ns.jira.com은 *.jira.com에 등록된 Proxy의 IP를 되돌려 준다.
  5. 유저는 Proxy 서버에 접속한다.
  6. Proxy Server는 HTTP의 Host 필드의 user_01.jira.com을 읽어서, 이 도메인에 대한 IP를 찾는다.
  7. user_01.jira.com에 대한 인스턴스 IP로 요청을 proxy 한다.
이 서비스를 테스트 하려면, DNS 서버를 구축해야 한다. 꽤나 복잡 할 것 같지만 dnsmasq를 이용하면 간단하게 테스트 환경을 만들 수 있다. 아래는 테스트 환경이다.

 

 dnsmasq를 이용한 네임서버 기반 proxy

 

테스트를 위해서 4개의 인스턴스를 만들었다. 먼저 DNS Instance에 dnsmasq를 설치한다.
1
# apt-get install dnsmasq
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

*.test.priv에 대해서 proxy server ip를 알려주도록 설정을 변경했다.
1
2
3
# cat /etc/dnsmasq.conf
....
address=/.test.priv/192.168.56.10
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
이제 *.test.priv 요청에 대해서 NginX Proxy server의 IP를 반환한다.

 

그리고 web-01.test.priv와 web-02.test.priv를 등록한후 dnsmasq 서버를 리로드 했다.
1
2
3
4
# cat /etc/hosts
...
192.168.57.3 web-01.test.priv
192.168.57.4 web-02.test.priv
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

호스트 운영체제에서 curl로 테스트 할 생각이다. /etc/resolv.conf 파일을 수정했다.
1
2
3
4
# cat /etc/resolv.conf
nameserver 192.168.56.10
# service nginx reload
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

네임을 제대로 찾는지 테스트를 했다.
1
2
3
4
5
6
# nslookup web-01.test.priv
Server: 192.168.56.10
Address: 192.168.56.10#53
Name: web-01.test.priv
Address: 192.168.56.2
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

이제 proxy server를 설정한다. nginx를 설치 한 후 설정파일을 수정했다.
1
2
3
4
5
6
7
8
9
10
# cat /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
resolver 192.168.56.10;
location / {
proxy_pass http://$request_uri;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
resolver로 앞서 만든 dns server를 설정했다. nginx를 restart 한 뒤, 호스트 운영체제에서 테스트를 수행했다.
1
2
3
4
# curl web-01.test.priv
<h1>WEB-01</h1>
# curl web-02.test.priv
<h1>WEB-02</h1>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
잘 된다. 도메인 이름 기반 Proxy는 PaaS나 SaaS 환경을 구축 하려고 할 때, 특히 유용하게 사용 할 수 있을 거다.

 

이 방식의 유일한 문제점은 아마도 dnsmasq 서버의 유지 보수일 것이다. 새로운 도메인이 추가 되면 /etc/hosts를 변경 한 다음 realod를 해줘야 한다. 단순한 파일 관리기는 하지만 그다지 깔끔하지는 않다.

 

SaaS/PassS 환경을 구축하려면 service discovery 시스템을 만들어야 한다. 아마도 DNS 기반으로 만들어야 할 건데, dnsmasq 클러스터를 구성 해야 할 것이다. 주키퍼를 이용해서 구축 할 수 있겠다.

 

 key/value 기반의 proxy 환경

 

  1. 주키퍼는 dnsmasq 노드들을 관리한다.
  2. 도메인 정보는 주키퍼에 저장된다.
  3. dnsmasq가 주키퍼에 저장된 도메인 정보로 /etc/hosts를 재구성하기는 쉽지 않을 것이다. 별도의 애플리케이션으로 /etc/hosts를 재구성하고 dnsmasq를 reload 한다.
  4. 다이나믹하게 도메인 정보가 바뀌는 서비스에서 dnsmasq는 효율적이지 않다. 새로 만드는 것도 생각해봐야 겠다.
Saas/PaaS를 위한 DNS 기반의 service discovery 시스템은 간단하게 다룰 만한 내용은 아니다. 언젠가 제대로 고민을 해봐야 겠다. 지금은 이정도로 하고 넘어간다.

 

6.2. 정규표현을 이용한 dynamic proxy

컨테이너를 기반으로 하는 SaaS 인프라를 개발한다고 가정해보자. 이 인프라에는 host_01, host_02, host_03 3개의 호스트가 있다. 유저가 SaaS 서비스인 워드프레스(wordpress)를 요청하면, 3개의 호스트 중 적당한 호스트를 골라서 워드프레스 컨테이너를 배치한다. 이제 유저 요청이 들어오면, 유저에게 할당한 컨테이너로 프락시해줘야 한다. 정규표현을 이용해서 프락시를 해보기로 하자.

 

 정규표현을 이용한 다이나믹 프락시

 

프로세스는 다음과 같다.
  1. 유저 컨테이너를 만들고 나면, 컨테이너를 위한 도메인을 등록한다. 도메인 이름에는 애플리케이션 이름, 컨테이너의 ID, 호스트 번호등이 들어간다. wordpress_container001_01.test.priv에는 host_01에 있는 container001로 프락시하라 라는 정보가 담겨있다. 정규표현식을 이용해서 처리 할 수 있을 것이다.
  2. 물론 *.test.priv는 로드밸런서(LB)로 향하도록 도메인 작업을 해둬야 한다. 약간 응용하면 dnsmasq로 만들 수 있다. 이 과정은 다루지 않겠다.
  3. 유저 요청은 로드밸런서 밑에 있는 NginX 프락시 서버로 이동한다. NginX 프락시 서버는 정규표현식을 이용해서 프락시할 호스트의 위치를 찾는다.
  4. 유저 요청은 NginX에 의해서 워드프레스 컨테이너가 있는 호스트로 전달된다. 이 호스트에는 역시 NginX 기반으로 된 Local Proxy가 있는데, 정규표현식을 이용해서 컨테이너의 이름을 찾아서 프락시 한다.
NginX Proxy Server의 설정은 대략 다음과 같다.
1
2
3
4
5
6
7
8
9
server {
server_name ~^([a-zA-Z0-9]+)_([a-zA-Z0-9]+)_([0-9]+)\.test\.org$;
resolver 127.0.0.1;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://host_$3;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$1은 SaaS 애플리케이션 이름, $2는 컨테이너 ID, $3은 호스트 번호다. 예를 들어서 http://wordpress_container001_01.test.priv 요청이 들어오면, http://host_01로 요청을 프락시 한다.

'리눅스 > 웹서버(WAS)' 카테고리의 다른 글

웹서버 분산 세션공유  (0) 2014.06.11

하드웨어 부하테스트 (Stress)

Posted by 주원이^^
2016. 7. 13. 10:39 리눅스/소프트웨어(Software)
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

LinuxStress 툴의 설치 및 사용방법

                                                                             작성자: 신 동 인

 

1. Kit확보방법

 - 아래의 url에서 source download 받음.

   http://weather.ou.edu/~apw/projects/stress/

   stress-1.0.0.tar.gz

 

2. ftp를 사용하여 원하는 시스템의 디렉토리로 이동

 

3. 압축의 해제

[root@krcipf3 stress]# tar -xzvf stress-1.0.0.tar.gz

stress-1.0.0/

stress-1.0.0/README

stress-1.0.0/configure.in

stress-1.0.0/aclocal.m4

stress-1.0.0/Makefile.am

stress-1.0.0/Makefile.in

stress-1.0.0/configure

stress-1.0.0/AUTHORS

stress-1.0.0/COPYING

stress-1.0.0/ChangeLog

stress-1.0.0/INSTALL

stress-1.0.0/NEWS

stress-1.0.0/TODO

stress-1.0.0/depcomp

stress-1.0.0/install-sh

stress-1.0.0/missing

stress-1.0.0/src/

stress-1.0.0/src/Makefile.am

stress-1.0.0/src/Makefile.in

stress-1.0.0/src/stress.c

stress-1.0.0/doc/

stress-1.0.0/doc/Makefile.am

stress-1.0.0/doc/Makefile.in

stress-1.0.0/doc/stamp-vti

stress-1.0.0/doc/version.texi

stress-1.0.0/doc/mdate-sh

stress-1.0.0/doc/texinfo.tex

stress-1.0.0/doc/stress.texi

stress-1.0.0/doc/stress.1

stress-1.0.0/doc/stress.html

stress-1.0.0/doc/stress.info

stress-1.0.0/test/

stress-1.0.0/test/Makefile.am

stress-1.0.0/test/Makefile.in

stress-1.0.0/test/check_version_return_code

stress-1.0.0/test/check_usage_return_code

 

4. 소스의 컴파일

[root@krcipf3 stress-1.0.0]# ./configure

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking for gcc... gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables...

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking for style of include used by make... GNU

checking dependency style of gcc... gcc3

checking how to run the C preprocessor... gcc -E

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking for unistd.h... (cached) yes

checking for sqrt in -lm... yes

checking for basename in -lgen... no

configure: creating ./config.status

config.status: creating Makefile

config.status: creating src/Makefile

config.status: creating doc/Makefile

config.status: creating test/Makefile

config.status: executing depfiles commands

[root@krcipf3 stress-1.0.0]# make

Making all in .

make[1]: Entering directory `/shindi/tools/stress/stress-1.0.0'

make[1]: `all-am'를 위해 할 일이 없습니다

make[1]: Leaving directory `/shindi/tools/stress/stress-1.0.0'

Making all in src

make[1]: Entering directory `/shindi/tools/stress/stress-1.0.0/src'

gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"stress\" -DVERSION=\"1.0.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIBM=1 -I.     -Wall -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MT stress.o -MD -MP -MF .deps/stress.Tpo -c -o stress.o stress.c

mv -f .deps/stress.Tpo .deps/stress.Po

gcc  -Wall -Werror -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE   -o stress stress.o  -lm

[root@krcipf3 stress-1.0.0]#

 

 

5. 실행파일 생성 확인

[root@krcipf3 stress-1.0.0]#

[root@krcipf3 stress-1.0.0]# cd src

[root@krcipf3 src]# ls -l stress

-rwxr-xr-x  1 root root 51993 10 21 16:50 stress

 

6. 실행테스트

[root@krcipf3 src]# ./stress --cpu 8 --timeout 60s  

   <-- 8 cpu에 돌아가는 것으로 8개 프로세스가 구동됨.

stress: info: [6950] dispatching hogs: 8 cpu, 0 io, 0 vm, 0 hdd

 

[root@krcipf3 ~]# vmstat 5

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----

 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa

 9  0      0 3681888  47760 226752   0    0     0     7 2075    51 100  0  0  0

 9  0      0 3681952  47760 226752   0    0     0     0 2066    44 100  0  0  0

 9  0      0 3679776  47776 226736   0    0     0     6 2082    77 100  0  0  0

 9  0      0 3679200  47808 226704   0    0     0    31 2069    56 100  0  0  0

 9  0      0 3679200  47808 226704   0    0     0     0 2070    46 100  0  0  0

 

 

[root@krcipf3 src]# ./stress --vm 3 --vm-bytes 1024m  --timeout 60s

   <--  Memory load를 위해 2개의 process 1024M의 메모리를 사용

stress: info: [7147] dispatching hogs: 0 cpu, 0 io, 3 vm, 0 hdd

stress: info: [7147] successful run completed in 60s

[root@krcipf3 src]#

 

[root@krcipf3 ~]# vmstat 5

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----

 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa

 4  0   8160 1452224  1952  22768    0    0     0     0 2063    48  7 93  0  0

 4  0   8160 3379968  1968  22752    0    0    26     0 2070    57  9 91  0  0

 4  0   8160 1816640  2016  24768    0    0    13     1 2066    87  7 93  0  0

 4  0   8160 2700224  2048  24736    0    0     0    34 2068    58  8 92  0  0

 4  0   8160 2366528  2048  24736    0    0     0     0 2061    53  7 93  0  0

 

[root@krcipf3 src]# stress --hdd 3 --hdd-bytes 1024m --timeout 60s

   <-- hard disk load를 위한 process수와 hard disk 테스트를 위한 파일의 크기를 정의

stress: info: [7301] dispatching hogs: 0 cpu, 0 io, 0 vm, 3 hdd

stress: info: [7301] successful run completed in 77s

[root@krcipf3 src]#

 

[root@krcipf3 ~]# vmstat 5

procs -----------memory---------- ---swap-- -----io----- --system-- ----cpu----

 r  b   swpd   free   buff  cache   si   so    bi     bo   in    cs us sy id wa

 0  5   8144 1914144  10448 1962576  0    0     5  11856 2200  1441  0 36  0 64

 4  5   8144 1600832  11664 2258576  0    0     2  70411 2211  1848  0 15  0 85

 0  7   8144 1090816  13600 2735488  0    0     3 226435 2204  1618  0 28  0 72

 0  7   8144 1929664  15152 1908336  0    0     3      0 2208  1742  0 20  0 80

 1  7   8144 2773504  15376 1101088  0    0     2     26 2205  1924  0 11  0 89

 

[root@krcipf3 src]# ./stress --cpu 5 --vm 3 --vm-bytes 512m --hdd 2 --hdd-bytes 1024m  --timeout 60s 

   <-- cpu, memory, and disk를 모두 테스트

stress: info: [7584] dispatching hogs: 5 cpu, 0 io, 3 vm, 2 hdd

stress: info: [7584] successful run completed in 64s

[root@krcipf3 src]#

 

[root@krcipf3 ~]# vmstat 5

procs -----------memory---------- ---swap-- -----io----  --system-- ----cpu----

 r  b   swpd   free   buff  cache   si   so    bi     bo   in    cs us sy id wa

11  4   8080 1430528  55952 1632048  0    0     0 143647 2197   762 50 50  0  0

10  5   8064 1131328  57680 1584928  0    0     0     20 2192    87 57 43  0  0

 9  4   8064 2387008  58048 472064   0    0     1 109312 2198    80 60 40  0  0

12  2   8064 2334624  58320 162192   0    0     0      2 2193    81 63 37  0  0

11  4   8064 1933120  60688 682016   0    0     0 129394 2143   131 55 45  0  0

 

시간: s,m,h,d,y     크기:k,m,g

 

7. stress툴의 사용방법관련 정보

# info stress 를 실행하면 사용방법에 대한 자세한 정보를 볼 수 있음.

 

 

'리눅스 > 소프트웨어(Software)' 카테고리의 다른 글

scp 쓰는법  (0) 2017.01.31
DNS 설치  (0) 2017.01.31
LVS Server2  (0) 2016.04.08
LVS Server1  (0) 2016.04.08
리눅스 본딩셋팅  (0) 2015.09.14

LVS Server2

Posted by 주원이^^
2016. 4. 8. 09:35 리눅스/소프트웨어(Software)
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

[Linux/CentOS7] Install LVS + Keepalived Server #2

※ Did you got the good news? Please click ad again, 좋은 정보 얻으셨다면 광고 한번 눌러주시는 센스 부탁드려요


This is the Redundant configuration for LVS + Keepalived Server itself.

This example is based on the environment below.



HTTP packets to the eth0 on LVS Server are forwarded to Backend01 and Backend02 Servers with NAT.

Change the default gateway to internal IP address of LVS on both Backend Web Servers first. (it's 10.0.0.29 on the example)



1. Install ipvsadm and keepalived.


[root@otaec ~]# yum -y install ipvsadm keepalived

# enable IP forward

[root@otaec ~]# echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf 

[root@otaec ~]# sysctl -p

[root@otaec ~]# touch /etc/sysconfig/ipvsadm 

[root@otaec ~]# systemctl start ipvsadm 

[root@otaec ~]# systemctl enable ipvsadm 






2. Configure Keepalived.

It's OK to configure the same settings except one setting on both backend servers. 

(but only for the "priority" section, Change it on both backend server.)


[root@otaec ~]# mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.org 

[root@otaec ~]# vi /etc/keepalived/keepalived.conf

# create new

global_defs {

    notification_email {

        root@otaec.server.world

    }

    notification_email_from root@otaec.server.world

    smtp_server 127.0.0.1

    smtp_connect_timeout 30

    router_id LVS_Server

}

vrrp_instance VI_1 {

    state BACKUP

    # monitored interface

    interface eth0

    # virtual router's ID

    virtual_router_id 51

    # set priority (change this value on each server)

    # (large number means priority is high)

    priority 100

    nopreempt

    # VRRP sending interval

    advert_int 1

    # authentication info between Keepalived servers

    authentication {

        auth_type PASS

        auth_pass password

    }


    virtual_ipaddress {

        # virtual IP address

        192.168.0.29 dev eth0

        10.0.0.29/24 dev eth1

    }

}

virtual_server 192.168.0.29 80 {

    # monitored interval

    delay_loop 3

    # distribution method

    lvs_sched rr

    # routing method

    lvs_method NAT

    protocol TCP


    # backend server#1

    real_server 10.0.0.51 80 {

        weight 1

        HTTP_GET {

            url {

                # monitored path

                path /

                # status code for normally state

                status_code 200

            }

            # timeout(sec)

            connect_timeout 3

        }

    }

    # backend server#2

    real_server 10.0.0.52 80 {

        weight 1

        HTTP_GET {

            url {

                path /

                status_code 200

            }

            connect_timeout 3

        }

    }

}


[root@otaec ~]# systemctl start keepalived 

[root@otaec ~]# systemctl enable keepalived 




[Linux/CentOS7] Install LVS + Keepalived Server #2

 

'리눅스 > 소프트웨어(Software)' 카테고리의 다른 글

DNS 설치  (0) 2017.01.31
하드웨어 부하테스트 (Stress)  (0) 2016.07.13
LVS Server1  (0) 2016.04.08
리눅스 본딩셋팅  (0) 2015.09.14
openssl 이용 키 생성 및 적용  (0) 2015.07.09

LVS Server1

Posted by 주원이^^
2016. 4. 8. 09:10 리눅스/소프트웨어(Software)
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

[Linux/CentOS7] Install LVS Server #1

※ Did you got the good news? Please click ad again, 좋은 정보 얻으셨다면 광고 한번 눌러주시는 센스 부탁드려요


Linux Virtual Server(LVS)란?

리눅스 가상 서버란, 한대의 서버로 증가하는 인터넷 사용자를 처리하기가 힘들어 지면서 
고가용성 서버를 구축하기 위해 리눅스 머신을 로드 발랜스 하도록 해주는 운영시스템이다.

만약 하나의 노드에서 처리량이 너무 많아서 서비스가 불가능할 경우 
간단히 하나의 노드를 병렬 구성으로 추가 함으로써 부하분산을 하도록 하는 것을 말한다. 
공개소스로서 이러한 기능을 담당하고 있는 것이다.

 

Configure LVS (Linux Virtual Server) to build a load barancer.
This example is based on the environment below.

 

 

 

1. Install ipvsadm.

 

[root@dlp ~]# yum -y install ipvsadm

 

 

 

 # enable IP forward
[root@dlp ~]# echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf 
[root@dlp ~]# sysctl -p
[root@dlp ~]# touch /etc/sysconfig/ipvsadm 
[root@dlp ~]# systemctl start ipvsadm 
[root@dlp ~]# systemctl enable ipvsadm

 

 

2. Configure Load Balancing.

 

 # clear tables
[root@dlp ~]# ipvsadm -C

 

 

 

# add virtual service
# [ ipvsadm -A -t (Service IP:Port) -s (Distribution method) ]
[root@dlp ~]# ipvsadm -A -t 192.168.0.30:80 -s wlc

 

 

 

# add backend real servers
# [ ipvsadm -a -t (Service IP:Port) -r (Real Server's IP:Port) -m ] ("m" means masquerading (NAT))
[root@dlp ~]# ipvsadm -a -t 192.168.0.30:80 -r 10.0.0.51:80 -m 
[root@dlp ~]# ipvsadm -a -t 192.168.0.30:80 -r 10.0.0.52:80 -m

 

 

 

# confirm tables
[root@dlp ~]# ipvsadm -l 
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  dlp.server.world:http wlc
  -> 10.0.0.51:http               Masq    1      0          0
  -> 10.0.0.52:http               Masq    1      0          0

 

 

 

rr Robin Robin 
 연결을 동일 순서대로 각 노드에 부하 분산한다.

wrr Weighted Round Robin 
 "-w weight '에 의해 설정된 weight에 따라 부하 분산한다.

lc Least-Connection 
 연결 수가 가장 낮은 노드에 부하 분산한다.

wlc Weighted Least-Connection 
 연결 수와 weight에 따라 부하 분산한다. 
 "-s (분산 방식)"을 지정하지 않으면 기본 분산 방식.

lblc Locality-Based Least-Connection 
 동일한 IP에서의 연결은 동일한 노드에 배분. 
 노드가 과부하 상태의 경우는 연결 수를 가진 노드에 부하 분산한다.

lblcr Locality-Based Least-Connection with Replication 
 동일한 IP에서의 연결은 가장 부하가 적은 노드에 배분. 
 모든 노드에 과부하 장소는 클러스터에서 연결 수를 가진 노드를 추가하여 부하 분산한다.

dh Destination Hashing 
 대상 IP에서 정적으로 할당 된 해시 테이블을 검색하여 부하 분산한다.

sh Source Hashing 
 소스 IP에서 정적으로 할당 된 해시 테이블을 검색하여 부하 분산한다.

sed Shortest Expected Delay 
 응답 속도가 가장 빠른 서버에 배분.

nq Never Queue 
 유휴 서버가 있으면 거기에 배분. 
 모든 서버가 사용 중이라면 가장 응답 속도가 빠른 서버에 배분.

 

[Linux/CentOS7] Install LVS Server #1

 

'리눅스 > 소프트웨어(Software)' 카테고리의 다른 글

하드웨어 부하테스트 (Stress)  (0) 2016.07.13
LVS Server2  (0) 2016.04.08
리눅스 본딩셋팅  (0) 2015.09.14
openssl 이용 키 생성 및 적용  (0) 2015.07.09
오픈메신저 설치법(openfire) + spark  (0) 2014.11.17

apache 자동다운받기

Posted by 주원이^^
2016. 3. 4. 06:22 리눅스/스크립트
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#!/bin/bash


folder="/httpd"
name="httpd"
start="1"
end="20"

ls -l /httpd | awk -F " " '{print $8}' > /httpd/httpd_list.txt

cd $folder
for ((i=$start;i<=$end;i++)); do
        start_cnt=`ls -l | grep ${name}-${i} | wc -l`
        if [[ $start_cnt != 0 ]]; then
                for ((j=$start;j<=$end;j++)); do
                        middle_cnt=`ls -l | grep ${name}-${i}.${j} | wc -l`
                        if [[ $middle_cnt != 0 ]]; then
                                if [[ `ls -l | grep ${name}-${i}.${j}.last | wc -l` != 0 ]]; then
                                        rm_name="`ls -v | grep ${name}-${i}.${j}.last`"
                                        rm -rf "$rm_name"
                                fi
                                        end_cnt=`ls -v | grep ${name}-${i}.${j} | wc -l`
                                        sed_name=`ls -v | grep ${name}-${i}.${j} | sed "/${name}-${i}.${j}.last/d" | sed -n "${end_cnt},${end_cnt}p"`
                                        ln -s ${sed_name} ${name}-${i}.${j}.last.tar.gz
                        fi
                        continue
                done
        fi

done

curl http://archive.apache.org/dist/httpd/ | grep httpd-2 | grep tar.gz | awk -F "href=\"" '{print $2}' | awk -F " " '{print $1}' | awk -F "\"" '{print $1}' | grep tar.gz$ | grep -v alpha | grep -v deps | grep -v beta > /httpd/httpd_list
_http_list

while read line; do
        while read line2; do
                if [[ $line == $line2 ]]; then
                        check=0
                        break;
                else
                        check=1
                fi
        done < /httpd/httpd_list
        if [ $check == 1 ]; then
                wget -O /httpd/$line http://archive.apache.org/dist/httpd/$line
        fi
done < /httpd/httpd_list.txt 
ls -l /httpd | awk -F " " '{print $8}' > /httpd/httpd_list.txt
rm -rf /httpd/httpd_list

'리눅스 > 스크립트' 카테고리의 다른 글

ssh_bruteforce 자동차단  (0) 2016.11.04
웹 트래픽 로그 순위 추출  (0) 2016.11.03
mysql replication 상태체크  (0) 2016.01.13
폴더내 파일 소문자로 일괄변경  (0) 2015.07.16
7일뒤 로그 삭제  (0) 2015.07.14

mysql replication 상태체크

Posted by 주원이^^
2016. 1. 13. 13:54 리눅스/스크립트
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#!/bin/bash
#Server infomation
DB_ID="root"
DB_PW="12345"
S_ip=`ifconfig | grep "inet addr" | awk '{print $2}' | awk -F ":" '{print $2}' | head -n 1`
S_Hostname=`hostname`
Sql_ver=`/usr/local/mysql/bin/mysql -V | awk -F " " '{print $5}' | awk -F "," '{print $1}'`

#log check
Source="/usr/bin/"

##time setting
Log_DeleteDay="42"
Log_Time="*/1 * * * * root sh"

Time_Day="`/bin/date +%Y%m%d --date "$Day days ago"`"
Time_Second="`/bin/date +%H%M%S --date "$Day days ago"`"
#sendmail info
TITLE="[${S_ip}]Mysql Replication Error $S_Hostname"
To_mail="메일주소"


#SQL infomation
MASTER_HOST="`/usr/local/mysql/bin/mysql -u${DB_ID} -p${DB_PW} -e "show slave status \G" | grep Master_Host: | awk -F " " '{print $2}'`"
MASTER_POS="`/usr/local/mysql/bin/mysql -u${DB_ID} -p${DB_PW} -e "show slave status \G" | grep Read_Master_Log_Pos: | awk -F " " '{print $2}'`"
SLAVE_POS="`/usr/local/mysql/bin/mysql -u${DB_ID} -p${DB_PW} -e "show slave status \G" | grep Exec_Master_Log_Pos: | awk -F " " '{print $2}'`"
SLAVE_IO="`/usr/local/mysql/bin/mysql -u${DB_ID} -p${DB_PW} -e "show slave status \G" | grep Slave_IO_Running: | awk -F " " '{print $2}'`"
SLAVE_SQL="`/usr/local/mysql/bin/mysql -u${DB_ID} -p${DB_PW} -e "show slave status \G" | grep Slave_SQL_Running: | awk -F " " '{print $2}'`"

Log_check() {
if [ ! -d /usr/logs ]; then
        mkdir -p ${Source}logs
fi
if [ ! -f ${Source}logs/sql_replication_${Time_Day}.log ]; then
        touch ${Source}logs/sql_replication_${Time_Day}.log
fi
if [[ -z `grep "##Sql Replication Check" "/etc/crontab" | head -n 1` ]]; then
        echo -ne "##Sql Replication Check
${Log_Time} ${Source}Sql_replication.sh" >> /etc/crontab
/etc/init.d/crond restart
fi
}

Log_delete() {

`find ${Source}logs/sql_replication* -ctime +${Log_DeleteDay} -exec rm -rf {} \;`

}


Content() {
echo -ne "
Master Host : $MASTER_HOST
Master Pos : $MASTER_POS        Slave Pos : $SLAVE_POS
Slave IO : $SLAVE_IO            Slave SQL : $SLAVE_SQL
Mysql Version : $Sql_ver
"
}

Mail() {
        Content | /bin/mail -s "${TITLE}" ${To_mail}
}

Start() {
Log_check

echo -ne "  #####$Time_Second#####" >> ${Source}logs/sql_replication_${Time_Day}.log

Content >> ${Source}logs/sql_replication_${Time_Day}.log

if [[ $SLAVE_IO != Yes ]] && [[ $SLAVE_SQL != Yes ]]; then
        Mail
elif [[ $MASTER_POS != $SLAVE_POS ]]; then
        Mail
fi

Log_delete
}

Start

 

'리눅스 > 스크립트' 카테고리의 다른 글

웹 트래픽 로그 순위 추출  (0) 2016.11.03
apache 자동다운받기  (0) 2016.03.04
폴더내 파일 소문자로 일괄변경  (0) 2015.07.16
7일뒤 로그 삭제  (0) 2015.07.14
특정데몬 모니터링  (0) 2014.11.06

fstab 설정하기

Posted by 주원이^^
2015. 9. 15. 16:56 리눅스/기본정보(OS)
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

마운트 옵션

이 항목에는 다양한 옵션들이 존재하는데, 각각의 옵션들을 콤마(,)를 이용해서 중복 입력이 가능하다. 대부분 defaults를 쓴다.

 옵션

 설명

 defaults

 rw, suid, dev, exec, auto, nouser, async 옵션을 모두 선택한 것과 같다.

 auto

 부팅시 자동으로 마운트

 noauto

 부팅시 자동으로 마운트 하지 않는다

 nosuid

 uid와 gid가 적용되지 않는다

 ro

 읽기 전용

 rw

 읽기 쓰기 허용


백업

백업 여부를 설정한다

 0

 백업하지 않는다

 1

 백업가능한 파일 시스템


검사

fsck를 이용한 파일시스템 검사옵션

 0

 부팅시에 파일 시스템을 점검하지 않는다

 1

 루트 파일시스템으로서 부팅시에 파일 시스템 점검을 한다

 2

 루트 파일 시스템 이외의 파일시스템으로서 부팅시에 파일 시스템 점검을 한다


 

uuid 알아내기

 

[root@ ~]# blkid
/dev/sda1: UUID="75e37272-6a04-4033-86dc-3196ddbcec16" TYPE="ext4"
/dev/sda2: UUID="466c1fc7-e904-48ae-9591-55be03947745" TYPE="swap"
/dev/sda3: UUID="6a293ee1-a574-4b08-9cff-84107682843e" UUID_SUB="9ce40889-9709-45bf-9ed8-d4f5df10ad1c" TYPE="btrfs"

 

 

'리눅스 > 기본정보(OS)' 카테고리의 다른 글

프로토콜 기본정보  (0) 2017.07.31
GPT 2TB 이상 하드디스크 사용 파티셔닝  (0) 2014.07.30
centos 버전 확인  (1078) 2014.06.19
로그 분석하는방법  (482) 2012.02.02
자신의 하드웨어 정보 보기  (2375) 2011.11.19

리눅스 본딩셋팅

Posted by 주원이^^
2015. 9. 14. 12:20 리눅스/소프트웨어(Software)
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

본딩이란 여러 개의 이더넷을 하나로 묶어 대역폭을 늘리는 기술
Microsoft Windows의 Teaming과 동일(HP-UX:APA, CISCO:EtherChannel, Linux:Bonding)

 

 

(본딩 정책)

BONDING_OPTS="mode=1 설명
mode=0 : Balance-Round Robin(순차적 전송 및 로드 발란스 기능, Fault Talerance 기능)
mode=1 : Active-backup      (기본적으로 1개만 active하고 이게 failed 이면 나머지가 기능 수행)
0이 기본값인데, 많은 엔지니어들이 1을 선호한다.


(설정파일)
/etc/sysconfig/network-scripts/ifcfg-bond0
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/modprobe.d/bonding

 

# ls /proc/sys/net/ipv4/conf
all  default  eth0  eth1  lo

 

 

리눅스에서 본딩설정 해 보자.

 

먼저

# setup 실행

이더넷을 bond0 란 이름으로 추가한다. 그리고 아래와 같이 수정

 

# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
IPADDR="10.1.1.31"
NETMASK="255.255.255.0"
GATEWAY="10.1.1.1"
BONDING_OPTS="mode=1 miimon=100"  <-- 이곳에 본딩 정책을 기입한다.

 

# cat ifcfg-eth0
DEVICE=eth0
HWADDR=A4:44:C1:F7:02:EF
TYPE=Ethernet
UUID=114ed8fd-54c7-43b3-9547-b3026fcc7336
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0 <-- 추가
SLAVE=yes <-- 추가


# cat ifcfg-eth1
DEVICE=eth1
HWADDR=A4:44:FD:98:F0:63
TYPE=Ethernet
UUID=1bd18e99-366a-465f-8c90-9ba513c82cb5
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0 <-- 추가
SLAVE=yes <-- 추가


# vi /etc/modprobe.d/bonding
alias bond0 bonding <-- 추가

# service network restart <- 서비스 재시작

# ifconfig

# cat /sys/class/net/bonding_masters
bond0

# cat /proc/net/bonding/bond0

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1  <-- 현재 Active 이더넷이 표시된다.
MII Status: up
MII Polling Interval (ms): 100

Slave Interface: eth0
MII Status: up
Speed: 100 Mbps

Slave Interface: eth1
MII Status: up
Speed: 100 Mbps


# cat /proc/net/dev  <-- 이더넷별로 송수신 패킷 확인하기

 

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

 

모듈을 구성한다.
 
  [Bonding 모드 종류]

     0 : balance-round robine ( 2개의 NIC를 통한 분배 +  Fault Tolerance )

     1 : active-standby ( Active상태의 NIC에 문제 발생시 Fault Tolerance )

     2 : balance-xor ( 0과 비슷하지만 xor연산을 이용한 목적지 Mac과 근원지 Mac을 이용한 분배 +    Fault tolerance)

     3 : broadcast ( 2개의 NIC에 어떤 규칙 없이 데이터 통신 +  Fault Tolerace)

     4 : 802.3ad (link aggregation) – switch 에 aggregation 그룹생성이 필요

'리눅스 > 소프트웨어(Software)' 카테고리의 다른 글

LVS Server2  (0) 2016.04.08
LVS Server1  (0) 2016.04.08
openssl 이용 키 생성 및 적용  (0) 2015.07.09
오픈메신저 설치법(openfire) + spark  (0) 2014.11.17
ntopng 설치 및 설정  (0) 2014.11.14

폴더내 파일 소문자로 일괄변경

Posted by 주원이^^
2015. 7. 16. 17:28 리눅스/스크립트
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

 

#! /bin/bash

 for filename in *
do
   fname=`basename $filename`
   n=`echo $fname | tr A-Z a-z`
  if [ "$fname" != "$n" ]
   then
     mv $fname $n
   fi
done
exit 0

'리눅스 > 스크립트' 카테고리의 다른 글

apache 자동다운받기  (0) 2016.03.04
mysql replication 상태체크  (0) 2016.01.13
7일뒤 로그 삭제  (0) 2015.07.14
특정데몬 모니터링  (0) 2014.11.06
watch  (0) 2014.11.05