NFS服务端:
[[email protected] ~]# rpm -qa rpcbind nfs-utils [[email protected] ~]# yum -y install rpcbind nfs-utils [[email protected] ~]# rpm -qa rpcbind nfs-utils [[email protected] ~]# mkdir /data/www/www/upload -p [[email protected] ~]# vim /etc/exports ~ [[email protected] ~]# /etc/init.d/nfs reload [[email protected] ~]# showmount -e 192.168.10.103 [[email protected] ~]# chown -R nfsnobody /data/www/www/upload/ [[email protected] ~]# touch /data/www/www/upload/iam_nfs_server [[email protected] ~]# vim /etc/rc.local 开机启动服务 |
搭好NFS-server后,将此web配置为NFS-client
:
[[email protected] ~]# rpm -qa rpcbind nfs-utils
[[email protected] ~]# yum -y install rpcbind nfs-utils
[[email protected] ~]# /etc/init.d/rpcbind start
Starting rpcbind: [ OK ]
[[email protected] ~]# ps -ef |grep rpcbind |grep -v grep
rpc 7938 1 0 18:28 ? 00:00:00 rpcbind
[[email protected] ~]# netstat -lntup |grep rpcbind
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 7938/rpcbind
tcp 0 0 :::111 :::* LISTEN 7938/rpcbind
udp 0 0 0.0.0.0:111 0.0.0.0:* 7938/rpcbind
udp 0 0 0.0.0.0:905 0.0.0.0:* 7938/rpcbind
udp 0 0 :::111 :::* 7938/rpcbind
udp 0 0 :::905 :::* 7938/rpcbind
[[email protected] ~]#
[[email protected] ~]# mkdir /data/www/www/upload
[[email protected] ~]# mkdir /data/www/bbs/upload
[[email protected] ~]# mkdir /data/www/blog/upload
[[email protected] ~]# mount -t nfs 192.168.10.103:/data/www/www/upload/ /data/www/www/upload/
[[email protected] ~]# mount -t nfs 192.168.10.103:/data/www/bbs/upload/ /data/www/bbs/upload/
[[email protected] ~]# mount -t nfs 192.168.10.103:/data/www/blog/upload/ /data/www/blog/upload/
[[email protected] ~]#
[[email protected] ~]# mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.10.103:/data/www/www/upload/ on /data/www/www/upload type nfs (rw,vers=4,addr=192.168.10.103,clientaddr=192.168.10.104)
192.168.10.103:/data/www/bbs/upload/ on /data/www/bbs/upload type nfs (rw,vers=4,addr=192.168.10.103,clientaddr=192.168.10.104)
192.168.10.103:/data/www/blog/upload/ on /data/www/blog/upload type nfs (rw,vers=4,addr=192.168.10.103,clientaddr=192.168.10.104)
[[email protected] ~]#
[[email protected] ~]# ls /data/www/www/upload/
iam_nfs_server
[[email protected] ~]#
[[email protected] ~]# vim /etc/rc.local
开机自动挂载
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don‘t # want to do the full Sys V style init stuff. touch /var/lock/subsys/local /etc/init.d/iptables stop /etc/init.d/rpcbind start mount -t nfs 192.168.10.103:/data/www/www/upload/ /data/www/www/upload/ mount -t nfs 192.168.10.103:/data/www/bbs/upload/ /data/www/bbs/upload/ mount -t nfs 192.168.10.103:/data/www/blog/upload/ /data/www/blog/upload/