GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come monitorare i limiti di OpenVZ con vzwatchd su Debian e Ubuntu

Vzwatchd è un demone di monitoraggio OpenVZ che informa l'amministratore del server tramite e-mail quando viene raggiunto un limite del contenitore. OpenVZ è una tecnologia di virtualizzazione del kernel Linux che viene spesso utilizzata dai servizi di Web Hosting, è il core gratuito dell'applicazione di virtualizzazione commerciale di virtuozzo. OpenVZ è una virtualizzazione leggera che ha un sovraccarico inferiore rispetto a KVM o XEN, è più simile a una jail LXC Linux ma con opzioni di limite avanzate per definire quante risorse può utilizzare una macchina virtuale e supporta la quota del filesystem.

Questo tutorial spiega l'installazione e la configurazione del demone vzwatchd su Debian e Ubuntu.

1 Il mio server virtuale utilizza OpenVZ

Hai noleggiato un server virtuale da una società di hosting senza sapere quale tecnologia di virtualizzazione utilizza? Esegui il comando seguente per verificare se utilizza OpenVZ:

cat /proc/user_beancounters

Se l'output è simile a quello seguente, il tuo server utilizza OpenVZ o una tecnologia compatibile e puoi utilizzare vzwatchd per monitorare il 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

L'output mostra i limiti della macchina virtuale, ogni riga descrive un limite e la colonna che viene osservata da vzwatchd è l'ultima colonna che conta la frequenza con cui è stato raggiunto un limite.

2 Installa vzwatchd

Vzwatchd è scritto in Perl, viene scaricato e installato dall'archivio Perl CPAN con il comando CPAN.

Installazione dei prerequisiti

Eseguirò i seguenti passaggi come utente root, eseguirò sudo -s su Ubuntu per diventare root:

sudo -s

Per prima cosa installerò lo strumento make e l'editor nano, make è usato da CPAN per compilare vzwatchd e userò nano in seguito per modificare il file di configurazione:

apt-get install make nano

Successivamente installerò vzwatchd da CPAN con questo comando:

cpan -i App::OpenVZ::BCWatch

Se è la prima volta che utilizzi CPAN su un server, lo script ti farà alcune domande sulla configurazione CPAN di base:

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]

Rispondi a entrambe le domande con "sì".

Il programma di installazione ora scaricherà, compilerà e installerà molti moduli 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

È importante che tu veda la linea

./Build install -- OK

alla fine dell'output di compilazione. Se invece ricevi un errore, esegui nuovamente il comando. Ho dovuto eseguire il comando due volte per compilare correttamente tutti i moduli.

Per verificare se l'installazione è andata a buon fine, esegui il comando:

vzwatchd check

Questo verificherà l'installazione e creerà un file di configurazione di esempio.

[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.

3 Configura e attiva vzwatchd

Ora modificherò il file vzwatchd.conf e imposterò l'indirizzo email per i messaggi di notifica.

nano /etc/vzwatchd.conf

Il file di configurazione apparirà così dopo averlo modificato, solo con il tuo indirizzo email fuori corso.

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

Le modifiche sono:

  • La riga "mail[from]" contiene l'indirizzo from delle email di notifica.
  • La riga "mail[to]" contiene l'indirizzo email che riceverà le notifiche.
  • Il valore nella riga "_active" deve essere modificato in 1 per attivare vzwatchd.
  • Quando esegui più server OpenVZ, potrebbe essere utile modificare "mail[oggetto]" in modo che contenga il nome del server.

Configura vzwatchd per l'avvio automatico all'avvio del server:

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

E avvia il demone vzwatchd monitor:

vzwatchd start
[email protected]:~# vzwatchd start
Starting /usr/local/bin/vzwatchd server

Ora riceverai una notifica via e-mail quando il tuo server virtuale OpenVZ raggiunge uno dei limiti del contenitore OpenVZ.

  • OpenVZ
  • Guarda

Ubuntu
  1. Come installare Netflix in Kodi su Ubuntu e Debian

  2. Come utilizzare APT con proxy su Ubuntu e Debian

  3. Come installare Python 3.7 su Ubuntu, Debian e LinuxMint

  4. Come installare Mattermost con MySQL su Ubuntu 14.04 e Debian 8

  5. Come configurare il failover IP con KeepAlived su Ubuntu e Debian

Come installare LEMP WordPress Ubuntu e Debian con Virtualhost

Come installare Zoom Ubuntu e derivati ​​Debian

Come configurare una VPN basata su IPsec con Strongswan su Debian e Ubuntu

Come installare Jitsi Meet su Debian e Ubuntu

Come installare Drupal con Apache su Debian e Ubuntu

Come installare ONLYOFFICE Docs su Debian e Ubuntu