挂载共享目录到本地/opt下
[root@localhost ~]# mount -t nfs 192.168.1.1:/www /opt/
[root@localhost ~]# df -hT #查看挂载
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sda5 ext3 17G 4.8G 11G 31% /
/dev/sda2 ext3 2.0G 36M 1.9G 2% /home
/dev/sda1 ext3 99M 12M 83M 13% /boot
tmpfs tmpfs 252M 0 252M 0% /dev/shm
/dev/hdc iso9660 3.9G 3.9G 0 100% /media/CentOS_5.5_Final
192.168.1.1:/www
nfs 17G 4.9G 11G 32% /opt
测试,分别向两端添加文件,看是否同步
nfs服务器
[root@localhost ~]# touch /www/1.txt
nfs客户端
[root@localhost ~]# ls /opt/
1.txt
设置开机自动挂载(nfs客户端上)
[root@localhost ~]# vim /etc/fstab
192.168.1.1:/www /opt nfs defaults 0 0
[root@localhost ~]# mount #查看挂载
/dev/sda5 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/sda2 on /home type ext3 (rw)
/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)
none on /proc/fs/vmblock/mountPoint type vmblock (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /media/CentOS_5.5_Final type iso9660 (ro,noexec,nosuid,nodev,uid=0)
192.168.1.1:/www on /opt type nfs (rw,addr=192.168.1.1)
至此,CentOS配置NFS服务器教程完成