Difference between revisions of "NFS: Konfigurasi Server"

From OnnoWiki
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
[[Network File System]] ([[NFS]]) merupakan salah satu layanan jaringan yang banyak digunakan. [[NFS]] memungkinkan client untuk menempelkan harddisk yang ada di jaringan.
 
[[Network File System]] ([[NFS]]) merupakan salah satu layanan jaringan yang banyak digunakan. [[NFS]] memungkinkan client untuk menempelkan harddisk yang ada di jaringan.
 
  
 
==Skenario==
 
==Skenario==
Line 13: Line 12:
  
 
  apt-get install nfs-common nfs-kernel-server
 
  apt-get install nfs-common nfs-kernel-server
 +
mkdir /etc/exports.d
  
 
Pastikan mesin kita mendukung [[NFS]] ketik
 
Pastikan mesin kita mendukung [[NFS]] ketik
  
  $ cat /proc/filesystems  
+
  $ cat /proc/filesystems | grep nfs
  
 +
keluar
 
  nodev nfs
 
  nodev nfs
 
  nodev nfs4
 
  nodev nfs4
Line 23: Line 24:
  
  
NFS file system supported
+
NFS daemon harusnya mendengerkan port 2049 dan portmap pada port 111.
 +
 
 +
more /etc/services | grep 111
 +
 
 +
keluar
 +
sunrpc 111/tcp portmapper # RPC 4.0 portmapper
 +
sunrpc 111/udp portmapper
  
NFS daemon should be listening on both standard ports 2049 and portmap on port 111.
+
more /etc/services | grep 2049
  
NFS daemon port 2049 portmap port 111
+
keluar
Another way to check if NFS is functioning, is to use the rpcinfo command.
+
nfs 2049/tcp # Network File System
 +
nfs 2049/udp # Network File System
  
# rpcinfo -p 
 
  
You should get a response/output similar to one below:
+
Cara lain untuk cek menggunakan
  
check if NFS is functioning
+
rpcinfo -p  | grep 111
 +
rpcinfo -p  | grep
  
4. Server export file
+
keluar
  
All NFS server exports need to be defined in /etc/exports file.
+
  program vers proto  port
4.1. Most common exports options
+
    100000    2  tcp    111  portmapper
 +
    100000    2  udp    111  portmapper
 +
    100024    1  udp  56835  status
 +
    100024    1  tcp  53408  status
 +
    100021    1  udp  50903  nlockmgr
 +
    100021    3  udp  50903  nlockmgr
 +
    100021    4   udp  50903  nlockmgr
 +
    100021    1   tcp  36404  nlockmgr
 +
    100021    3  tcp  36404  nlockmgr
 +
    100021    4  tcp  36404  nlockmgr
 +
    100003    2  udp  2049  nfs
 +
    100003    3  udp  2049  nfs
 +
    100003    4  udp  2049  nfs
 +
    100003    2  tcp  2049  nfs
 +
    100003    3  tcp  2049  nfs
 +
    100003    4  tcp  2049  nfs
  
Here are the most common export techniques and options:
+
==Server /etc/exports file==
/home/nfs/ 10.1.1.100(rw,sync) export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, and synchronized mode
 
/home/nfs/ 10.1.1.0/24(ro,sync) export /home/nfs directory for network 10.1.1.0 netmask 255.255.255.0 with read only permissions and synchronized mode
 
/home/nfs/ 10.1.1.100(rw,sync) 10.1.1.10(ro,sync) export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode, and also export /home/nfs directory for hosts with IP 10.1.1.10 with read only permissions and synchronized mode
 
/home/nfs/ 10.1.1.100(rw,sync,no_root_squash) export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.
 
/home/nfs/ *(ro,sync) export /home/nfs directory for any host with a read only permission and synchronized mode
 
/home/nfs/ *.linuxconfig.org(ro,sync) export /home/nfs directory for any host within linuxconfig.org domain with a read only permission and synchronized mode
 
/home/nfs/ foobar(rw,sync) export /home/nfs directory for hostname foobar with read, write permissions and synchronized mode
 
4.2. Edit exports file
 
  
Open up your favorite text editor, for example, vim and edit /etc/exports file and add line /home/nfs/ *(ro,sync) to export /home/nfs directory for any host with read only permissions. edit NFS exports file
 
  
Be sure that the directory you export by NFS exists. You can also create a file inside the /home/nfs directory which will help you troubleshoot once you mount this file system remotely.
+
Kita perlu mendefinisikan folder yang ingin di share
  
  # touch /home/nfs/test_file
+
  vi /etc/exports
  
4.3. Restart NFS daemon
+
misalnya
  
Once you edit /etc/exports file you need to restart NFS daemon to apply changes in the /etc/exports file. Depending on your Linux distribution, the restarting of NFS may differ. Debian users:
+
/home/nfs/ 10.1.1.100(rw,sync)  - /home/nfs utk IP 10.1.1.100 read, write permissions & synchronized mode
 +
/home/nfs/ 10.1.1.0/24(ro,sync) - /home/nfs utk IP 10.1.1.0 netmask 255.255.255.0 read only permissions and synchronized mode
 +
/home/nfs/ 10.1.1.100(rw,sync) 10.1.1.10(ro,sync) export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode, and also export /home/nfs directory for hosts with IP 10.1.1.10 with read only permissions and synchronized mode
 +
/home/nfs/ 10.1.1.100(rw,sync,no_root_squash) export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.
 +
/home/nfs/ *(ro,sync) export /home/nfs directory for any host with a read only permission and synchronized mode
 +
/home/nfs/ *.linuxconfig.org(ro,sync) export /home/nfs directory for any host within linuxconfig.org domain with a read only permission and synchronized mode
 +
/home/nfs/ foobar(rw,sync) export /home/nfs directory for hostname foobar with read, write permissions and synchronized mode
  
  # /etc/init.d/nfs-kernel-server restart  
+
contoh
 +
 
 +
/home/backup *(ro,sync,subtree_check)
 +
/home/backup/public *(rw,sync,subtree_check)
 +
/home/library *(ro,sync,subtree_check)
 +
/home/media *(ro,sync,subtree_check)
 +
 
 +
'''Yang baik:'''
 +
 
 +
/mnt/media *(ro,fsid=0,crossmnt,no_subtree_check,insecure)
 +
 
 +
==Restart NFS daemon==
 +
 
 +
Setelah /etc/exports file di edit, kita dapat me-restart NFS daemon.
 +
 
 +
  /etc/init.d/nfs-kernel-server restart  
  
 
Redhat users
 
Redhat users
  
  # /etc/init.d/nfs restart  
+
  /etc/init.d/nfs restart  
 +
 
 +
Jika ingin menambahkan NFS /etc/exports file, kita perlu mengedit & merestart kembali, atau menggunakan perintah
 +
 
 +
exportfs -ra
  
If you later decide to add more NFS exports to the /etc/exports file, you will need to either restart NFS daemon or run command exportfs:
 
  
# exportfs -ra
+
==Service Start==
 +
 
 +
  sudo systemctl start nfs-kernel-server.service
  
 
==Referensi==
 
==Referensi==
  
 
* http://www.linuxconfig.org/HowTo_configure_NFS
 
* http://www.linuxconfig.org/HowTo_configure_NFS
 
  
 
==Pranala Menarik==
 
==Pranala Menarik==

Latest revision as of 17:04, 24 January 2019

Pendahuluan

Network File System (NFS) merupakan salah satu layanan jaringan yang banyak digunakan. NFS memungkinkan client untuk menempelkan harddisk yang ada di jaringan.

Skenario

Dalam skenario ini kita akan menempelkan harddisk yang ada di linuxconfig.org (IP address 10.1.1.200) ke client IP address 10.1.1.100).

Persyaratan

Install NFS

apt-get install nfs-common nfs-kernel-server
mkdir /etc/exports.d

Pastikan mesin kita mendukung NFS ketik

$ cat /proc/filesystems | grep nfs

keluar

nodev	nfs
nodev	nfs4
nodev	nfsd


NFS daemon harusnya mendengerkan port 2049 dan portmap pada port 111.

more /etc/services | grep 111

keluar

sunrpc		111/tcp		portmapper	# RPC 4.0 portmapper
sunrpc		111/udp		portmapper
more /etc/services | grep 2049

keluar

nfs		2049/tcp			# Network File System
nfs		2049/udp			# Network File System


Cara lain untuk cek menggunakan

rpcinfo -p  | grep 111
rpcinfo -p  | grep 

keluar

  program vers proto   port
   100000    2   tcp    111  portmapper
   100000    2   udp    111  portmapper
   100024    1   udp  56835  status
   100024    1   tcp  53408  status
   100021    1   udp  50903  nlockmgr
   100021    3   udp  50903  nlockmgr
   100021    4   udp  50903  nlockmgr
   100021    1   tcp  36404  nlockmgr
   100021    3   tcp  36404  nlockmgr
   100021    4   tcp  36404  nlockmgr
   100003    2   udp   2049  nfs
   100003    3   udp   2049  nfs
   100003    4   udp   2049  nfs
   100003    2   tcp   2049  nfs
   100003    3   tcp   2049  nfs
   100003    4   tcp   2049  nfs

Server /etc/exports file

Kita perlu mendefinisikan folder yang ingin di share

vi /etc/exports

misalnya

/home/nfs/ 10.1.1.100(rw,sync)  - /home/nfs utk IP 10.1.1.100 read, write permissions & synchronized mode
/home/nfs/ 10.1.1.0/24(ro,sync) - /home/nfs utk IP 10.1.1.0 netmask 255.255.255.0 read only permissions and synchronized mode
/home/nfs/ 10.1.1.100(rw,sync) 10.1.1.10(ro,sync) 	export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode, and also export /home/nfs directory for hosts with IP 10.1.1.10 with read only permissions and synchronized mode
/home/nfs/ 10.1.1.100(rw,sync,no_root_squash) 	export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.
/home/nfs/ *(ro,sync) 	export /home/nfs directory for any host with a read only permission and synchronized mode
/home/nfs/ *.linuxconfig.org(ro,sync) 	export /home/nfs directory for any host within linuxconfig.org domain with a read only permission and synchronized mode
/home/nfs/ foobar(rw,sync) 	export /home/nfs directory for hostname foobar with read, write permissions and synchronized mode

contoh

/home/backup *(ro,sync,subtree_check)
/home/backup/public *(rw,sync,subtree_check)
/home/library *(ro,sync,subtree_check)
/home/media *(ro,sync,subtree_check)

Yang baik:

/mnt/media *(ro,fsid=0,crossmnt,no_subtree_check,insecure)

Restart NFS daemon

Setelah /etc/exports file di edit, kita dapat me-restart NFS daemon.

/etc/init.d/nfs-kernel-server restart 

Redhat users

/etc/init.d/nfs restart 

Jika ingin menambahkan NFS /etc/exports file, kita perlu mengedit & merestart kembali, atau menggunakan perintah

exportfs -ra


Service Start

 sudo systemctl start nfs-kernel-server.service

Referensi

Pranala Menarik