首页 > 代码库 > Linux NFS 服务部署

Linux NFS 服务部署

系统环境:Oracle Linux 5.7

服务端:192.168.1.111

客户端:192.168.1.171

一、服务端配置

1.依次启动portmap和nfs服务

service portmap start

service nfs start

[root@OEL-ASM ~]#  service portmap statusportmap (pid 2543) is running...[root@OEL-ASM ~]#  service nfs statusrpc.mountd is stoppednfsd is stoppedrpc.rquotad is stopped[root@OEL-ASM ~]# service nfs startStarting NFS services:                                     [  OK  ]Starting NFS quotas:                                       [  OK  ]Starting NFS daemon:                                       [  OK  ]Starting NFS mountd:                                       [  OK  ]
[root@OEL-ASM ~]# service nfs statusrpc.mountd (pid 10530) is running...nfsd (pid 10527 10526 10525 10524 10523 10522 10521 10520) is running...rpc.rquotad (pid 10504) is running...

2.将服务端需要共享的目录配置到/etc/exports文件中

例如在/etc/exports配置文件中添加一行:

/usr2/nfs *(rw)

配置/etc/exports文件后重启nfs服务

[root@OEL-ASM /]# mkdir -p /usr2/nfs[root@OEL-ASM /]# cd /usr2/nfs[root@OEL-ASM nfs]# ls[root@OEL-ASM nfs]# pwd/usr2/nfs[root@OEL-ASM nfs]# touch 1 2[root@OEL-ASM nfs]# vi 1[root@OEL-ASM nfs]# vi 2[root@OEL-ASM nfs]# more 1Hello, World! one~[root@OEL-ASM nfs]# more 2Hello, World! two.[root@OEL-ASM nfs]# pwd/usr2/nfs[root@OEL-ASM nfs]# ls -lhtotal 8.0K-rw-r--r-- 1 root root 19 10-09 10:02 1-rw-r--r-- 1 root root 19 10-09 10:03 2
[root@OEL-ASM nfs]# vi /etc/exports[root@OEL-ASM nfs]# more /etc/exports/usr2/nfs *(rw)[root@OEL-ASM nfs]# service nfs restartShutting down NFS mountd:                                  [  OK  ]Shutting down NFS daemon:                                  [  OK  ]Shutting down NFS quotas:                                  [  OK  ]Starting NFS services:                                     [  OK  ]Starting NFS quotas:                                       [  OK  ]Starting NFS daemon:                                       [  OK  ]Starting NFS mountd:                                       [  OK  ]
[root@OEL-ASM nfs]# showmount -eExport list for OEL-ASM:/usr2/nfs *[root@OEL-ASM nfs]# exportfs/usr2/nfs <world>

二、客户端配置

1.同样启动服务

service portmap start

service nfs start

2.创建挂载目录挂载服务端映射出来的目录

mkdir -p /usr2/nfs_mapmount -t nfs 192.168.1.111:/usr2/nfs /usr2/nfs_map

此时就可以在客户端/usr2/nfs_map目录下看到服务端/usr2/nfs目录下的文件了,如下:

# df -hFilesystem            Size  Used Avail Use% Mounted on/dev/mapper/VolGroup00-LogVol00                       55G   11G   41G  21% //dev/sda1              99M   23M   71M  25% /boottmpfs                 749M     0  749M   0% /dev/shm192.168.1.111:/usr2/nfs                       55G   11G   41G  21% /usr2/nfs_map# ls -lhtotal 8.0K-rw-r--r-- 1 root root 19 10-09 10:02 1-rw-r--r-- 1 root root 19 10-09 10:03 2

# more 1Hello, World! one~
# more 2Hello, World! two.

 

Linux NFS 服务部署