11 月 202012
 

NFS服务器端

安装包

[root@localhost ~]# yum install nfs-utils

编辑本机主机名

[root@localhost ~]# vi /etc/idmapd.conf #Domain = local.domain.edu

创建共享目录

[root@localhost ~]# mkdir /shared [root@localhost ~]# chmod 777 /shared/

编辑共享目录及设置权限

 #vi /etc/exports /shared 192.168.1.0/24(rw,sync)

启动服务

[root@localhost ~]# service nfs start 
Starting NFS services:                                     [  OK  ] 
Starting NFS mountd:                                       [  OK  ] 
Stopping RPC idmapd:                                       [  OK  ] 
Starting RPC idmapd:                                       [  OK  ] 
Starting NFS daemon:                                       [  OK  ]

查看共享目录状态

[root@localhost ~]# showmount -e 
Export list for localhost.localdomain:
/shared 192.168.1.0/24

设置服务为开机启动  

[root@localhost ~]# chkconfig --level 35 nfs on

NFS客户端

挂载共享目录

[root@localhost ~]# mount -t nfs 192.168.2.122:/shared /share/

查看当前挂载的文件系统

[root@localhost ~]# mount 
/dev/mapper/VolGroup-lv_root 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) /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) 
nfsd on /proc/fs/nfsd type nfsd (rw) 192.168.2.122:/shared on /share 
 type nfs (rw,vers=4,addr=192.168.2.122,clientaddr=192.168.146.130)

注册文件系统并在开机时自动挂载

#vi /etc/fstab 192.168.2.122:/shared 
/share                  nfs     defaults        0 0

查看共享文件系统磁盘容量

#df Filesystem           1K-blocks      Used Available Use% Mounted on 
/dev/mapper/VolGroup-lv_root      8813300   1250776   7114832  15% / 
tmpfs                   122236         0    122236   0% /dev/shm 
/dev/sda1               495844     70454    399790  15% /boot 
192.168.2.122:/shared      15022080  13341184    917504  94% /share

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据