NFS服务安装

服务端

1.nfs服务安装:

$ sudo apt-get install nfs-kernel-server nfs-common

2.工作路径配置:

/etc/exports文件加上以下语句:

# 增加要共享的目录,以及共享给哪个ip(或网段), fsid不要相同
/var/log/bd_files/ 192.168.3.101/32(rw,no_root_squash,fsid=0)
/var/log/bd_output_cache/ 192.168.3.101/32(rw,no_root_squash,fsid=1)

参数解释:

  • 1.共享的目录
  • 2.允许访问的IP或者某个网段 192.168.1.0/24
  • 3.选项
    • rw 读写
    • ro 只读
    • sync 同步模式,将内存的数据实时写入磁盘
    • async 不同步 ,将内存的数据定期写入磁盘
    • all_squash 限制所有用户,排除后面设定的uid的用户
    • root_squash 限制root用户
    • no_root_squash 不限制root用户
    • anonuid 用于指定使用NFS的用户限定后的uid
    • anongid 用于指定使用NFS的用户限定后的gid

3.重启服务生效:

$ sudo service nfs-kernel-server restart

4.查看已经共享的目录

root@debian:~# showmount -e
Export list for debian:
/var/log/bd_pcap_cache  192.168.1.101/32
/var/log/bd_input_cache 192.168.1.101/32
root@debian:~# 

客户端

1.安装nfs-common

$ sudo apt-get install nfs-common

2.查看服务器共享的目录

root@debian:~# showmount -e 192.168.3.102
Export list for 192.168.3.102:
/var/log/bd_output_cache 192.168.3.101/32
/var/log/bd_files        192.168.3.101/32
root@debian:~# 

3.挂载服务器的共享目录

$ mount -o nolock,wsize=1024,rsize=1024 192.168.3.102:/var/log/bd_files /var/log/bd_files/
$ mount -o nolock,wsize=1024,rsize=1024 192.168.3.102:/var/log/bd_output_cache /var/log/bd_output_cache

4.查看挂载情况

root@debian:~# df -h
Filesystem                              Size  Used Avail Use% Mounted on
/dev/sda2                               197G   28G  160G  15% /
udev                                     10M     0   10M   0% /dev
tmpfs                                   6.3G   17M  6.3G   1% /run
tmpfs                                    16G  992K   16G   1% /dev/shm
tmpfs                                   5.0M     0  5.0M   0% /run/lock
tmpfs                                    16G     0   16G   0% /sys/fs/cgroup
/dev/sda3                               591G  337M  561G   1% /var/lib/postgresql
tmpfs                                   4.0G  499M  3.6G  13% /var/log/bd_input_cache
tmpfs                                   2.0G  5.1M  2.0G   1% /var/log/bd_pcap_cache
tmpfs                                   1.0G   32K  1.0G   1% /var/log/bd_tmp_cache
192.168.3.102:/var/log/bd_files         213G   46G  157G  23% /var/log/bd_files
192.168.3.102:/var/log/bd_output_cache  1.0G     0  1.0G   0% /var/log/bd_output_cache
原文地址:https://www.cnblogs.com/yanhai307/p/10861459.html