Mudanças entre as edições de "Minicluster:NFS"

De WikiLICC
Ir para: navegação, pesquisa
m (/etc/fstab)
m (Troubleshooting)
Linha 119: Linha 119:
 
  [root]$ rpcinfo -p
 
  [root]$ rpcinfo -p
 
  [root]$ /usr/sbin/ntsysv        # servicos inicicializados.
 
  [root]$ /usr/sbin/ntsysv        # servicos inicicializados.
 +
Tudo que é importante é logged em /var/log/messages.
  
 
== Veja ==
 
== Veja ==
 
* http://www.debianhelp.co.uk/nfs.htm
 
* http://www.debianhelp.co.uk/nfs.htm
 
* http://uwsg.indiana.edu/usail/network/nfs/tips.html
 
* http://uwsg.indiana.edu/usail/network/nfs/tips.html

Edição das 23h50min de 25 de junho de 2010

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 servidor 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

Monitoração

Para monitorar o sistema

[root@one]$ nfsstat
[root@one]$ nfsstat -o net

Cliente NFS

Pacotes para o cliente NFS

Instalar nos clientes NFS (antigamente era usado portmap para a comunicação)

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

/etc/fstab

/etc/fstab fornece a funcionalidade oposta ao /etc/exports - ao invés de contar o que exportar, informa o que importar. O formato é

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

Adicione a linha NFS depois do drive local ser montado. Use

<NFS server>:<remote location>

Deveria estar apto a usar a opção defaults, que usa as opções setadas no servidor NFS em /etc/exports, e dump e pass não precisam ser habilitados (assim podem ter 0).

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


Ferramentas:

[root]$ chkconfig
[root]$ system-config-services
[root]$ rpcinfo -p
[root]$ /usr/sbin/ntsysv        # servicos inicicializados.

Tudo que é importante é logged em /var/log/messages.

Veja