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

De WikiLICC
Ir para: navegação, pesquisa
m (Pacotes para o cliente NFS)
m (Cliente NFS)
 
(30 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 5: Linha 5:
 
= Servidor NFS =
 
= Servidor NFS =
 
== Instalando o servidor NFS ==
 
== Instalando o servidor NFS ==
Instalar no servidor NFS (antigamente era usado <code>portmap</code> para a comunicação)
+
Instalar no servidor NFS
  [root@one]$ yum install nfs-utils rpcbind
+
  [root@one]$ dnf install nfs-utils rpcbind
  
 
== /etc/exports ==
 
== /etc/exports ==
  
* Criar no servidor o diretório para colocar os usuários a serem exportados
+
* Criar no servidor o diretório para colocar os usuários a serem exportados (não usar o próprio <code>/home</code> pois ele já existe nas máquinas clientes, pois assim arquivos não serão montados sobre os arquivos locais).
 
  [root@one] $ cd /home
 
  [root@one] $ cd /home
 
  [root@one] $ mkdir /home/export
 
  [root@one] $ mkdir /home/export
(não usar o próprio <code>/home</code> pois ele já existe nas máquinas clientes, pois assim arquivos não serão montados sobre os arquivos locais).
+
[root@one] $ mkdir /home/export/alunos
 +
[root@one] $ mkdir /home/export/docentes
 +
[root@one] $ mkdir /share
 +
 
 +
 
  
 
* Configurar o arquivo
 
* Configurar o arquivo
 
  [root@one] $ vi /etc/exports
 
  [root@one] $ vi /etc/exports
Este arquivo contém quais arquivos serão compartilhados. Para comentários use o sinal <code>#</code>.  O formato é
+
Este arquivo contém quais arquivos serão compartilhados. (Usando endereços IP não requer que DNS esteja de pé e rodando)
 
  # <dir a ser compartilho> <clientes permitidos>(opções)
 
  # <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.0/24(rw,no_root_squash,sync,subtree_check,no_wdelay)
 +
/share      192.168.0.100(ro)
 
  #
 
  #
 
  # /home/export 192.168.0.101(rw)  # um endereço IP
 
  # /home/export 192.168.0.101(rw)  # um endereço IP
Linha 25: Linha 30:
 
  # /home/export .matrix.net(rw)    # um dominio
 
  # /home/export .matrix.net(rw)    # um dominio
 
  # /home/export 192.1680.0.1/24(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]
 
* Ver [LDAP]
Linha 39: Linha 42:
  
 
== Reiniciando o servidor NFS ==
 
== Reiniciando o servidor NFS ==
  [root@one]$ service nfs start
+
  [root@one]$ systemctl start  nfs
  [root@one]$ service rpcbind start   # portmap para versões antigas
+
  [root@one]$ systemctl stop  rpcbind   # portmap para versões antigas
 
+
[root@one]$ systemctl start rpcbind  # portmap para versões antigas
 +
ou na ordem contrária.
 
Para modificar outras diretivas NFS não padrões, modifique /etc/sysconfig/nfs
 
Para modificar outras diretivas NFS não padrões, modifique /etc/sysconfig/nfs
  
 
Para verificar que o mount esta sendo compartilhado,  
 
Para verificar que o mount esta sendo compartilhado,  
 
  [root@one]$  showmount -e
 
  [root@one]$  showmount -e
  Export list for gyrfalcon:     HHHHHMMMMM, nao ainda
+
  Export list for one:
  /shared 192.168.1/17
+
  /home/export 192.168.0.100
 +
 
  
 
* http://techgurulive.com/2008/09/15/fedora-9-quick-nfs-server-howto/
 
* http://techgurulive.com/2008/09/15/fedora-9-quick-nfs-server-howto/
Linha 55: Linha 60:
 
  [root@one]$ nfsstat -o net
 
  [root@one]$ nfsstat -o net
  
= Cliente NFS =
+
= Cliente NFS (usando DRBL) =
  
 
== Pacotes para o cliente NFS ==
 
== Pacotes para o cliente NFS ==
Instalar nos clientes NFS (antigamente era usado <code>portmap</code> para a comunicação)
+
Instalar nos clientes NFS  
  [root@one]$ yum install nfs-utils rpcbind
+
  [root@cell100]$ yum install nfs-utils rpcbind
 +
 
 +
* Criar no cliente um diretório para colocar os diretórios a serem importados
 +
[root@cell100] $ cd /home
 +
[root@cell100] $ mkdir /home/export
  
 
== /etc/fstab ==
 
== /etc/fstab ==
<code>/etc/fstab</code> provides the opposite functionality as <code>/etc/exports</code> - 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:
+
Este arquivo fornece a funcionalidade oposta ao <code>/etc/exports</code> - ao invés de contar o que exportar, informa o que importar.  
  
  <source to mount from> <local mount point> <type of filesystem> <options> <dump> <pass>
+
Adicione a última linha ao arquivo (será montado automaticamente quando a máquina é iniciada)
 +
  [root@cell100] $ vi /etc/fstab
 +
#
 +
UUID=4410482b-b774-4129-8df7-e91bced7206d /      ext4    defaults        1 1
 +
UUID=4083cf64-0477-476c-a116-a39c7f47847b /boot  ext3    defaults        1 2
 +
UUID=1d1ee881-d431-46df-b387-d180f239f388 swap  swap    defaults        0 0
 +
tmpfs                      /dev/shm            tmpfs  defaults        0 0
 +
devpts                      /dev/pts            devpts  gid=5,mode=620  0 0
 +
sysfs                      /sys                sysfs  defaults        0 0
 +
proc                        /proc                proc    defaults        0 0
 +
192.168.0.99:/home/export  /home/export        nfs    defaults        0 0
  
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
+
Usando defaults utiliza as opções setadas no servidor NFS em <code>/etc/exports</code>.
  
:<code><NFS server>:<remote location></code>
+
Para montar o diretório NFS sem resetar a máquina use
 +
[root@cell100 /]# mount -v 192.168.0.99:/share /share
  
You should be able to use the <code>defaults</code> option, which uses the options you set up in <code>/etc/exports</code> on the NFS server, and <code>dump</code> and <code>pass</code> don't need to enabled, so they can have <code>0's</code>.
+
Usando mount é possível ver os diretórios montados.
 +
[root@cell100 /]# mount
  
My <code>/etc/fstab</code> looks like this.
+
=== Criar link simbólico===
 
+
  [root@cell100] $ mkdir /share
<pre>
+
  [root@cell100] $ cd /share
# /etc/fstab: static file system information.
+
  [root@cell100] $ ln -s /home/dago /share/dago
#
 
# <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
 
</pre>
 
 
 
After specifying it in <code>/etc/fstab</code>, it will automatically be mounted when the machine starts up, if the mount point exists. (If you're using <code>/shared</code> 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
 
 
 
: '''<code>mount <mount point></code>'''
 
 
 
For instance, mine would be <code>mount /shared</code>.  Similarly, you can also do <code>umount <mount point></code> to unmount a filesystem.
 
  
 
== Troubleshooting: NFS Mounts not Loading at Boot ==
 
== 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 <code>mount -a</code> as root as soon as the system booted up, but it wouldn't boot at load time, despite the <code>/etc/fstab</code> file.  To "hack fix" it, I added my own script at <code>/etc/rcS.d/S46mymount</code>.  (46 runs right after S45mountnfs.sh and S46mountnfs-bootclean.sh.)  It needs to be executable (<code>chmod +x nfshack</code>), but the file itself is simply:
 
I had a problem with my firewall not automatically mounting the NFS systems at boot, for whatever reason.  I could issue <code>mount -a</code> as root as soon as the system booted up, but it wouldn't boot at load time, despite the <code>/etc/fstab</code> file.  To "hack fix" it, I added my own script at <code>/etc/rcS.d/S46mymount</code>.  (46 runs right after S45mountnfs.sh and S46mountnfs-bootclean.sh.)  It needs to be executable (<code>chmod +x nfshack</code>), but the file itself is simply:
  
<pre>
+
#!/bin/bash
#!/bin/bash
+
mount -a
 
 
mount -a
 
</pre>
 
 
 
If anyone knows of a better fix for this, please contact me at kwanous <at> debianclusters <dot> org.
 
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Linha 121: Linha 122:
 
  [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.
 +
 +
;Erros:
 +
[root@cell100 etc]# mount -v 192.168.0.99:/home/export2 /home/export2/
 +
mount.nfs: trying text-based options 'vers=4,addr=192.168.0.99,clientaddr=192.168.0.100'
 +
mount.nfs: mount(2): No route to host
 +
Causa: Provavelmente firewall ativa. Desativar iptables ou consertar.
  
 
== 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
 +
 +
*http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch04_:_Simple_Network_Troubleshooting
 +
*http://tldp.org/HOWTO/NFS-HOWTO/troubleshooting.html, Dicas
 +
*http://www.linuxconfig.org/HowTo_configure_NFS

Edição atual tal como às 22h05min de 27 de junho de 2017

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

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

/etc/exports

  • Criar no servidor o diretório para colocar os usuários a serem exportados (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).
[root@one] $ cd /home
[root@one] $ mkdir /home/export
[root@one] $ mkdir /home/export/alunos
[root@one] $ mkdir /home/export/docentes
[root@one] $ mkdir /share


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

Este arquivo contém quais arquivos serão compartilhados. (Usando endereços IP não requer que DNS esteja de pé e rodando)

# <dir a ser compartilho> <clientes permitidos>(opções)
/home/export 192.168.0.0/24(rw,no_root_squash,sync,subtree_check,no_wdelay)
/share       192.168.0.100(ro)
#
# /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
  • 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]$ systemctl start  nfs
[root@one]$ systemctl stop   rpcbind   # portmap para versões antigas
[root@one]$ systemctl start  rpcbind   # portmap para versões antigas

ou na ordem contrária. 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 one:
/home/export 192.168.0.100


Monitoração

Para monitorar o sistema

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

Cliente NFS (usando DRBL)

Pacotes para o cliente NFS

Instalar nos clientes NFS

[root@cell100]$ yum install nfs-utils rpcbind
  • Criar no cliente um diretório para colocar os diretórios a serem importados
[root@cell100] $ cd /home
[root@cell100] $ mkdir /home/export

/etc/fstab

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

Adicione a última linha ao arquivo (será montado automaticamente quando a máquina é iniciada)

[root@cell100] $ vi /etc/fstab
#
UUID=4410482b-b774-4129-8df7-e91bced7206d /      ext4    defaults        1 1
UUID=4083cf64-0477-476c-a116-a39c7f47847b /boot  ext3    defaults        1 2
UUID=1d1ee881-d431-46df-b387-d180f239f388 swap   swap    defaults        0 0
tmpfs                       /dev/shm             tmpfs   defaults        0 0
devpts                      /dev/pts             devpts  gid=5,mode=620  0 0
sysfs                       /sys                 sysfs   defaults        0 0
proc                        /proc                proc    defaults        0 0
192.168.0.99:/home/export   /home/export         nfs     defaults        0 0

Usando defaults utiliza as opções setadas no servidor NFS em /etc/exports.

Para montar o diretório NFS sem resetar a máquina use

[root@cell100 /]# mount -v 192.168.0.99:/share /share

Usando mount é possível ver os diretórios montados.

[root@cell100 /]# mount

Criar link simbólico

[root@cell100] $ mkdir /share
[root@cell100] $ cd /share
[root@cell100] $ ln -s /home/dago /share/dago

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

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.

Erros
[root@cell100 etc]# mount -v 192.168.0.99:/home/export2 /home/export2/
mount.nfs: trying text-based options 'vers=4,addr=192.168.0.99,clientaddr=192.168.0.100'
mount.nfs: mount(2): No route to host

Causa: Provavelmente firewall ativa. Desativar iptables ou consertar.

Veja