服務端配置:php
[root@gary-tao ~]# vim /etc/exports 增長一行配置以下: /tmp/ 172.16.111.0/24(rw,sync,no_root_squash) [root@gary-tao ~]# exportfs -arv //不用重啓nfs服務,配置文件就會生效 exporting 172.16.111.0/24:/tmp exporting 172.16.111.0/24:/home/nfstestdir
客戶端測試:mysql
[root@gary ~]# !showm showmount -e 172.16.111.100 Export list for 172.16.111.100: /tmp 172.16.111.0/24 /home/nfstestdir 172.16.111.0/24
//客戶端操做 [root@gary ~]# mount -t nfs 172.16.111.100:/tmp/ /mnt/ [root@gary ~]# df -h 文件系統 容量 已用 可用 已用% 掛載點 /dev/sda3 18G 1.1G 17G 7% / devtmpfs 479M 0 479M 0% /dev tmpfs 489M 0 489M 0% /dev/shm tmpfs 489M 19M 470M 4% /run tmpfs 489M 0 489M 0% /sys/fs/cgroup /dev/sda1 197M 109M 88M 56% /boot tmpfs 98M 0 98M 0% /run/user/0 172.16.111.100:/tmp 18G 6.9G 11G 39% /mnt [root@gary ~]# ls /mnt/ aming.sock php-fcgi.sock test.com.log-20180108 mysql_all.sql systemd-private-55f859a1063045b7a4c022e444d06732-vmtoolsd.service-FjZRDv test.com.log-20180109 mysql.sock test.com.log-20180106 user.sql mysql.sql test.com.log-20180107 [root@gary ~]# vi /mnt/123.txt [root@gary ~]# ls -l /mnt/123.txt -rw-r--r--. 1 root root 19 1月 16 15:00 /mnt/123.txt [root@gary ~]# ls -l /mnt/ //客戶端查看 總用量 1324 -rw-r--r--. 1 root root 19 1月 16 15:00 123.txt srw-rw-rw-. 1 root root 0 1月 12 09:55 aming.sock -rw-r--r--. 1 root root 1304811 1月 15 19:27 mysql_all.sql srwxrwxrwx. 1 xietao xietao 0 1月 12 15:02 mysql.sock -rw-r--r--. 1 root root 30806 1月 15 19:31 mysql.sql srw-rw-rw-. 1 root root 0 1月 12 09:55 php-fcgi.sock drwx------. 3 root root 17 1月 12 09:55 systemd-private-55f859a1063045b7a4c022e444d06732-vmtoolsd.service-FjZRDv -rw-r--r--. 1 root root 0 1月 6 00:00 test.com.log-20180106 -rw-r--r--. 1 root root 0 1月 7 00:00 test.com.log-20180107 -rw-r--r--. 1 root root 0 1月 8 00:00 test.com.log-20180108 -rw-r--r--. 1 root root 1158 1月 9 21:10 test.com.log-20180109 -rw-r--r--. 1 root root 6528 1月 15 19:23 user.sql //服務端查看 [root@gary-tao ~]# ls -l /tmp/ 總用量 1324 -rw-r--r-- 1 root root 19 1月 16 15:00 123.txt srw-rw-rw- 1 root root 0 1月 12 09:55 aming.sock -rw-r--r-- 1 root root 1304811 1月 15 19:27 mysql_all.sql srwxrwxrwx 1 mysql mysql 0 1月 12 15:02 mysql.sock -rw-r--r-- 1 root root 30806 1月 15 19:31 mysql.sql srw-rw-rw- 1 root root 0 1月 12 09:55 php-fcgi.sock drwx------ 3 root root 17 1月 12 09:55 systemd-private-55f859a1063045b7a4c022e444d06732-vmtoolsd.service-FjZRDv -rw-r--r-- 1 root root 0 1月 6 00:00 test.com.log-20180106 -rw-r--r-- 1 root root 0 1月 7 00:00 test.com.log-20180107 -rw-r--r-- 1 root root 0 1月 8 00:00 test.com.log-20180108 -rw-r--r-- 1 root root 1158 1月 9 21:10 test.com.log-20180109 -rw-r--r-- 1 root root 6528 1月 15 19:23 user.sql
執行命令:sql
[root@gary-tao ~]# mount -t nfs -oremount,nfsvers=3 192.168.118.133:/tmp/ /mnt/