informatica:linux:nfs
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatica:linux:nfs [2013/03/12 11:13] – javi | informatica:linux:nfs [2015/04/13 20:19] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
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 | ||
- | En el servidor | + | |
+ | ==== Configuracion | ||
+ | |||
+ | 1. Editar | ||
sudo vim / | sudo vim / | ||
- | Se añade la linea: | + | Se añade la linea con la carpeta a comartir, en este caso /home/datos: |
# | # | ||
/home/datos 192.168.1.0/ | /home/datos 192.168.1.0/ | ||
- | Se reinicia el servicio: | + | 2. Se reinicia el servicio: |
sudo exportfs -rav | sudo exportfs -rav | ||
- | Desde el cliente | + | ==== Configuracion |
+ | |||
+ | 1. Instalar | ||
sudo aptitude install nfs-common portmap | sudo aptitude install nfs-common portmap | ||
- | y se monta el recurso donde 192.168.1.3 es la ip del servidor i /home/datos su recurso compartido y /mnt/raid donde lo queremos montar en el cliente: | + | 2. Y se monta el recurso donde 192.168.1.3 es la ip del servidor i /home/datos su recurso compartido y /mnt/raid donde lo queremos montar en el cliente: |
sudo mount -t nfs 192.168.1.3:/ | sudo mount -t nfs 192.168.1.3:/ | ||
Line 38: | Line 43: | ||
mount /mnt/raid | mount /mnt/raid | ||
- | + | ==== Puertos ==== | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ===== Puertos | + | |
http:// | http:// | ||
Line 89: | Line 86: | ||
| rpc.rquotad | quota | Random | 4003 | Install " | | rpc.rquotad | quota | Random | 4003 | Install " | ||
- | + | ==== Establecer puertos fijos ==== | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ===== Establecer puertos fijos ===== | + | |
* **Fijar puerto de status:** | * **Fijar puerto de status:** | ||
Line 181: | Line 173: | ||
</ | </ | ||
- | ===== Ejemplo reglas iptables | + | |
+ | |||
+ | ==== Ejemplo reglas iptables ==== | ||
< | < | ||
Line 190: | Line 184: | ||
VM=" | VM=" | ||
KVM_VM_IP=" | KVM_VM_IP=" | ||
+ | KVM_LAN_IP=" | ||
NFS_PORTS=" | NFS_PORTS=" | ||
Line 203: | 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 | + | $IPTABLES -A INPUT -i $VIRT_IF -s $VM -d $KVM_VM_IP |
fi | fi | ||
done | done | ||
+ | # NFSD | ||
+ | $IPTABLES -A INPUT -i $VIRT_IF -s $VM -d $KVM_LAN_IP -p tcp --dport 2049 -j ACCEPT | ||
</ | </ | ||
+ | |||
+ | ===== 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/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: | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | # If you do not set values for the NEED_ options, they will be attempted | ||
+ | # autodetected; | ||
+ | # for the NEED_ options are " | ||
+ | |||
+ | # Do you want to start the statd daemon? It is not needed for NFSv4. | ||
+ | NEED_STATD= | ||
+ | |||
+ | # Options for rpc.statd. | ||
+ | # | ||
+ | # when you have a port-based firewall. To use a fixed port, set this | ||
+ | # this variable to a statd argument like: " | ||
+ | # For more information, | ||
+ | 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= | ||
+ | </ | ||
+ | |||
+ | **/ | ||
+ | |||
+ | < | ||
+ | [General] | ||
+ | |||
+ | Verbosity = 1 | ||
+ | Pipefs-Directory = / | ||
+ | domain = dev.local.legido.com | ||
+ | |||
+ | [Mapping] | ||
+ | |||
+ | Nobody-User = nobody | ||
+ | Nobody-Group = nogroup | ||
+ | </ | ||
+ | |||
+ | **IMPORTANTE**: | ||
+ | |||
+ | ==== Configuracion servidor ==== | ||
+ | |||
+ | 0. Realizar los pasos anteriores | ||
+ | |||
+ | 1. Configurar los siguientes archivos: | ||
+ | |||
+ | **/ | ||
+ | |||
+ | /srv cliente1.example.com/ | ||
+ | |||
+ | 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:/ | ||
+ | |||
+ | 3. Comprobar permisos: | ||
+ | |||
+ | ls -la /mnt/nfs | ||
+ | |||
+ | **NO** deberia pertenecer a nobody: | ||
+ | |||
+ | 4. Para montar definitivamente editar: | ||
+ | |||
+ | sudo vim /etc/fstab | ||
+ | |||
+ | Y anyadir la siguiente entrada: | ||
+ | |||
+ | | ||
+ | |||
+ | 5. Ahora lo puede montar cualquier usuario: | ||
+ | |||
+ | mount /mnt/nfs |
informatica/linux/nfs.1363086796.txt.gz · Last modified: 2015/04/13 20:19 (external edit)