Minicluster:NFS

De WikiLICC
Revisão de 22h56min de 25 de junho de 2010 por Dago (Discussão | contribs) (Cliente NFS)
Ir para: navegação, pesquisa

O Network File System (NFS) permite que todo o cluster compartilhe parte de seu sistema de arquivos. Neste paradigma, uma ou mais máquinas guardam os arquivos no seu disco físico e agem como um servidor NFS enquanto que os outros "mount" o sistema de arquivos localmente. Para o usuário, parece que seus arquivos existem em todas as máquinas de uma só vez.

Se houver mais de um servidor de arquivos (digamos MESTRE1 e MESTRE2), eles não podem compartilhar o mesmo diretório /home (mas um poder compartilhar o /home/students e o outro pode compartilhar /home/faculty.)

Servidor NFS

Instalando o servidor NFS

Instalar no servido NFS (antigamente era usado portmap para a comunicação)

[root@one]$ yum install nfs-utils rpcbind

/etc/exports

  • Criar no servidor o diretório para colocar os usuários a serem exportados
[root@one] $ cd /home
[root@one] $ mkdir /home/export

(não usar o próprio /home pois ele já existe nas máquinas clientes, pois assim arquivos não serão montados sobre os arquivos locais).

  • Configurar o arquivo
[root@one] $ vi /etc/exports

Este arquivo contém quais arquivos serão compartilhados. Para comentários use o sinal #. O formato é

# <dir a ser compartilho> <clientes permitidos>(opções)
/home/export 192.168.0.0/24(rw,no_root_squash,sync,subtree_check,no_wdelay)
#
# /home/export 192.168.0.101(rw)   # um endereço IP
# /home/export cell101(rw)         # uma maquina
# /home/export .matrix.net(rw)     # um dominio
# /home/export 192.1680.0.1/24(rw) # um dominio

(Usando endereços IP não requer que DNS esteja de pé e rodando)

  • Ver [LDAP]

Opções para /etc/exports

  • rw - permite read e write ao sistema de arquivos.
  • ro - read only é o default do NFS.
  • async/sync - Assíncrona perminte que o servidor NFS respond to requests before committing changes. According to man, this can improve performance but can corrupt data in the event of a crash. Synchronous is the default.
  • wdelay/no_wdelay - Write delay allows the NFS server to put off committing changes to disk if it suspects that another write is coming shortly.
  • subtree_check/no_subtree_check - Subtree checking improves security by checking not just that the client has rights to mount a directory, but all of the directory's subdirectories as well. Subtree checking is enabled by default, but the NFS server will complain if you don't specifically indicate it.
  • root_squash/no_root_squash - Root squashing prevents a root user on a machine using the filesystem to act as it if is the root user on the actual filesystem; this is more secure. It is on by default.

Reiniciando o servidor NFS

[root@one]$ service nfs start
[root@one]$ service rpcbind start    # portmap para versões antigas

Para modificar outras diretivas NFS não padrões, modifique /etc/sysconfig/nfs

Para verificar que o mount esta sendo compartilhado,

[root@one]$  showmount -e
Export list for gyrfalcon:     HHHHHMMMMM, nao ainda
/shared 192.168.1/17

Cliente NFS

Pacotes para o cliente NFS

Any machines that will act as NFS clients and will be using the shared filesystem need to

apt-get install nfs-common

Again, portmap is included with nfs-common, so it doesn't need to be installed separately. Then /etc/fstab needs to be configured.

/etc/fstab

/etc/fstab provides the opposite functionality as /etc/exports - rather than telling what to export, this file tells the machine what to import and where to mount it. In other words, this includes eventhing it needs to mount, even its own hard drives, floppy drives, cdrom drives, and such. The format of this file is as follows:

<source to mount from> <local mount point> <type of filesystem> <options> <dump> <pass>

You'll want to add the NFS line under any existing lines, so that it gets mounted after your local drives. When you specify an NFS mount, use

<NFS server>:<remote location>

You should be able to use the defaults option, which uses the options you set up in /etc/exports on the NFS server, and dump and pass don't need to enabled, so they can have 0's.

My /etc/fstab looks like this.

# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/sda1       /               ext3    defaults,errors=remount-ro 0       1
/dev/sda2       none            swap    sw              0       0
/dev/hdb        /media/cdrom0   udf,iso9660 user,noauto     0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0
192.168.1.200:/shared     /shared   nfs     defaults        0       0

After specifying it in /etc/fstab, it will automatically be mounted when the machine starts up, if the mount point exists. (If you're using /shared or another directory that isn't automatically created as part of Debian, you'll need to create the directory.) To mount it without having to reboot, use

mount <mount point>

For instance, mine would be mount /shared. Similarly, you can also do umount <mount point> to unmount a filesystem.

Troubleshooting: NFS Mounts not Loading at Boot

I had a problem with my firewall not automatically mounting the NFS systems at boot, for whatever reason. I could issue mount -a as root as soon as the system booted up, but it wouldn't boot at load time, despite the /etc/fstab file. To "hack fix" it, I added my own script at /etc/rcS.d/S46mymount. (46 runs right after S45mountnfs.sh and S46mountnfs-bootclean.sh.) It needs to be executable (chmod +x nfshack), but the file itself is simply:

#!/bin/bash

mount -a

If anyone knows of a better fix for this, please contact me at kwanous <at> debianclusters <dot> org.

Troubleshooting

Algumas vezes um erro ocorre:

[maquina~] $ mount /shared
mount: RPC: Timed out

Reiniciando o serviço portmap funcionou para o autor:

[maquina~] $ /etc/init.d/portmap stop
Stopping portmap daemon....
[maquina~] $ /etc/init.d/portmap start
Starting portmap daemon....
[maquina~] $ mount /shared

Veja