Partage NFS
Environnement de travail :
…
Manipulations :
--- --- installation du serveur + des vérifications
--- root@serveur:~# apt-get install nfs-kernel-server nfs-common portmap
...
Paramétrage de nfs-kernel-server (1:1.2.2-4squeeze2) ...
Creating config file /etc/exports with new version
Creating config file /etc/default/nfs-kernel-server with new version Starting NFS common utilities: statd.
Exporting directories for NFS kernel daemon....
Starting NFS kernel daemon: nfsd mountd.
root@serveur:~# ps -ef | grep nfs
root 1442 2 0 09:08 ? 00:00:00 [nfsd4]
root 1443 2 0 09:08 ? 00:00:00 [nfsd]
root 1444 2 0 09:08 ? 00:00:00 [nfsd]
root 1445 2 0 09:08 ? 00:00:00 [nfsd]
root 1446 2 0 09:08 ? 00:00:00 [nfsd]
root 1447 2 0 09:08 ? 00:00:00 [nfsd]
root 1448 2 0 09:08 ? 00:00:00 [nfsd]
root 1449 2 0 09:08 ? 00:00:00 [nfsd]
root 1450 2 0 09:08 ? 00:00:00 [nfsd]
root 1461 1140 0 09:11 pts/1 00:00:00 grep nfs
root@serveur:~# cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
root@serveur:~# cat /etc/default/nfs-kernel-server
# Number of servers to start up RPCNFSDCOUNT=8
# Runtime priority of server (see nice(1)) RPCNFSDPRIORITY=0
# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/?SecuringNFS RPCMOUNTDOPTS=--manage-gids
# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD=
# Options for rpc.svcgssd.
RPCSVCGSSDOPTS=
--- --- configuration d'un partage nfs
--- root@serveur:~# nano /etc/exports
root@serveur:~# cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/srv/rep *(rw,sync,no_root_squash)
root@serveur:~# exportfs -a
exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "*:/srv/rep".
Assuming default behaviour ('no_subtree_check').
NOTE: this default has changed since nfs-utils version 1.0.x root@serveur:~# exportfs
/srv/rep <world>
root@serveur:~# echo "Bonjour tout le monde" > /srv/rep/f.txt
---
--- configuration d'un client
--- root@client:~# apt-get install nfs-common portmap
...
root@client:~# mkdir /mnt/rep
root@client:~# mount -t nfs 192.168.56.101:/srv/rep /mnt/rep root@client:~# ls /mnt/rep/
f.txt
root@client:~# cat /mnt/rep/f.txt Bonjour tout le monde
root@client:~# mount | grep nfs
192.168.56.101:/srv/rep on /mnt/rep type nfs (rw,addr=192.168.56.101) root@client:~# nano /etc/fstab
root@client:~# cat /etc/fstab |grep nfs
192.168.56.101:/srv/rep /mnt/rep nfs rw,sync,no_root_squash 0 0 root@client:~# umount /mnt/rep/
root@client:~# mount | grep nfs root@client:~# mount -a
root@client:~# mount | grep nfs
192.168.56.101:/srv/rep on /mnt/rep type nfs (rw,addr=192.168.56.101)
---
--- on revient au serveur
---
# man showmount
SHOWMOUNT(8) SHOWMOUNT(8) NOM
showmount - Afficher des informations sur les montages en cours sur un serveur NFS
SYNOPSIS
showmount [ -adehv ] [ --all ] [ --directories ] [ --exports ] [ --help ] [ --version ] [ serveurNFS ]
DESCRIPTION
showmount demande des informations, via le démon chargé des partages, sur une machine distante. Exécuté sans aucune option, showmount affiche la liste des clients ayant monté des systèmes de fichiers NFS depuis ce serveur. L'affichage produit par showmount est conçu pour apparaître filtré par « sort -u ».
root@serveur:~# showmount Hosts on serveur:
192.168.56.103
root@serveur:~# showmount -a All mount points on serveur:
192.168.56.103:/srv/rep
--- ---
root@serveur:~# man nfsstat NOM
nfsstat - Afficher des statistiques NFS SYNOPSIS
nfsstat [OPTION]...
DESCRIPTION
La commande nfsstat affiche des statistiques concernant l'activité du client et du serveur NFS.
OPTIONS ...
EXEMPLES
nfsstat -o all -234
Afficher toutes les informations à propos de toutes les versions de NFS.
nfsstat --verbose -234
Identique à celle du dessus.
nfsstat -o all
Afficher toutes les informations à propos des versions de NFS en cours d'utilisation.
nfsstat --nfs --server -3
Afficher les statistiques pour la version 3 du serveur NFS.
nfsstat -m
Afficher les informations à propos de tous les systèmes de fichiers NFS montés.
root@serveur:~# nfsstat -c
Error: No Client Stats (/proc/net/rpc/nfs: No such file or directory).
root@serveur:~# nfsstat -s Server rpc stats:
calls badcalls badauth badclnt xdrcall
52 0 0 0 0
Server nfs v3:
null getattr setattr lookup access readlink 11 30% 8 22% 0 0% 4 11% 4 11% 0 0%
read write create mkdir symlink mknod
1 2% 0 0% 0 0% 0 0% 0 0% 0 0%
...
Server nfs v4:
null compound 6 42% 8 57%
Server nfs v4 operations:
...
root@client:~# nfsstat -s
Error: No Server Stats (/proc/net/rpc/nfsd: No such file or directory).
root@client:~# nfsstat -c Client rpc stats:
calls retrans authrefrsh
38 0 0
Client nfs v3:
null getattr setattr lookup access readlink
0 0% 8 33% 0 0% 4 16% 4 16% 0 0%
read write create mkdir symlink mknod
1 4% 0 0% 0 0% 0 0% 0 0% 0 0%
remove rmdir rename link readdir readdirplus
0 0% 0 0% 0 0% 0 0% 0 0% 1 4%
fsstat fsinfo pathconf commit
0 0% 4 16% 2 8% 0 0%
root@client:~# nfsstat -m
/mnt/rep from 192.168.56.101:/srv/rep Flags:
rw,relatime,vers=3,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,timeo=600,r etrans=2,sec=sys,mountaddr=192.168.56.101,mountvers=3,mountport=42168,mountproto
=udp,addr=192.168.56.101