1. Scenario
An organization needs to configure an NFS server to provide backup storage for another Linux server running the Oracle database.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/BF/wKiom1QaL2PDqpfpAAIkUQ9L6_k075.jpg "Title =" 1.jpg" alt = "wkiom1qal2pdqpfpaaikuq9l6_k075.jpg"/>
Host Name |
IP address |
Nfs1.abc. Local |
192.168.188.11 |
Db1.abc. Local |
192.168.188.13 |
2. experiment environment
[[email protected] ~]# cat /etc/redhat-releaseRed Hat Enterprise Linux Server release 6.4 (Santiago)[[email protected] ~]# uname -aLinux localhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux
3. NFS Server installation and configuration
3.1 install NFS Server Components
[[email protected] ~]# mount /dev/cdrom /mnt/cdrommount: block device /dev/sr0 is write-protected, mounting read-only[[email protected] ~]# cd /mnt/cdrom/Packages/[[email protected] Packages]# ls *nfs*nfs4-acl-tools-0.3.3-6.el6.x86_64.rpm sblim-cmpi-nfsv3-1.1.1-1.el6.i686.rpmnfs-utils-1.2.3-36.el6.x86_64.rpm sblim-cmpi-nfsv3-1.1.1-1.el6.x86_64.rpmnfs-utils-lib-1.1.5-6.el6.i686.rpm sblim-cmpi-nfsv4-1.1.0-1.el6.i686.rpmnfs-utils-lib-1.1.5-6.el6.x86_64.rpm sblim-cmpi-nfsv4-1.1.0-1.el6.x86_64.rpm[[email protected] Packages]# rpm -Uvh nfs-utils-1.2.3-36.el6.x86_64.rpm libevent-1.4.13-4.el6.x86_64.rpm keyutils-1.4-4.el6.x86_64.rpm rpcbind-0.2.0-11.el6.x86_64.rpm libgssglue-0.1-11.el6.x86_64.rpm nfs-utils-lib-1.1.5-6.el6.x86_64.rpm libtirpc-0.2.1-5.el6.x86_64.rpmwarning: nfs-utils-1.2.3-36.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEYPreparing... ########################################### [100%] 1:libgssglue ########################################### [ 14%] 2:libtirpc ########################################### [ 29%] 3:rpcbind ########################################### [ 43%] 4:keyutils ########################################### [ 57%] 5:libevent ########################################### [ 71%] 6:nfs-utils-lib ########################################### [ 86%] 7:nfs-utils ########################################### [100%]
3.2 start the NFS service
NFS depends on the rpcbind service and is set to automatic start.
[[email protected] Packages]# chkconfig rpcbind on
The NFS function is failed because NFS depends on the rpcbind service. You must first start the rpcbind service to start NFS.
[[email protected] Packages]# service nfs startStarting NFS services: [ OK ]Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refusedrpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp). [FAILED]Starting NFS mountd: [FAILED]Starting NFS daemon: rpc.nfsd: writing fd to kernel failed: errno 111 (Connection refused)rpc.nfsd: unable to set any sockets for nfsd [FAILED]
Start the rpcbind service first:
[[email protected] Packages]# service rpcbind startStarting rpcbind: [ OK ]
Start the NFS service again:
[[email protected] Packages]# service nfs startStarting NFS services: [ OK ]Starting NFS quotas: [ OK ]Starting NFS mountd: [ OK ]Starting NFS daemon: [ OK ]
Set NFS to auto start
[[email protected] Packages]# chkconfig nfs on
3.3 configure the NFS server
View shared NFS Information
[[email protected] Packages]# showmount -e localhostExport list for localhost:[[email protected] Packages]# mkdir /nfsdata[[email protected] Packages]# ll -ld /nfsdata/drwxr-xr-x 2 root root 4096 Sep 11 05:03 /nfsdata/
Add write permission for directory/nfsdata
[[email protected] Packages]# chmod a+w /nfsdata/[[email protected] Packages]# ll -ld /nfsdata/drwxrwxrwx 2 root root 4096 Sep 11 05:03 /nfsdata/
Configure the Export File
[[email protected] Packages]# vi /etc/exports/nfsdata * (rw,root_squash,no_all_squash,sync)
Restart the NFS service
[[email protected] Packages]# service nfs restartShutting down NFS daemon: [ OK ]Shutting down NFS mountd: [ OK ]Shutting down NFS quotas: [ OK ]Shutting down NFS services: [ OK ]Starting NFS services: exportfs: No options for /nfsdata *: suggest *(sync) to avoid warningexportfs: No host name given with /nfsdata (rw,root_squash,no_all_squash,sync), suggest *(rw,root_squash,no_all_squash,sync) to avoid warningexportfs: incompatible duplicated export entries:exportfs: *:/nfsdata (0x424) [IGNORED]exportfs: *:/nfsdata (0x425) [ OK ]Starting NFS quotas: [ OK ]Starting NFS mountd: [ OK ]Starting NFS daemon: [ OK ][[email protected] Packages]# showmount -e localhostExport list for localhost:/nfsdata *
Connect yourself and Test
[[email protected] Packages]# mkdir /mnt/nfs[[email protected] Packages]# mount 127.0.0.1:/nfsdata /mnt/nfs[[email protected] Packages]# mount/dev/mapper/VolGroup-lv_root on / type ext4 (rw)proc on /proc type proc (rw)sysfs on /sys type sysfs (rw)devpts on /dev/pts type devpts (rw,gid=5,mode=620)tmpfs on /dev/shm type tmpfs (rw)/dev/sda1 on /boot type ext4 (rw)/dev/sdb1 on /test_qu type ext4 (rw,usrquota)none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)/dev/sr0 on /mnt/cdrom type iso9660 (ro)sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)nfsd on /proc/fs/nfsd type nfsd (rw)127.0.0.1:/nfsdata on /mnt/nfs type nfs (rw,vers=4,addr=127.0.0.1,clientaddr=127.0.0.1)
Check whether the directory can be written
[[email protected] ~]# touch /mnt/nfs/testfile1.txt[[email protected] ~]# ll /mnt/nfs/testfile1.txt-rw-r--r-- 1 nfsnobody nfsnobody 0 Sep 18 01:41 /mnt/nfs/testfile1.txt
3.4 configure an NFS client
The NFS client also needs to install the nfs-utils package.
[[email protected] ~]# showmount -e 192.168.188.11Export list for 192.168.188.11:/nfsdata *[[email protected] ~]# mkdir /mnt/nfs[[email protected] ~]# mount 192.168.188.11:/nfsdata /mnt/nfs[[email protected] ~]# ls /mnt/nfs -ltotal 0-rw-r--r-- 1 nfsnobody nfsnobody 0 Sep 18 01:41 testfile1.txt[[email protected] ~]# echo test >> /mnt/nfs/testfile1.txt[[email protected] ~]# ls /mnt/nfs/testfile1.txt -l-rw-r--r-- 1 nfsnobody nfsnobody 5 Sep 18 02:01 /mnt/nfs/testfile1.txt
4. Summary
For NFS, both the server and client need to install the nfs-utils package.
Showmount-e + host display the shared directory in the current host/etc/exports
Exportfs-r re-mount the settings in/etc/exports
Build NFS servers and clients