ubuntu 16.04 OS 安装TFTP and NFS Server 配置详解

TFTP*********************************************

1. sudo apt-get install -y tftpd tftp openbsd-inetd
2. sudo  vi /etc/inetd.conf
#:BOOT: TFTP service is provided primarily for booting. Most sites
# run this only on machines acting as "boot servers."
#tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp  (/srv/tftp 为默认tftp目录)
#修改如下文件
tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /home/harry/TftpRoot
3.sudo mkdir /home/harry/TftpRoot
4.sudo chmod 777 /home/harry/TftpRoot
5.sudo /etc/init.d/openbsd-inetd restart
6.查看69端口是否有打开 :netstat -an | more | grep udp
udp 0 0 0.0.0.0:69 0.0.0.0:*
7.本机测试:
      a. 在/home/harry/TftpRoot 下新建文件1.txt   
      b. 在其他目录下测试:
       tftp 127.0.0.1
       tftp> get 1.txt
        Received 12 bytes in 0.0 seconds
        tftp> quit

   

NFS***********************************************

1、执行命令:sudo apt-get install -y nfs-kernel-server ;

2、执行命令:mkdir /home/harry/NfsRoot 建立一个nfs服务的专有的文件夹;

3、建立好文件夹后,接着执行命令:sudo vi /etc/exports 配置nfs;

4、在文章的最后一行添加:/home/harry/NfsRoot *(rw,sync,no_root_squash,no_subtree_check)
 11 /home/harry/NfsRoot 192.168.15.0/24(rw,sync,no_root_squash,no_subtree_check,wdelay)
 12 /home/pumbaa/NfsRoot 192.168.15.0/24(rw,sync,no_root_squash,no_subtree_check,wdelay)
 13 /home/haisheng/NfsRoot 192.168.15.0/24(rw,sync,no_root_squash,no_subtree_check,wdelay)
 14 /home/fhl/NfsRoot 192.168.15.0/24(rw,sync,no_root_squash,no_subtree_check,wdelay)
/home/harry/NfsRoot *(rw,sync,no_root_squash,no_subtree_check)这一行的含义是:
/home/harry/NfsRoot:与nfs服务客户端共享的目录,这个路径必须和你前面设置的文件的路径一致!
*:允许所有的网段访问,也可以使用具体的IP
rw:挂接此目录的客户端对该共享目录具有读写权限
sync:资料同步写入内存和硬盘
no_root_squash:root用户具有对根目录的完全管理访问权限。
no_subtree_check:不检查父目录的权限。

5、修改完上述配置文件保存退出。

6、执行命令:sudo /etc/init.d/rpcbind restart 重启rpcbind 服务。nfs是一个RPC程序,使用它前,需要映射好端口,通过rpcbind 设定。

7、执行命令:sudo /etc/init.d/nfs-kernel-server restart 重启nfs服务。

8、挂载指令:
sudo mount -t nfs 192.168.15.238:/home/harry/NfsRoot ./tmp/
到任意一台服务器中执行挂载指令,则可以将指定ip服务器上的共享路径,挂载到本地。

注:nfs只是一种文件目录共享模式,以本地方式进行访问。而HDFS是一种分布式的文件系统,能够在服务器中进行数据的负载均衡。

9、开机自动挂载:
把 上述指令 sudo mount -t nfs 192.168.111.128:/home/harry/NfsRoot ./tmp/ 写到 /etc/rc.local 文件中

附录:NFS常用参数如下:
ro 只读访问
rw 读写访问sync 所有数据在请求时写入共享
async nfs在写入数据前可以响应请求
secure nfs通过1024以下的安全TCP/IP端口发送
insecure nfs通过1024以上的端口发送
wdelay 如果多个用户要写入nfs目录,则归组写入(默认)
no_wdelay 如果多个用户要写入nfs目录,则立即写入,当使用async时,无需此设置。
hide 在nfs共享目录中不共享其子目录
no_hide 共享nfs目录的子目录
subtree_check 如果共享/usr/bin之类的子目录时,强制nfs检查父目录的权限(默认)
no_subtree_check 和上面相对,不检查父目录权限
all_squash 共享文件的UID和GID映射匿名用户anonymous,适合公用目录。
no_all_squash 保留共享文件的UID和GID(默认)
root_squash root用户的所有请求映射成如anonymous用户一样的权限(默认)
no_root_squas root用户具有根目录的完全管理访问权限
anonuid=xxx 指定nfs服务器/etc/passwd文件中匿名用户的UID
anongid=xxx 指定nfs服务器/etc/passwd文件中匿名用户的GID  

猜你喜欢

转载自blog.csdn.net/hehaibo2008/article/details/52253924
今日推荐