GNU/Linux >> Linux の 問題 >  >> Ubuntu

DebianとUbuntuでvzwatchdを使用してOpenVZの制限を監視する方法

Vzwatchdは、コンテナの制限に達したときにサーバー管理者にメールで通知するOpenVZ監視デーモンです。 OpenVZは、Webホスティングサービスでよく使用されるLinuxカーネル仮想化テクノロジーであり、商用のvirtuozzo仮想化アプリケーションの無料コアです。 OpenVZは、KVMやXENよりもオーバーヘッドが少ない軽量の仮想化であり、Linux LXCジェイルに似ていますが、仮想マシンが使用できるリソースの数を定義する高度な制限オプションがあり、ファイルシステムクォータをサポートしています。

このチュートリアルでは、DebianとUbuntuでのvzwatchdデーモンのインストールと構成について説明します。

1私の仮想サーバーはOpenVZを使用していますか

ホスティング会社が使用している仮想化テクノロジーを知らずに、ホスティング会社から仮想サーバーを借りたことがありますか?次のコマンドを実行して、OpenVZを使用しているかどうかをテストします。

cat /proc/user_beancounters

出力が以下のようなものである場合、サーバーはOpenVZまたは互換性のあるテクノロジーを使用しており、vzwatchdを使用してvserverを監視できます。

[email protected]:/# 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

出力には仮想マシンの制限が表示され、各行は1つの制限を示し、vzwatchdによって監視される列は、制限に到達した頻度をカウントする最後の列です。

2vzwatchdをインストールします

VzwatchdはPerlで記述されており、CPANコマンドを使用してPerlCPANアーカイブからダウンロードおよびインストールされます。

前提条件のインストール

rootユーザーとして次の手順を実行し、Ubuntuでsudo-sを実行してrootになります。

sudo -s

まず、makeツールとnanoエディターをインストールし、makeはCPANによってvzwatchdをビルドするために使用され、後で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モジュールをダウンロード、コンパイル、およびインストールします。

[email protected]:~# 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

コンパイル出力の最後に。代わりにエラーが発生した場合は、コマンドを再実行してください。すべてのモジュールを正常にコンパイルするには、コマンドを2回実行する必要がありました。

インストールが成功したかどうかを確認するには、次のコマンドを実行します。

vzwatchd check

これにより、インストールが確認され、設定ファイルの例が作成されます。

[email protected]:~# 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.

3vzwatchdを構成してアクティブ化します

次に、vzwatchd.confファイルを編集して、通知メッセージのメールアドレスを設定します。

nano /etc/vzwatchd.conf

設定ファイルは、編集後は次のようになりますが、自分のメールアドレスはコース外になります。

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

変更点は次のとおりです。

  • 「mail[from]」の行には、通知メールの差出人アドレスが含まれています。
  • 「mail[to]」の行には、通知を受信するメールアドレスが含まれています。
  • vzwatchdをアクティブにするには、「_active」行の値を1に変更する必要があります。
  • 複数のOpenVZサーバーを実行している場合は、「mail[subject]」を変更してサーバー名を含めると便利な場合があります。

サーバーの起動時に自動的に起動するようにvzwatchdを構成します。

vzwatchd install
[email protected]:~# 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
[email protected]:~# vzwatchd start
Starting /usr/local/bin/vzwatchd server

これで、OpenVZ仮想サーバーがOpenVZコンテナーの制限の1つに達すると、電子メールで通知が届きます。

リンク
  • OpenVZ
  • Vzwatchd

Ubuntu
  1. UbuntuとDebianでプロキシでAPTを使用する方法

  2. Ubuntu、Debian、LinuxMintにPython3.7をインストールする方法

  3. Ubuntu14.04およびDebian8にMySQLを使用してMattermostをインストールする方法

  1. UbuntuとDebianのKodiにNetflixをインストールする方法

  2. Debian 9 / Ubuntu 16.04/17.10にWiresharkをインストールして使用する方法

  3. UbuntuとDebianでKeepAlivedを使用してIPフェイルオーバーを設定する方法

  1. Debian/UbuntuにWebminをインストールして設定する方法

  2. Ubuntu 18.04 /Debian9にNginxをインストールして構成する方法

  3. Ubuntu18.04とDebianにEasyEngineでWordPressをインストールする方法