项目背景: 搭建NFS网络服务器!!!
试验环境: vmware workstation 11 centos6.5的系统下 NFS服务器:ip:192.168.0.36 iptables 关闭 setenforce 0 NFS客户端:ip:192.168.0.39 iptables 关闭 setenforce 0 SecureCRT (ssh远程连接软件)
实验过程: 一、软件安装 服务器端: [root@real_server02 ~]# yum install -y nfs-utils rpcbind 客户端: [root@user ~]# yum install -y nfs-utils rpcbind 二、服务器端设置: 1、[root@real_server02 ~]# vim /etc/exports /home/www 192.168.0.*(rw,sync,no_root_squash) 添加上面这一行,保存退出! 2、创建测试目录 [root@real_server02 ~]# mkdir /home/www 3、服务器端NFS启动 [root@real_server02 www]# /etc/init.d/rpcbind start Starting rpcbind: [ OK ] [root@real_server02 www]# /etc/init.d/nfs start Starting NFS services: [ OK ] Starting NFS quotas: [ OK ] Starting NFS mountd: [ OK ] Starting NFS daemon: [ OK ] Starting RPC idmapd: [ OK ] [root@real_server02 www]# /etc/init.d/nfslock start Starting NFS statd: [ OK ] [root@real_server02 www]# chkconfig rpcbind on [root@real_server02 www]# chkconfig nfs on [root@real_server02 www]# chkconfig nfslock on 4、显示出来我们芥菜设置的共享目录 [root@real_server02 www]# showmount -e localhost Export list for localhost: /home/www 192.168.0.* 三、客户端设置 1、启动必要服务 [root@user ~]# /etc/init.d/rpcbind start Starting rpcbind: [ OK ] [root@user ~]# /etc/init.d/nfslock start Starting NFS statd: [ OK ] 2、查看NFS服务器提供给我们的共享目录信息 [root@user ~]# showmount -e 192.168.0.36 Export list for 192.168.0.36: /home/www 192.168.0.* 3、创建挂载点,然后把服务器的共享目录挂在上去 [root@user ~]# mkdir /home/nfs/ [root@user ~]# mount -t nfs 192.168.0.36:/home/www /home/nfs/ [root@user ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 18339256 2910612 14497060 17% / tmpfs 502204 84 502120 1% /dev/shm /dev/sda1 297485 34643 247482 13% /boot 192.168.0.36:/home/www 18208256 2918400 14358272 17% /home/nfs 可以看到我们成功了!!!
简单应用 :进去客户端我们挂载的目录,然后创建一个测试文件,然后查看服务器端是否出现我们创建的文件。 NFS客户端 [root@user nfs]# ifconfig >test.txt [root@user nfs]# cat test.txt eth0 Link encap:Ethernet HWaddr 00:0C:29:97:5D:78 inet addr:192.168.0.39 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe97:5d78/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13460 errors:0 dropped:0 overruns:0 frame:0 TX packets:6304 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:8998558 (8.5 MiB) TX bytes:520939 (508.7 KiB) 我只是截取了一部分 NFS服务器端 [root@real_server02 www]# ls test.txt [root@real_server02 www]# cat test.txt eth0 Link encap:Ethernet HWaddr 00:0C:29:97:5D:78 inet addr:192.168.0.39 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe97:5d78/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:13460 errors:0 dropped:0 overruns:0 frame:0 TX packets:6304 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:8998558 (8.5 MiB) TX bytes:520939 (508.7 KiB)
可以看到我们成功的进行了同步,当然NFS服务器的用途不仅限于此! |