File Server NFS configuration details

Source: Internet
Author: User
NFS configuration of file servers: a file server and multiple web servers are deployed in Linux. the directory provided by the file server is accessed and written by the web server at the same time, apache can be used, and tomcat can be used on web servers ,... NFS configuration of file servers: a file server and multiple web servers are deployed in Linux. the directory provided by the file server is accessed and written by the web server at the same time, apache and tomcat can be used for web servers, and NFS network file system sharing is used. The specific operation process should be written in red (^_^. Environment: IP host name purpose: 192.168.56.151 rhel151 file server 192.168.56.152 rhel152 web server 0. First of all, deploy the configuration file server. Check whether related software packages are installed: [root @ rhel151 ~] # Rpm-qa | grep nfssystem-config-nfs-1.3.23-2.el5nfs-utils-1.0.9-66.el5nfs-utils-lib-1.0.8-7.9.el5 the above three are the NFS system software package. Next, create a directory for shared access/opt/nfsshare: [root @ rhel151 ~] # Mkdir-p/opt/nfsshare then write the shared directory information and shared open permissions to the configuration file: [root @ rhel151 ~] # Echo "/opt/nfsshare 192.168.56. * (rw, no_root_squash)">/etc/exports [root @ rhel151 ~] # Cat/etc/exports/opt/nfsshare 192.168.56. * (rw, no_root_squash) the above configuration indicates that the shared directory is/opt/nfsshare and can be accessed by hosts in the 192.168.56 network segment. The permission is read/write (rw ), corresponding to the root user permission settings (no_root_squash). For detailed parameter descriptions, refer to the NFS Manual. here, the most common parameters are configured and enough. Next, restart NFS-related services on the file server: [root @ rhel151 ~] # Service portmap restart stop portmap: [OK] start portmap: [OK] [root @ rhel151 ~] # Service nfs restart disable NFS mountd: [failed] disable NFS daemon: [failed] disable NFS quotas: [failed] start NFS service: [OK] disable NFS quota: [OK] start the NFS daemon: [OK] start NFS mountd: [OK] Stopping RPC idmapd: [OK] starting RPC idmapd: [OK] set the relevant services to automatically start when starting: [root @ rhel151 ~] # Chkconfig portmap on [root @ rhel151 ~] # Chkconfig nfs on 1. to configure client access to the client, you must also start the relevant access service: [root @ rhel152 ~] # Service portmap restart stop portmap: [OK] start portmap: [OK] set automatic start of access service process startup: [root @ rhel152 ~] # Chkconfig portmap on creates a directory that has the permission to mount the shared directory of the file server to a local directory/opt/nfsshare. you can also choose not to use this directory, this directory path does not need to be consistent with the file server: [root @ rhel152 ~] # Mkdir-p/opt/nfsshare use the mount command to specify the directory/opt/nfsshare for mounting the nfs file server to the local/opt/nfsshare Directory: [root @ rhel152 ~] # Mount-t nfs 192.168.56.151:/opt/nfsshare/opt/nfs0000mount: 192.168.56.151:/opt/nfsshare failed, reason given by server: Permission denied oh ~~ An error is reported because the file server rhel151 has configured the host name and IP address ing. you need to comment out the ING of the corresponding client: [root @ rhel151 ~] # Cat/etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail.127.0.0.1 rhel151 localhost. localdomain localhost: 1 localhost6.localdomain6 localhost6192.168.56.1 m192.168.56.151 rhel151 #192.168.56.152 255.255.255.gpm192.168.56.163 gpms192.168.56.165 255.gps2 as above, the corresponding client rhel152 Comment out: #192.168.56.152 rhel152. Remember, this operation is performed on the rhel151 file server. Return to the rhel152 client to continue the operation: [root @ rhel152 ~] # Mount-t nfs rhel151:/opt/nfsshare. check the mounting result: [root @ rhel152 ~]. # Mount/dev/mapper/VolGroup00-LogVol00 on/type ext3 (rw) proc on/proc type proc (rw) sysfs on/sys type sysfs (rw) devpts on/dev/pts type devpts (rw, gid = 5, mode = 620)/dev/sda1 on/boot type ext3 (rw) tmpfs on/dev/shm type tmpfs (rw) none on/proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)/dev/sdb1 on/oradata type ext3 (rw) rhel151:/opt/nfsshare on/ Opt/nfsshare type nfs (rw, addr = 192.168.56.151) is good. The last line is the result we want. you can view the result through the df command: [root @ rhel152 ~] # Df-H file system capacity available in use % mount point/dev/mapper/VolGroup00-LogVol00 14G 5.2G 7.8G 41%/dev/sda1 99 M 13 M 82 M 14%/boottmpfs 1006 M 0 1006 M 0%/dev/shm/dev/sdb1 99G 2.0G 92G 3%/oradatarhel151: /opt/nfsshare 14G 7.6G 5.5G 59%/opt/nfsshare and write a file in rhel152: [root @ rhel152 ~] # Cd/opt/nfsshare/[root @ rhel152 nfsshare] # touch 111 [root @ rhel152 nfsshare] # echo 'asdfasdf '> 111 [root @ rhel152 nfsshare] # cat 111asdfasdf has been written file 1111, return to the rhel151 server to see if any results have been found: [root @ rhel151 ~] # Cat/opt/nfsshare/111 asdfasdfok, everything is normal. Finally, if you still have a lot of servers to access, you just need to repeat the above rhel152 operations. The file server provides a centralized access directory, because we are unlikely to provide a large storage space on each web server. The most important reason is that data synchronization is very troublesome, now, the server-client method can ensure that data reading is only stored in one place, so that data synchronization is not required and the single point of failure of the web server is avoided. -EOF-
Related Article

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.