NFS Server Installation and Use

Source: Internet
Author: User

Chapter 1 Introduction to software for installing and using NFS servers 1. What is NFS? NFS is short for Network File System, that is, Network File System. An agreement for the use of distributed file systems, developed by Sun, was published on April 9, 1984. The function is to allow different machines and operating systems to share individual data with each other through the network, so that applications can access data on server disks through the network on the client, it is a way to share disk files between Unix-like systems. 2. What is the difference between Samba and NFS? Samba was developed by DEC and used for resource sharing between different Unix machines. It adopts the udp protocol. Later, after re-development based on tcp, the efficiency was greatly improved. The protocol used is SMB. Microsoft is reluctant to pay the License fee and implements the protocol again in windows. Since both samba and windows use the SMB protocol. Samba is mainly used to share resources between windows and unix. Resources include files and printers. With samba, windows machines can use the shared resources of linux Hosts in their network neighbors like those of windows machines. NFS is developed by SUN for sharing resources between UNIX machines. It is quite easy to set, mainly to configure the/etc/exports file, and then run exportfs-a to share it. Now NFS has become a standard for UNIX/LINUX. Nfs efficiency is slightly higher, but the difference is not too big. Chapter 2 System Environment System Platform: CentOS release 5.2 NFS Server IP: 192.168.1.138 Firewall disabled (Firewall is not running) SELINUX = disabled Chapter 3 NFS service installation NFS is very simple, you only need two software packages, which are usually installed as the default package of the system. If not installed, the installation process is not cumbersome here. L nfs-utils-*: includes basic NFS commands and monitoring programs l portmap-*: supports connections to secure nfs rpc services to check whether NFS is installed: [root @ localhost ~] # Rpm-qa | grep nfs Chapter 4 NFS service configuration step 1 create an update folder [root @ localhostusr] # mkdir/usr/update step 2 modify the/etc/exports file (note: 192.168.1.121 is the client address) file content:/usr/update192.168.1.121 (rw, sync, no_root_squash) step 3 enable the service [root @ localhostusr] # service portmap start [root @ localhostusr] # service nfs start Step 4. mount the shared directory on the NFS server [root @ localhostusr] # mount 192.168.1.138: /usr/update // usr/update/indicates that the configuration is successful. You can check whether your folder is mounted and synchronized. The following steps are used in the actual project. If you only try to use NFS, you can ignore it. Step 5 set the Automatic startup status of the NFS server [root @ localhostusr] # chkconfig -- list portmap [root @ localhostusr] # chkconfig -- list nfs [root @ localhostusr] # chkconfig -- level 35 portmap on [root @ localhostusr] # chkconfig -- level 35 nfs on Step 6 the client starts automatic mounting of the nfs file system to open the/etc/fstab file [root @ localhostusr] # vi/etc/fstab add content: 192.168.1.138:/usr/update nfs defaults 0 0 note: the configuration of the NFS server is relatively simple. You only need to set it in the corresponding configuration file, then start the NFS server. The NFS service configuration file is/etc/exports. This file is the main NFS configuration file, but the system does not have the default value. Therefore, this file may not exist and may need to be manually created using vim, then write the configuration content in the file. Chapter 5 NFS service commands 1. start the NFS server # service portmap start # service nfs start Note: To enable the NFS server to work normally, you need to start the portmap and nfs services, portmap must be started before nfs. 2. query the NFS server status # service portmap status # service nfs status 3. stop the NFS server # service nfs stop # service portmap stop Note: To stop running NFS, you need to stop the nfs service before stopping the portmap service. If other services (such as NIS) in the system need to be used, you do not need to stop the portmap service. 4. restart the NFS server # service nfs restart # service portmap restart 5. Set the Automatic startup status of the NFS server # chkconfig -- list portmap # chkconfig -- list nfs # chkconfig -- level 35 portmap on # chkconfig -- level 35 nfs on note: for the actual application system, it is unrealistic to manually start the nfs server after each LINUX system is started. You need to set the system to automatically start the portmap and nfs services at the specified running level. Set portmap and nfs service to automatically start at system running level 3 and 5. 6. query the NFS sharing status # showmount-e // by default, view the shared service # showmount-a // display the directory information that has been connected to the client. 7. Mount the NFS server on the client. format: # mount NFS server IP Address: shared directory local mount point directory case: # mount 192.168.1.138:/usr/update/8. Format of uninstalling NFS server on the client: # umount device | directory case: # umount/usr/update 9. view the complete permission settings # cat/var/lib/nfs/etab 10. Format of starting an automatic mounting nfs file system: <server>: </remote/export> </local/directory> nfs <options> 0 0 case: open the file # vi/etc/fstab and add content 192.168.1.138: /usr/update/us R/update nfs defaults 0 0 Note: configure the format of 11 and exportfs on the client: # exportfs [-aruv]-a mount or detach all content in/etc/exports-r re-read the information in/etc/exports, and synchronously update/etc/exports,/var/lib/nfs/xtab-u to detach a single directory (used with-a to detach all directories in the/etc/exports file) -v outputs detailed information to the screen during the export operation. Case: # exportfs-au unmount all shared directories # exportfs-rv re-share all directories and output details Note: If/etc/exports is modified after NFS is started, is it necessary to restart nfs? At this time, we can use the exportfs command to make the change take effect immediately. Chapter 6 Appendix 1. Common NFS directories/etc/exports NFS service configuration file/usr/sbin/exportfs NFS service management command/usr/sbin/showmount client view command /var/lib/nfs/etab record the full permission setting value of the directories shared by NFS/var/lib/nfs/xtab record the client information that has been logged on 2./etc/exports file Content format <output directory> [client 1 option (access permission, user ing, others)] [client 2 options (access permission, user ing, others)] (1) output directory l concept: the output directory refers to the directory that needs to be shared to the client in the NFS System (2) client l concept: the client is a computer that can access the NFS output directory in the network. The client usually specifies the host with the IP Address: 192.168.0.200 all hosts in the specified subnet: 192.168.0.0/24192.168.0.0/ 255.255.255.0 all hosts in the specified domain name: David .bsmart.cn all hosts in the specified domain: * .bsmart.cn: * (3) option l concept: This option is used to set access permissions and user ing for the output directory. L NFS mainly has three options: access permission option setting output directory read-only: ro setting output directory read/write: rw Ø user ing option all_squash: maps all common users and groups for remote access to an anonymous user or user group (nfsnobody) no_all_squash: returns the inverse (default setting) of root_squash with all_squash: map root users and groups to anonymous users or user groups (default setting) no_root_squash: And rootsquash to anti-anonuid = xxx: map all users remotely to anonymous users, specify the user as a local user (UID = xxx) anongid = xxx: maps all user groups remotely accessed to anonymous user group accounts, specify the anonymous user group account as the local user group account (GID = xxx). Other options secure: restrict the client to connect to the nfs server from the TCP/IP Port less than 1024 (default) insecure: allow the client to connect to server sync from a tcp/ip port greater than 1024: write data synchronously to the memory buffer and disk, which is less efficient, but can ensure data consistency async: store data in the memory buffer before writing data to the disk wdelay if necessary: Check whether there are related write operations. If yes, execute these write operations together, which improves the efficiency (default setting) no_wdelay: if there is a write operation, it will be executed immediately. Use subtree with sync: If the output directory is a sub-directory, the nfs server will check the permission of its parent directory (default setting) no_subtree: even if the output directory is a sub-directory, the nfs server does not check the permissions of its parent directory, which improves the efficiency.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.