GNU/Linux >> Linux Esercitazione >  >> Cent OS

Come montare filesystem NFS con 'autofs' su CentOS/RHEL

Questo articolo spiega come configurare 'autofs' per montare filesystem NFS tramite il servizio autofs.

1. Ferma il servizio 'autofs': verifica se è in esecuzione e poi arrestalo.

# service autofs status
automount (pid 25285) is running...
# service autofs stop
Stopping automount: [  OK  ]
# service autofs status
automount is stopped

2. Modifica il file /etc/auto.master per impostare la mappa dei file. Il file /etc/auto.master è il file di configurazione principale del servizio 'autofs': contiene l'elenco dei mount point gestiti da 'autofs' e i corrispondenti file di configurazione o sorgenti di rete, noti come 'automount maps'. Ecco come dovrebbe presentarsi:

# Sample auto.master file
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# For details of the format look at autofs(5).
#
/misc /etc/auto.misc --------------------> MAP FILE
#
# NOTE: mounts done from a hosts map will be mounted with the
# "nosuid" and "nodev" options unless the "suid" and "dev"
# options are explicitly given.
#
/net -hosts
#
# Include central master map if it can be found using
# nsswitch sources.
#
# Note that if there are entries for /net or /misc (as
# above) in the included master map any keys that are the
# same will not be seen as the first read key seen takes
# precedence.
#
+auto.master

La 'map file' può essere cambiata con qualunque altro file in /etc chiamato 'auto.mount', per montare l'export in qualsiasi altra directory desiderata.

Modifica il file 'auto.master' e aggiungi il simbolo cancelletto davanti alla riga «/misc /etc/auto.misc», poi aggiungi la riga seguente alla fine del file:

/- /etc/auto.mount

Dopo la modifica il file dovrebbe presentarsi così:

#
/misc /etc/auto.misc
#- /etc/auto.mount

Attenzione: la sintassi corretta è «/- /etc/auto.mount», dove «/-» indica una mappa di tipo direct map.

/- /etc/auto.mount

3. Crea e/o modifica il file di mappa. Il file di mappa è un file separato che definisce i filesystem da montare sotto un determinato mount point. Per esempio, /etc/auto.misc può definire mount point nella directory /misc; in alternativa puoi usare /mnt. Se serve un'altra directory, crea un nuovo file in /etc con il nome 'auto.mount', come da nostra raccomandazione.

Di seguito un esempio di file '/etc/auto.misc' e del nuovo file 'auto.mount':

# This is an automounter map and it has the following format
# key(mount-point) [ -mount-options-separated-by-comma ] location
# ===> THIS IS THE GENERAL FORMAT OF THE MAPS
# Details may be found in the autofs(5) manpage
cd        -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom     ===> EXAMPLE
# the following entries are samples to pique your imagination
#linux      -ro,soft,intr           ftp.example.org:/pub/linux
#boot       -fstype=ext2            :/dev/hda1
#floppy     -fstype=auto            :/dev/fd0
#floppy     -fstype=ext2            :/dev/fd0
#e2floppy   -fstype=ext2            :/dev/fd0
#jaz        -fstype=ext2            :/dev/sdc1
#removable  -fstype=ext2            :/dev/hdd
mount_point_name  -rw,soft,intr,rsize=8192,wsize=8192  NFS.example.net:/export_name
===> IP address can be used instead of the FQDN

Se non vuoi usare la directory /misc né il file 'auto.misc', crea un nuovo file chiamato 'auto.mount' e aggiungi gli stessi parametri con la sintassi corrispondente, come nell'esempio seguente:

# vi /etc/auto.mount

Aggiungi la riga:

/mount_point  -fstype=nfs,rw  NFS.example.net:/export_name

NOTA: assicurati di aver modificato il file '/etc/auto.master' cambiando il file di mappa con quello desiderato.

4. Avvia il servizio 'autofs':

# service autofs start
Starting automount: [  OK  ]

5. Esegui il comando 'mount' per verificare che la tua condivisione NFS sia ora montata:

# mount
NFS_IP_Address:/export on /mount_point type nfs (rw,vers=4,addr=NFS_IP_Address,clientaddr=local_IP_Address)

Suggerimento: con autofs il mount point viene popolato solo quando vi si accede: per questo nel listato di 'mount' potrebbe non comparire finché non lo usi. Accedi alla directory e poi verifica di nuovo.

Cent OS
  1. Configurare autofs su CentOS 7 e RHEL 7

  2. Configurare un server NFS su CentOS 7 / RHEL 7

  3. Monitorare operazioni mount e umount con auditd su CentOS/RHEL 6 e 7

  4. Trovare il pacchetto di un file mancante con yum

  5. Come disabilitare la cache del client NFS in CentOS/RHEL

Come abilitare Kdump su RHEL 7 e CentOS 7

Configurare server e client NFS su CentOS 8 o RHEL 8

Installare e usare Fail2ban su RHEL 8 / CentOS 8

Utilizzare tmpfs su RHEL e CentOS 7

Come installare Flameshot su RHEL/CentOS con Snapcraft

Come diagnosticare la latenza di trasferimento NFS con nfsiostat in CentOS / RHEL