• Aucun résultat trouvé

Testing the Crash Dump Mechanism

Dans le document Guida a Ubuntu Server (Page 25-34)

5. Kernel Crash Dump

5.6. Testing the Crash Dump Mechanism

So for the crashkernel parameter found in /proc/cmdline we would have :

crashkernel=384M-2G:64M,2G-:128M

The above value means:

• if the RAM is smaller than 384M, then don't reserve anything (this is the "rescue" case)

• if the RAM size is between 386M and 2G (exclusive), then reserve 64M

• if the RAM size is larger than 2G, then reserve 128M

Second, verify that the kernel has reserved the requested memory area for the kdump kernel by doing:

dmesg | grep -i crash

...

[ 0.000000] Reserving 64MB of memory at 800MB for crashkernel (System RAM: 1023MB)

5.6. Testing the Crash Dump Mechanism

Testing the Crash Dump Mechanism will cause a system reboot. In certain situations, this can cause data loss if the system is under heavy load. If you want to test the mechanism, make sure that the system is idle or under very light load.

Verify that the SysRQ mechanism is enabled by looking at the value of the /proc/sys/kernel/sysrq

kernel parameter :

cat /proc/sys/kernel/sysrq

If a value of 0 is returned the feature is disabled. Enable it with the following command :

sudo sysctl -w kernel.sysrq=1

Once this is done, you must become root, as just using sudo will not be sufficient. As the root user, you will have to issue the command echo c > /proc/sysrq-trigger. If you are using a network

connection, you will lose contact with the system. This is why it is better to do the test while being connected to the system console. This has the advantage of making the kernel dump process visible.

A typical test output should look like the following :

sudo -s

[sudo] password for ubuntu:

# echo c > /proc/sysrq-trigger

[ 31.659002] SysRq : Trigger a crash

[ 31.659749] BUG: unable to handle kernel NULL pointer dereference at (null) [ 31.662668] IP: [<ffffffff8139f166>] sysrq_handle_crash+0x16/0x20

[ 31.662668] PGD 3bfb9067 PUD 368a7067 PMD 0 [ 31.662668] Oops: 0002 [#1] SMP

[ 31.662668] CPU 1 ....

The rest of the output is truncated, but you should see the system rebooting and somewhere in the log, you will see the following line :

Begin: Saving vmcore from kernel crash ...

Once completed, the system will reboot to its normal operational mode. You will then find Kernel Crash Dump file in the /var/crash directory :

ls /var/crash

linux-image-3.0.0-12-server.0.crash

5.7. Risorse

Kernel Crash Dump is a vast topic that requires good knowledge of the linux kernel. You can find more information on the topic here :

• Kdump kernel documentation13.

• The crash tool14

• Analyzing Linux Kernel Crash15 (Based on Fedora, it still gives a good walkthrough of kernel dump analysis)

13 http://www.kernel.org/doc/Documentation/kdump/kdump.txt 14 http://people.redhat.com/~anderson/

15 http://www.dedoimedo.com/computers/crash-analyze.html

Ubuntu features a comprehensive package management system for installing, upgrading, configuring, and removing software. In addition to providing access to an organized base of over 35,000 software packages for your Ubuntu computer, the package management facilities also feature dependency resolution capabilities and software update checking.

Per l'interazione con il sistema di gestione dei pacchetti di Ubuntu sono disponibili diversi strumenti, a partire da semplici utilità a riga di comando che possono essere usate con facilità da amministratori di sistema per attività automatizzate, fino a interfacce grafiche semplici da usare per chi si è

avvicinato da poco a Ubuntu.

1. Introduzione

Il sistema di gestione dei pacchetti di Ubuntu è derivato dallo stesso sistema usato dalla distribuzione Debian GNU/Linux. I file di pacchetto contengono tutti i file, i meta-dati e le istruzioni necessari per implementare sui sistemi Ubuntu una particolare funzionalità o un'applicazione software.

Debian package files typically have the extension '.deb', and usually exist in repositories which are collections of packages found on various media, such as CD-ROM discs, or online. Packages are normally in a pre-compiled binary format; thus installation is quick, and requires no compiling of software.

Many complex packages use the concept of dependencies. Dependencies are additional packages required by the principal package in order to function properly. For example, the speech synthesis package festival depends upon the package libasound2, which is a package supplying the ALSA sound library needed for audio playback. In order for festival to function, it and all of its dependencies must be installed. The software management tools in Ubuntu will do this automatically.

2. dpkg

dpkg is a package manager for Debian-based systems. It can install, remove, and build packages, but unlike other package management systems, it cannot automatically download and install packages or their dependencies. This section covers using dpkg to manage locally installed packages:

• To list all packages installed on the system, from a terminal prompt type:

dpkg -l

• In base a quanti pacchetto sono installati nel sistema, questo comando può generare molto output.

È comunque possibile passare l'output attraverso una pipe all'applicazione grep per vedere se un particolare pacchetto è installato o meno:

dpkg -l | grep apache2

Sostituire apache2 con il nome di un qualsiasi altro pacchetto, parte del nome o qualsiasi altra espressione regolare.

• Per elencare i file installati da un pacchetto, in questo caso ufw, digitare:

dpkg -L ufw

• Se non si è sicuri di quale pacchetto abbia installato un file, usare il comando dpkg -S. Per esempio:

dpkg -S /etc/host.conf base-files: /etc/host.conf

L'output mostra che /etc/host.conf appartiene al pacchetto base-files.

Many files are automatically generated during the package install process, and even though they are on the filesystem, dpkg -S may not know which package they belong to.

• Per installare un file .deb locale, digitare:

sudo dpkg -i zip_3.0-4_i386.deb

Change zip_3.0-4_i386.deb to the actual file name of the local .deb file you wish to install.

• Per disinstallare un pacchetto:

sudo dpkg -r zip

Uninstalling packages using dpkg, in most cases, is NOT recommended. It is better to use a package manager that handles dependencies to ensure that the system is in a consistent state. For example using dpkg -r zip will remove the zip package, but any packages that

Per le ulteriori opzioni di dpkg, consultare la pagina di manuale: man dpkg.

3. Apt-Get

The apt-get command is a powerful command-line tool, which works with Ubuntu's Advanced Packaging Tool (APT) performing such functions as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.

Being a simple command-line tool, apt-get has numerous advantages over other package management tools available in Ubuntu for server administrators. Some of these advantages include ease of use over simple terminal connections (SSH), and the ability to be used in system administration scripts, which can in turn be automated by the cron scheduling utility.

Alcuni esempi di utilizzo tipico dell'utilità apt-get:

• Install a Package: Installation of packages using the apt-get tool is quite simple. For example, to install the network scanner nmap, type the following:

sudo apt-get install nmap

• Remove a Package: Removal of a package (or packages) is also straightforward. To remove the package installed in the previous example, type the following:

sudo apt-get remove nmap

Pacchetti multipli: è possibile specificare più di un pacchetto da installare o rimuovere, separati da spazi.

Also, adding the --purge option to apt-get remove will remove the package configuration files as well. This may or may not be the desired effect, so use with caution.

• Update the Package Index: The APT package index is essentially a database of available packages from the repositories defined in the /etc/apt/sources.list file and in the /etc/apt/

sources.list.d directory. To update the local package index with the latest changes made in the repositories, type the following:

sudo apt-get update

• Aggiornare i pacchetti: versioni aggiornate dei pacchetti installati possono essere disponibili attraverso i repository dei pacchetti (per esempio per aggiornamenti di sicurezza). Per aggiornare il proprio sistema è necessario, prima di tutto, aggiornare l'indice dei pacchetti come spiegato sopra, quindi digitare:

sudo apt-get upgrade

Per informazioni sull'avanzamento a un nuovo rilascio di Ubuntu, consultare la Sezione 3,

«Avanzamento di versione» [9].

Le azioni del comando apt-get, come l'installazione o la rimozione di pacchetti, vengono registrate nel file di registro /var/log/dpkg.log.

For further information about the use of APT, read the comprehensive Debian APT User Manual1 or type:

apt-get help

1 http://www.debian.org/doc/user-manuals#apt-howto

4. Aptitude

Launching Aptitude with no command-line options, will give you a menu-driven, text-based front-end to the Advanced Packaging Tool (APT) system. Many of the common package management functions, such as installation, removal, and upgrade, can be performed in Aptitude with single-key commands, which are typically lowercase letters.

Aptitude is best suited for use in a non-graphical terminal environment to ensure proper functioning of the command keys. You may start the menu-driven interface of Aptitude as a normal user by typing the following command at a terminal prompt:

sudo aptitude

When Aptitude starts, you will see a menu bar at the top of the screen and two panes below the menu bar. The top pane contains package categories, such as New Packages and Not Installed Packages.

The bottom pane contains information related to the packages and package categories.

Usare Aptitude per la gestione dei pacchetti è relativamente chiaro e l'interfaccia utente rende le operazioni comuni semplici da eseguire. Di seguito vengono presentati alcuni esempi di funzioni comuni della gestione dei pacchetti con Aptitude:

• Install Packages: To install a package, locate the package via the Not Installed Packages package category, by using the keyboard arrow keys and the ENTER key. Highlight the desired package, then press the + key. The package entry should turn green, indicating that it has been marked for installation. Now press g to be presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the installation. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more and you'll be prompted to download the package. Press ENTER on the Continue prompt, and downloading and installation of the package will commence.

• Remove Packages: To remove a package, locate the package via the Installed Packages package category, by using the keyboard arrow keys and the ENTER key. Highlight the desired package you wish to remove, then press the - key. The package entry should turn pink, indicating it has been marked for removal. Now press g to be presented with a summary of package actions. Press g again, and you will be prompted to become root to complete the removal. Press ENTER which will result in a Password: prompt. Enter your user password to become root. Finally, press g once more, then press ENTER on the Continue prompt, and removal of the package will commence.

• Update Package Index: To update the package index, simply press the u key and you will be prompted to become root to complete the update. Press ENTER which will result in a Password:

prompt. Enter your user password to become root. Updating of the package index will commence.

Press ENTER on the OK prompt when the download dialog is presented to complete the process.

• Upgrade Packages: To upgrade packages, perform the update of the package index as detailed above, and then press the U key to mark all packages with updates. Now press g whereby you'll be presented with a summary of package actions. Press g again, and you will be prompted to

become root to complete the installation. Press ENTER which will result in a Password: prompt.

Enter your user password to become root. Finally, press g once more, and you'll be prompted to download the packages. Press ENTER on the Continue prompt, and upgrade of the packages will commence.

La prima colonna delle informazioni mostrate nell'elenco dei pacchetti nel riquadro superiore, indica l'attuale stato del pacchetto, utilizzando le seguenti chiavi per descrivere lo stato del pacchetto:

• i: pacchetto installato

• c: pacchetto non installato, ma nel sistema è rimasta traccia della configurazione del pacchetto

• p: rimosso completamente dal sistema

• v: pacchetto virtuale

• B: pacchetto non integro

• u: file decompressi, ma pacchetto non ancora configurato

• C: configurato in parte. La configurazione è fallita e necessita di essere corretta

• H: installato parzialmente. La rimozione è fallita e necessita di essere sistemata

Per chiudere Aptitude, è sufficiente premere il tasto q e confermare l'uscita. Sono disponibili molte altre funzioni dal menù di Aptitude, premendo il tasto F10.

Dans le document Guida a Ubuntu Server (Page 25-34)