Tutorial 01: NFS Sharing Service
. Lab Objectives
Rhel5.9 _ A: 192.168.10.253/24
Rhel5.9 _ B: 192.168.10.200/24
1. Share/root with 192.168.10.200, which can be written or synchronized, and allow the client to access it as root
2. Share/usr/src to the 192.168.10.200/24 CIDR Block, writable and asynchronous
3. Based on the previous experiment, all user identities on the client are mapped to nfsnobody.
4. automatically mount the/root directory shared by the NFS server to the local/data/root directory at the client startup.
Mount the/usr/src directory shared by the NFS server to the local/data/src directory on the client.
. Experiment steps
1. writable. Synchronization
(1) NTFS server operations
1. Prepare the software package and directory.
[[Email protected] ~] # Rpm-Q nfs-utils Portmap
Nfs-utils-1.0.9-66.el5
Portmap-4.0-65.2.2.1
[[Email protected] ~] # Mkdir/Ptest // create a shared test directory
[[Email protected] ~] # Echo "Welcome to NFS Station">/Ptest/nfs.txt
// Create a test file
[[Email protected] ~] # Ls-LD/Ptest // check the default directory permissions
Drwxr-XR-x 2 root Root 4096 09-12/Ptest/
2. Configure/etc/exports shared files and modify permissions
[[Email protected] ~] # Vim/etc/exports
/Boot 192.168.10.200 (RW, sync, no_root_squash)
3. Start the Portmap service
[[Email protected] ~] # Service Portmap restart
Stop Portmap: [OK]
Start Portmap: [OK]
[[Email protected] ~] # Chkconfig Portmap on // set Portmap to start automatically
4. Start the NFS service
[[Email protected] ~] # Service NFS restart // Ensure NFS is enabled
Disable NFS mountd: [failed]
Disable NFS mountd: [OK]
Disable the NFS daemon: [OK]
Disable NFS quotas: [OK]
Disable NFS: [OK]
Start the NFS service: [OK]
Disable NFS quota: [OK]
Start the NFS daemon: [OK]
Start NFS mountd: [OK]
Stopping RPC idmapd: [OK]
Starting RPC idmapd: [OK]
[[Email protected] ~] # Chkconfig Portmap on // set Portmap to start automatically
[[Email protected] ~] # Chkconfig NFS on // sets NFS auto-start
[[Email protected] ~] # Service Portmap restart
[[Email protected] ~] # Chkconfig network on // set Portmap to start automatically
(2) NFS client operations
1. Start Portmap
[[Email protected] ~] # Service Portmap restart
Stop Portmap: [OK]
Start Portmap: [OK]
2. view the NFS shared resource list of the server
[[Email protected] ~] # Showmount-e 192.168.10.253
Export list for 192.168.10.253:
/Boot 192.168.10.200
3. Check the NFS service status of the target server
[[Email protected] ~] # Rpcinfo-P 192.168.10.200 // program version protocol port
100000 2 TCP 111 Portmapper
100000 2 UDP 111 Portmapper
100024 1 udp 635 status
100024 1 tcp 638 status
4. Mount the shared file from the client 192.168.10.200 to/boot
[[Email protected] ~] # Mkdir-P/data/root // create a file
[[Email protected] ~] # Mount 192.168.10.253:/boot // data/root/
[[Email protected] ~] # DF-HT // check the mounting result
File System Type capacity available in use % mount point
/Dev/sda2 ext3 19 GB 11g 7.2g 61%/
/Dev/sda1 ext3 99 m 12 m 82 m 13%/boot
Tmpfs 500 M 0 500 m 0%/dev/SHM
/Dev/HDC iso9660 4.1g 4.1g 0 100%/Media/rhel_5.9 x86_64 DVD
192.168.10.253:/boot/
NFS 99 m 12 Mb 82 m 13%/data/root
5. Test read/write permissions
[[Email protected] root] # Touch file.txt
[[Email protected] root] # ls-l file.txt
-RW-r -- 1 Root 0 09-13 23:54 file.txt
Ii. writable. asynchronous
(1) server operations
1. Configure/etc/exports shared files and modify permissions
[[Email protected] ~] # Vim/etc/exports
/Boot 192.168.10.200 (RW, sync, no_root_squash)
/Usr/src 192.168.10.0/24 (RW, async)
2. Output shared files
[[Email protected] ~] # Exportfs-RV
Exporting 192.168.10.0/24:/usr/src
Exporting 192.168.10.200:/boot
3. All client permissions are downgraded to nfsnobody.
[[Email protected] ~] # Setfacl-m u: nfsnobody: rwx/usr/src/
(2) client operations
1. view the NFS shared resource list of the server
[[Email protected] ~] # Mkdir/data/src/
[[Email protected] ~] # Showmount-e 192.168.10.253
Export list for 192.168.10.253:
/Boot 192.168.10.200
/Usr/src 192.168.10.0/24
2. Mount shared files from the client
[[Email protected] ~] # Mount 192.168.10.253:/usr/src // data/src/
3. Test read/write permissions
[[Email protected] ~] # Cd/data/src/
[[Email protected] SRC] # Touch filel.txt
[[Email protected] SRC] # ls-l filel.txt
-RW-r -- 1 nfsnobody 0 09-14 00:36 filel.txt
Iii. ing
(1) Client Configuration
1. Add folder Permissions
[[Email protected] ~] # Chmod o + w/usr/src/
2. Modify the NFS master configuration file
[[Email protected] ~] # Vim/etc/exports
/Boot 192.168.10.200 (RW, sync, no_root_squash)
/Usr/src 192.168.10.0/24 (RW, async, all_squash)
3. View
[[Email protected] ~] # Exportfs-RV
Exporting 192.168.10.0/24:/usr/src
Exporting 192.168.10.200:/boot
(2) NFS client operations
1. check folder Permissions
[[Email protected] ~] # Useradd Tom
[[Email protected] ~] # Su-Tom
[[Email protected] ~] $ CD/data/src/
[[Email protected] SRC] $ touch toml.txt
[[Email protected] SRC] $ LS-l toml.txt
-RW-r -- 1 Tom 0 09-14 toml.txt
2. Test read/write permissions
[[Email protected] SRC] $ touch tom2.txt
[[Email protected] SRC] $ LS-l tom2.txt
-RW-r -- 1 nfsnobody 0 09-14 00:56 tom2.txt
4. automatic mounting and trigger mounting at startup
(1) automatically mount nfs shared resources on the client
1. Add NFS mounting settings
[[Email protected] ~] # Vim/etc/fstab
192.168.10.253:/root/data/root NFS ults, _ netdev 0 0
2. view the mounting result
[[Email protected] ~] # Grep/data/root/etc/fstab
192.168.10.253:/root/data/root NFS ults, _ netdev 0 0
3. automatically mount the main directory
[[Email protected] ~] # Vim/etc/auto. Master
/Mnt/etc/auto. Data
[[Email protected] ~] # Grep MNT/etc/auto. Master
/Mnt/etc/auto. Data
4. Start the service
[[Email protected] ~] # Service autofs restart
Start automount: [OK]
[[Email protected] ~] # Chkconfig autofs on
(2) triggering mounting NFS shared resources on the client
1. Add automatic mounting NFS settings
[[Email protected] ~] # Vim/etc/auto. Data
Src-fstype = NFS, RW 192.168.10.253:/usr/src
[[Email protected] ~] # Cat/etc/auto. Data
Src-fstype = NFS, RW 192.168.10.253:/usr/src
2. Start the service
[[Email protected] ~] # Service autofs restart
Start automount: [OK]
[[Email protected] ~] # Chkconfig autofs on
. Problem and Experience Summary
Fault description: Mount fails, and the target host cannot be reached
[[Email protected] ~] # Mount 192.168.10.253:/root/data/root/
Mount: 192.168.10.253:/root/failed, reason given by server:
Permission denied
Solution: Directory error/root/-/boot/
[[Email protected] ~] # Mount 192.168.10.253:/boot // data/root/
Mount: 192.168.10.253:/root/failed, reason given by server: Permission denied
Solution: Directory Permissions
[[Email protected] ~] # Chmod 755/boot
This article is from the "9255610" blog, please be sure to keep this source http://9265610.blog.51cto.com/9255610/1552668
NFS Sharing Service