웹사이트 검색

Debian 및 Ubuntu에서 vzwatchd로 OpenVZ 제한을 모니터링하는 방법


이 페이지에서

  1. 1 내 가상 서버가 OpenVZ를 사용합니까?\n
  2. 2 vzwatchd 설치
    1. 필수 구성 요소 설치\n

    Vzwatchd는 컨테이너 한도에 도달하면 이메일로 서버 관리자에게 알리는 OpenVZ 모니터링 데몬입니다. OpenVZ는 웹 호스팅 서비스에서 자주 사용하는 Linux 커널 가상화 기술로, 상용 virtuozzo 가상화 애플리케이션의 무료 핵심입니다. OpenVZ는 KVM이나 XEN보다 오버헤드가 적은 가벼운 가상화이며 Linux LXC 감옥과 비슷하지만 가상 머신이 사용할 수 있는 리소스 수를 정의하는 고급 제한 옵션이 있으며 파일 시스템 할당량을 지원합니다.

    이 자습서에서는 Debian 및 Ubuntu에서 vzwatchd 데몬의 설치 및 구성에 대해 설명합니다.

    1 가상 서버가 OpenVZ를 사용합니까?

    어떤 가상화 기술을 사용하는지 모른 채 호스팅 회사에서 가상 서버를 대여한 적이 있습니까? 다음 명령을 실행하여 OpenVZ를 사용하는지 테스트합니다.

    cat /proc/user_beancounters

    출력이 아래와 유사하면 서버가 OpenVZ 또는 호환 기술을 사용하고 vzwatchd를 사용하여 가상 서버를 모니터링할 수 있습니다.

    :/# cat /proc/user_beancounters
    Version: 2.5
    uid resource held maxheld barrier limit failcnt
    101: kmemsize 190939926 274194432 9223372036854775807 9223372036854775807 0
    lockedpages 0 3211 1048576 1048576 0
    privvmpages 749006 781311 9223372036854775807 9223372036854775807 0
    shmpages 22506 30698 9223372036854775807 9223372036854775807 0
    dummy 0 0 9223372036854775807 9223372036854775807 0
    numproc 237 312 9223372036854775807 9223372036854775807 0
    physpages 486543 804959 0 1048576 0
    vmguarpages 0 0 3145728 9223372036854775807 0
    oomguarpages 233498 242378 1048576 9223372036854775807 0
    numtcpsock 111 298 9223372036854775807 9223372036854775807 0
    numflock 253 294 9223372036854775807 9223372036854775807 0
    numpty 1 12 9223372036854775807 9223372036854775807 0
    numsiginfo 0 33 9223372036854775807 9223372036854775807 0
    tcpsndbuf 7083944 11209000 9223372036854775807 9223372036854775807 0
    tcprcvbuf 3300832 10792248 9223372036854775807 9223372036854775807 0
    othersockbuf 261256 1008400 9223372036854775807 9223372036854775807 0
    dgramrcvbuf 0 5152 9223372036854775807 9223372036854775807 0
    numothersock 166 526 1024 1024 0
    dcachesize 168291899 247843839 9223372036854775807 9223372036854775807 0
    numfile 3098 5205 9223372036854775807 9223372036854775807 0
    dummy 0 0 9223372036854775807 9223372036854775807 0
    dummy 0 0 9223372036854775807 9223372036854775807 0
    dummy 0 0 9223372036854775807 9223372036854775807 0
    numiptent 28 35 9223372036854775807 9223372036854775807 0

    출력에는 가상 머신의 제한이 표시되고 각 줄은 하나의 제한을 설명하며 vzwatchd에서 감시하는 열은 제한에 도달한 빈도를 계산하는 마지막 열입니다.

    2 vzwatchd 설치

    Vzwatchd는 Perl로 작성되었으며 CPAN 명령을 사용하여 Perl CPAN 아카이브에서 다운로드 및 설치됩니다.

    필수 구성 요소 설치

    루트 사용자로 다음 단계를 수행하고 Ubuntu에서 sudo -s를 실행하여 루트가 됩니다.

    sudo -s

    먼저 make 도구와 nano 편집기를 설치하고 CPAN에서 vzwatchd를 빌드하는 데 make를 사용하고 나중에 nano를 사용하여 구성 파일을 편집합니다.

    apt-get install make nano

    다음으로 다음 명령을 사용하여 CPAN에서 vzwatchd를 설치합니다.

    cpan -i App::OpenVZ::BCWatch

    서버에서 CPAN을 처음 사용하는 경우 스크립트에서 기본 CPAN 구성에 대한 몇 가지 질문을 합니다.

    Would you like to configure as much as possible automatically? [yes]
    Would you like me to automatically choose some CPAN mirror sites for you? (This means connecting to the Internet) [yes]

    두 질문에 모두 \\'예\\'로 대답하세요.

    설치 프로그램은 이제 많은 Perl 모듈을 다운로드, 컴파일 및 설치합니다.

    :~# cpan -i App::OpenVZ::BCWatch

    CPAN.pm requires configuration, but most of it can be done automatically.
    If you answer 'no' below, you will enter an interactive dialog for each
    configuration option instead.

    Would you like to configure as much as possible automatically? [yes] yes

    Autoconfigured everything but 'urllist'.

    Now you need to choose your CPAN mirror sites. You can let me
    pick mirrors for you, you can select them from a list or you
    can enter them by hand.

    Would you like me to automatically choose some CPAN mirror
    sites for you? (This means connecting to the Internet) [yes] yes
    Trying to fetch a mirror list from the Internet
    Fetching with LWP:
    http://www.perl.org/CPAN/MIRRORED.BY

    Looking for CPAN mirrors near you (please be patient)
    .............................. done!

    New urllist
    http://www.planet-elektronik.de/CPAN/
    http://cpan.noris.de/
    http://cpan.lnx.sk/

    Autoconfiguration complete.

    commit: wrote '/root/.cpan/CPAN/MyConfig.pm'

    You can re-run configuration any time with 'o conf init' in the CPAN shell
    Fetching with LWP:
    http://www.planet-elektronik.de/CPAN/authors/01mailrc.txt.gz
    Going to read '/root/.cpan/sources/authors/01mailrc.txt.gz'
    ............................................................................DONE
    Fetching with LWP:
    http://www.planet-elektronik.de/CPAN/modules/02packages.details.txt.gz
    Going to read '/root/.cpan/sources/modules/02packages.details.txt.gz'
    Database was generated on Mon, 13 Apr 2015 23:29:02 GMT
    ..............
    New CPAN.pm version (v2.10) available.
    [Currently running version is v1.960001]
    You might want to try
    install CPAN
    reload cpan
    to both upgrade CPAN.pm and run the new version without leaving
    the current session.

    [... snip ...]

    CPAN.pm: Going to build G/GW/GWOLF/Config-File-1.50.tar.gz

    Building Config-File
    GWOLF/Config-File-1.50.tar.gz
    ./Build -- OK
    Running Build test
    t/pod.t ........... Subroutine main::all_pod_files_ok redefined at /usr/local/share/perl/5.14.2/Test/Pod.pm line 90.
    t/pod.t ........... ok
    t/pod_coverage.t .. ok
    t/test.t .......... 1/11 Invalid characters in key to'be^ignored at line 10 - Ignoring at /root/.cpan/build/Config-File-1.50-NjLxod/blib/lib/Config/File.pm line 41, <GEN0> line 10.
    Line format invalid at line 11: 'malformed line that should be also dropped (no equal sign)' at /root/.cpan/build/Config-File-1.50-NjLxod/blib/lib/Config/File.pm line 35, <GEN0> line 11.
    t/test.t .......... ok
    All tests successful.
    Files=3, Tests=13, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.13 cusr 0.02 csys = 0.18 CPU)
    Result: PASS
    GWOLF/Config-File-1.50.tar.gz
    ./Build test -- OK
    Running Build install
    Building Config-File
    Installing /usr/local/share/perl/5.14.2/Config/File.pm
    Installing /usr/local/man/man3/Config::File.3pm
    GWOLF/Config-File-1.50.tar.gz
    ./Build install -- OK
    Running Build for S/SC/SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz
    Has already been unwrapped into directory /root/.cpan/build/App-OpenVZ-BCWatch-0.04-4Al97O

    CPAN.pm: Going to build S/SC/SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz

    Building App-OpenVZ-BCWatch
    SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz
    ./Build -- OK
    Running Build test
    t/00-load.t ....... ok
    t/basic.t ......... ok
    t/pod-coverage.t .. ok
    t/pod.t ........... ok
    All tests successful.
    Files=4, Tests=6, 0 wallclock secs ( 0.04 usr 0.01 sys + 0.27 cusr 0.04 csys = 0.36 CPU)
    Result: PASS
    SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz
    ./Build test -- OK
    Running Build install
    Building App-OpenVZ-BCWatch
    Installing /usr/local/man/man1/vzwatchd.1p
    Installing /usr/local/share/perl/5.14.2/App/OpenVZ/BCWatch.pm
    Installing /usr/local/man/man3/App::OpenVZ::BCWatch.3pm
    Installing /usr/local/bin/vzwatchd
    SCHUBIGER/App-OpenVZ-BCWatch-0.04.tar.gz
    ./Build install -- OK

    라인을 보는 것이 중요합니다

    ./Build install -- OK

    컴파일 출력의 끝에서. 대신 오류가 발생하면 명령을 다시 실행하십시오. 모든 모듈을 성공적으로 컴파일하려면 명령을 두 번 실행해야 했습니다.

    설치가 성공했는지 확인하려면 다음 명령을 실행하십시오.

    vzwatchd check

    이렇게 하면 설치를 확인하고 예제 구성 파일이 생성됩니다.

    :~# vzwatchd check
    /etc/vzwatchd.conf does not exist, creating one with defaults.
    Edit /etc/vzwatchd.conf to suit your needs and then start /usr/local/bin/vzwatchd again.

    3 vzwatchd 구성 및 활성화

    이제 vzwatchd.conf 파일을 편집하고 알림 메시지의 이메일 주소를 설정하겠습니다.

    nano /etc/vzwatchd.conf

    구성 파일은 편집한 후 자신의 이메일 주소를 제외하고 다음과 같이 표시됩니다.

    mail[from] = 
    mail[subject] = vzwatchd on server.example.com: NOTICE
    sleep = 60
    verbose = 0
    monitor_fields = failcnt
    _active = 1

    변경 사항은 다음과 같습니다.

    • "mail[from]" 행에는 알림 이메일의 보낸 사람 주소가 포함됩니다.\n
    • "mail[to]" 줄에는 알림을 받을 이메일 주소가 포함됩니다.\n
    • vzwatchd를 활성화하려면 "_active" 줄의 값을 1로 변경해야 합니다.\n
    • 여러 OpenVZ 서버를 실행할 때 서버 이름을 포함하도록 "mail[subject]"를 변경하는 것이 편리할 수 있습니다.\n

    서버가 부팅될 때 자동으로 시작되도록 vzwatchd를 구성합니다.

    vzwatchd install
    :~# vzwatchd install
    + /usr/sbin/update-rc.d vzwatchd defaults
    update-rc.d: warning: /etc/init.d/vzwatchd missing LSB information
    update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
    Adding system startup for /etc/init.d/vzwatchd ...
    /etc/rc0.d/K20vzwatchd -> ../init.d/vzwatchd
    /etc/rc1.d/K20vzwatchd -> ../init.d/vzwatchd
    /etc/rc6.d/K20vzwatchd -> ../init.d/vzwatchd
    /etc/rc2.d/S20vzwatchd -> ../init.d/vzwatchd
    /etc/rc3.d/S20vzwatchd -> ../init.d/vzwatchd
    /etc/rc4.d/S20vzwatchd -> ../init.d/vzwatchd
    /etc/rc5.d/S20vzwatchd -> ../init.d/vzwatchd

    그리고 vzwatchd 모니터 데몬을 시작합니다.

    vzwatchd start
    :~# vzwatchd start
    Starting /usr/local/bin/vzwatchd server

    이제 OpenVZ 가상 서버가 OpenVZ 컨테이너의 한계 중 하나에 도달하면 이메일로 알림을 받게 됩니다.

    연결

    • OpenVZ
    • Vzwatchd