NFS网络文件服务器:
windows上面叫文件共享。
多台linux服务器,只要有一台搭建了NFS服务器并把文件共享出来,其余几台服务器就可以来访问。
root@ubuntu:/etc# service portmap status ● rpcbind.service - RPC bind portmap service Loaded: loaded (/lib/systemd/system/rpcbind.service; indirect; vendor preset: enab Drop-In: /run/systemd/generator/rpcbind.service.d └─50-rpcbind-$portmap.conf Active: active (running) since 日 2018-02-25 05:50:45 PST; 1h 30min ago
root@ubuntu:/etc# service nfs-utils start root@ubuntu:/etc# service nfs-utils status ● nfs-utils.service - NFS server and client services Loaded: loaded (/lib/systemd/system/nfs-utils.service; static; vendor preset: enab Active: active (exited) since 日 2018-02-25 07:22:33 PST; 6min ago Process: 6007 ExecStart=/bin/true (code=exited, status=0/SUCCESS) Main PID: 6007 (code=exited, status=0/SUCCESS) 2月 25 07:22:30 ubuntu systemd[1]: Starting NFS server and client services... 2月 25 07:22:33 ubuntu systemd[1]: Started NFS server and client services. 2月 25 07:28:39 ubuntu systemd[1]: Started NFS server and client services.
root@ubuntu:/etc# ll | grep exports -rw-r--r-- 1 root root 389 10月 10 2012 exports root@ubuntu:/etc# vim exports /home/nfs *(sync,ro)
写完之后要重启nfs和portmap才能够生效。 root@ubuntu:/etc# service portmap restart root@ubuntu:/etc# service nfs-utils restart 我们要共享的目录是/home/nfs,现在nfs所属的账号是root,要改成nfs, root@ubuntu:/home# mkdir nfs root@ubuntu:/home# ll drwxr-xr-x 2 root root 4096 2月 25 07:39 nfs/ nfs账号是存在的,root@ubuntu:/home# vim /etc/passwd nfsnobody:x:125:65534::/var/lib/nfs:/bin/false root@ubuntu:/home# chown -R nfsnobody:nfsnobody nfs/ (修改文件的宿主) NFS服务端需要启动2个进程,并修改配置文件,修改文件宿主。 客户端: 创建一个目录/mnt/share chown -R nfsnobody:nfsnobody share/ mount -t nfs 192.168.229.134:/home/nfs /mnt/share(把另一台服务器共享的文件192.168.229.134:/home/nfs映射到本地来/mnt/share)