首页 > 代码库 > nfs
nfs
1
[root@westos mnt]# yum install nfs-utils
[root@westos mnt]# systemctl enable nfs-server
ln -s ‘/usr/lib/systemd/system/nfs-server.service‘ ‘/etc/systemd/system/nfs.target.wants/nfs-server.service‘
[root@westos mnt]# systemctl start nfs-server
[root@westos mnt]# firewall-cmd --permanent --add-service=nfs
success
[root@westos mnt]# firewall-cmd --permanent --add-service=rpc-bind
success
[root@westos mnt]# firewall-cmd --permanent --add-service=mountd
success
[root@localhost ~]# firewall-cmd --reload
success
2共享目录
[root@westos ~]# systemctl status nfs-server
nfs-server.service - NFS Server
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled)
Active: active (exited) since Sat 2017-06-03 21:04:56 EDT; 35min ago
Process: 2007 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS $RPCNFSDCOUNT (code=exited, status=0/SUCCESS)
Process: 2003 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Process: 2002 ExecStartPre=/usr/libexec/nfs-utils/scripts/nfs-server.preconfig (code=exited, status=0/SUCCESS)
Main PID: 2007 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
Jun 03 21:04:56 westos systemd[1]: Starting NFS Server...
Jun 03 21:04:56 westos systemd[1]: Started NFS Server.
root@westos ~]# mkdir /piblic 建立共享目录
[root@westos ~]# chmod 777 /public
chmod: cannot access ‘/public’: No such file or directory
[root@westos ~]# chmod 777 /piblic
[root@westos ~]# vim /etc/exportfs
[root@westos ~]# exportfs -rv 重新启动共享目录
/public *(rw,sync) 共享/public给所有人并可写
/public 172.25.0.0/24(sync) 共享给0.0这个网段
/public *.example.com(sync) 共享给example.com域的所有主机
/public 172.25.0.14(ro,sync) 172.25.0.250(rw,sync) 11只读 250可写
/public *(sync,no_root_squash) 共享给所有人,当客户端用root挂载不转化身份
利用kerberos保护nfs输出
在server上
开启kerberos认证,得到ldap用户
[root@localhost ~]# yum install sssd krb-workstation authconfig-gtk -y
[root@localhost ~]# logout
Connection to 172.25.254.114 closed.
[kiosk@foundation14 Desktop]$ ssh root@172.25.254.114 -X 打开图形
root@172.25.254.114‘s password:
Last login: Sat Jun 3 23:48:41 2017 from 172.25.254.14
/usr/bin/xauth: file /root/.Xauthority does not exist
[root@localhost ~]# authconfig-gtk 安装认证
[root@localhost ~]# wget http://172.25.254.254/pub/keytabs/server14.keytab -O /etc/krb5.keytab
--2017-06-03 23:59:28-- http://172.25.254.254/pub/keytabs/server14.keytab
Connecting to 172.25.254.254:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1258 (1.2K)
Saving to: ‘/etc/krb5.keytab’
100%[==========================================>] 1,258 --.-K/s in 0s
2017-06-03 23:59:28 (190 MB/s) - ‘/etc/krb5.keytab’ saved [1258/1258]
下载认证文件
nfs