User Tools

Site Tools


informatica:linux:nfs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
informatica:linux:nfs [2013/05/16 08:08] javiinformatica:linux:nfs [2013/09/26 18:57] javi
Line 1: Line 1:
 ====== NFS ====== ====== NFS ======
  
-nfs portmap+===== NFSv3 =====
  
-===== Instalacion =====+==== Instalacion ====
  
 En el servidor se instalan los paquetes: En el servidor se instalan los paquetes:
Line 9: Line 9:
   sudo aptitude install nfs-common nfs-kernel-server   sudo aptitude install nfs-common nfs-kernel-server
  
-===== Configuracion servidor ===== 
  
-==== NFSv4 ==== +==== Configuracion servidor ====
- +
-https://help.ubuntu.com/community/NFSv4Howto +
- +
-NFSv4 without Kerberos +
- +
-1. Crear el directorio a exportar (una especie de enlace simbolico): +
- +
-  sudo mkdir /opt/export +
- +
-2. Montar el directorio: +
- +
-  sudo vim /etc/fstab +
- +
-Y anyadir la siguiente linea: +
- +
-  /srv/data /opt/export   none    bind  0  0 +
- +
-3. Editar: +
- +
-  sudo vim /etc/default/nfs-kernel-server +
- +
-Con la siguiente linea: +
- +
-  NEED_SVCGSSD=no +
- +
-4. Yo por comodida reinicio el servidor, supongo que se pueden reiniciar servicios: +
- +
-  sudo mount /opt/export +
-  sudo exportfs -rav +
- +
-==== NFSv3 ====+
  
 1. Editar el fichero:  1. Editar el fichero: 
Line 48: Line 16:
   sudo vim /etc/exports   sudo vim /etc/exports
  
-Se añade la linea: +Se añade la linea con la carpeta a comartir, en este caso /home/datos
  
   #recurso       ips con acceso              permisos    #recurso       ips con acceso              permisos 
Line 57: Line 25:
   sudo exportfs -rav   sudo exportfs -rav
  
-===== Configuracion cliente =====+==== Configuracion cliente ====
  
 1. Instalar estos paquetes: 1. Instalar estos paquetes:
Line 75: Line 43:
   mount /mnt/raid   mount /mnt/raid
  
-===== Puertos =====+==== Puertos ====
  
 http://www.lowth.com/LinWiz/nfs_help.html http://www.lowth.com/LinWiz/nfs_help.html
Line 118: Line 86:
 | rpc.rquotad | quota | Random | 4003 | Install "quota" package version 3.08 or later and edit /etc/rpc and /etc/services | | rpc.rquotad | quota | Random | 4003 | Install "quota" package version 3.08 or later and edit /etc/rpc and /etc/services |
  
- +==== Establecer puertos fijos ====
- +
- +
- +
- +
-===== Establecer puertos fijos =====+
  
   * **Fijar puerto de status:**   * **Fijar puerto de status:**
Line 210: Line 173:
 </code> </code>
  
-===== Ejemplo reglas iptables =====+ 
 + 
 +==== Ejemplo reglas iptables ====
  
 <code> <code>
Line 219: Line 184:
 VM="10.0.0.0/24" VM="10.0.0.0/24"
 KVM_VM_IP="10.0.0.1" KVM_VM_IP="10.0.0.1"
 +KVM_LAN_IP="192.168.1.2"
  
 NFS_PORTS=" NFS_PORTS="
Line 232: Line 198:
     then     then
         $IPTABLES -A INPUT -i $VIRT_IF -s $VM -d $KVM_VM_IP -p tcp --dport $port -j ACCEPT         $IPTABLES -A INPUT -i $VIRT_IF -s $VM -d $KVM_VM_IP -p tcp --dport $port -j ACCEPT
-        $IPTABLES -A INPUT -i $VIRT_IF -s $VM -d $KVM_VM_IF -p udp --dport $port -j ACCEPT+        $IPTABLES -A INPUT -i $VIRT_IF -s $VM -d $KVM_VM_IP -p udp --dport $port -j ACCEPT
     fi     fi
 done done
 +# NFSD
 +$IPTABLES -A INPUT -i $VIRT_IF -s $VM -d $KVM_LAN_IP -p tcp --dport 2049 -j ACCEPT
 </code> </code>
 +
 +===== NFSv4 =====
 +
 +
 +
 +==== Instalacion ====
 +
 +**IMPORTANTE** NFSv4 exporta de forma distinta que NFSv3. En este ejemplo vamos a exportar:
 +
 +^ Directorio donde se alojan los archivos ^ Punto de montaje en el servidor ^
 +| /srv/www | /srv/nfs/cliente1.example.com/www |
 +| /srv/svn | /srv/nfs/cliente1.example.com/svn |
 +
 +1. Servidor:
 +
 +  sudo aptitude install nfs-common nfs-kernel-server
 +
 +2. Cliente:
 +
 +  sudo aptitude install nfs-common
 +  
 +NOTA: en principio rpcbind **NO** hace falta
 +
 +==== Configuracion comun (misma en servidor y cliente) ====
 +
 +1. Configurar los siguientes archivos:
 +
 +**/etc/default/nfs-common**
 +
 +<code>
 +# If you do not set values for the NEED_ options, they will be attempted
 +# autodetected; this should be sufficient for most people. Valid alternatives
 +# for the NEED_ options are "yes" and "no".
 +
 +# Do you want to start the statd daemon? It is not needed for NFSv4.
 +NEED_STATD=
 +
 +# Options for rpc.statd.
 +#   Should rpc.statd listen on a specific port? This is especially useful
 +#   when you have a port-based firewall. To use a fixed port, set this
 +#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
 +#   For more information, see rpc.statd(8) or http://wiki.debian.org/SecuringNFS
 +STATDOPTS=
 +
 +# Do you want to start the idmapd daemon? It is only needed for NFSv4.
 +NEED_IDMAPD=yes
 +
 +# Do you want to start the gssd daemon? It is required for Kerberos mounts.
 +NEED_GSSD=
 +</code>
 +
 +**/etc/idmapd.conf**
 +
 +<code>
 +[General]
 +
 +Verbosity = 1
 +Pipefs-Directory = /var/lib/nfs/rpc_pipefs
 +domain = dev.local.legido.com
 +
 +[Mapping]
 +
 +Nobody-User = nobody
 +Nobody-Group = nogroup
 +</code>
 +
 +**IMPORTANTE**: es clave la entrada "domain", que en mi caso es la misma en el servidor que en el cliente (quiza no sea necesario)
 +
 +==== Configuracion servidor ====
 +
 +0. Realizar los pasos anteriores
 +
 +1. Configurar los siguientes archivos:
 +
 +**/etc/exports**
 +
 +  /srv    cliente1.example.com/255.255.255.0(rw,no_root_squash,no_subtree_check,crossmnt,fsid=0)
 +
 +2. Se reinicia el servicio:  
 +
 +  sudo exportfs -rav
 +
 +
 +
 +==== Configuracion cliente ====
 +
 +1. Ver los recursos que ofrece el servidor:
 +
 +  sudo showmount -e nfs_server.example.com
 +
 +2. Montar el recurso:
 +
 +  sudo mount -v -t nfs4 nfs_server.example.com:/ /mnt/nfs
 +
 +3. Comprobar permisos:
 +
 +  ls -la /mnt/nfs
 +
 +**NO** deberia pertenecer a nobody:nogroup
 +
 +4. Para montar definitivamente editar:
 +
 +  sudo vim /etc/fstab
 +
 +Y anyadir la siguiente entrada:
 +
 +   nfs_server.example.com:/ /mnt/nfs nfs users 0 0
 +
 +5. Ahora lo puede montar cualquier usuario:
 +
 +  mount /mnt/nfs
informatica/linux/nfs.txt · Last modified: 2015/04/13 20:19 by 127.0.0.1