个人工具
104.160.18.24
该IP地址的讨论
登录
查看“UbuntuHelp:NFSv4Howto”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:NFSv4Howto”的源代码
来自Ubuntu中文
←
UbuntuHelp:NFSv4Howto
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/NFSv4Howto}} {{Languages|UbuntuHelp:NFSv4Howto}} === Installation === The required packages are different depending on if the system is a client or a server. In this Howto, the server is the host that has the files you want to share and the client is the host that will be mounting the NFS share. * NFSv4 client <pre><nowiki> # apt-get install nfs-common </nowiki></pre> * NFSv4 server <pre><nowiki> # apt-get install nfs-kernel-server </nowiki></pre> After you finish installing nfs-kernel-server, you might see failure to start nfs-kernel-server due to missing entries in /etc/exports. Remember to restart the service when you finish configuring. === NFSv4 without Kerberos === ==== NFSv4 Server ==== NFSv4 exports exist in a single ''pseudo filesystem'', where the real directories are mounted with the <code><nowiki>--bind</nowiki></code> option. [http://www.citi.umich.edu/projects/nfsv4/linux/using-nfsv4.html Here] is some additional information regarding this fact. * Let's say we want to export our users' home directories in <code><nowiki>/home/users</nowiki></code>. First we create the export filesystem: <pre><nowiki> # mkdir /export # mkdir /export/users </nowiki></pre> and mount the real users directory with: <pre><nowiki> # mount --bind /home/users /export/users</nowiki></pre> To save us from retyping this after every reboot we add the following line to <code><nowiki>/etc/fstab</nowiki></code> <pre><nowiki> /home/users /export/users none bind 0 0</nowiki></pre> * In <code><nowiki>/etc/default/nfs-kernel-server</nowiki></code> we set: <pre><nowiki> NEED_SVCGSSD=no </nowiki></pre> because we are not activating NFSv4 security this time. * In <code><nowiki>/etc/default/nfs-common</nowiki></code> we set: <pre><nowiki> NEED_IDMAPD=yes NEED_GSSD=no </nowiki></pre> * To export our directories to a local network 192.198.1.0/24 we add the following two lines to <code><nowiki>/etc/exports</nowiki></code> <pre><nowiki> /export 192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async) /export/users 192.168.1.0/24(rw,nohide,insecure,no_subtree_check,async) </nowiki></pre> * Restart the service <pre><nowiki> # /etc/init.d/nfs-kernel-server restart</nowiki></pre> ==== NFSv4 Client ==== * On the client we can mount the complete export tree with one command: <pre><nowiki> # mount -t nfs4 -o proto=tcp,port=2049 nfs-server:/ /mnt</nowiki></pre> * We can also mount an exported ''subtree'' with: <pre><nowiki> # mount -t nfs4 -o proto=tcp,port=2049 nfs-server:/users /home/users</nowiki></pre> * To save us from retyping this after every reboot we add the following line to <code><nowiki>/etc/fstab</nowiki></code>: <pre><nowiki> nfs-server:/ /mnt nfs4 _netdev,auto 0 0</nowiki></pre> where the <code><nowiki>auto</nowiki></code> option mounts on startup and the <code><nowiki>_netdev</nowiki></code> option waits until network devices are loaded. * If you have a slow network connection and are not establishing mount at reboot, you can change the line in <code><nowiki>etc/fstab</nowiki></code>: <pre><nowiki> nfs-server:/ /mnt nfs4 noauto 0 0</nowiki></pre> and execute this mount after a short pause once all devices are loaded. Add the following lines to <code><nowiki>/etc/rc.local</nowiki></code> <pre><nowiki> # sleep 5 # mount /mnt</nowiki></pre> * If you experience Problems like this: <pre><nowiki> Warning: rpc.idmapd appears not to be running. All uids will be mapped to the nobody uid. mount: unknown filesystem type 'nfs4'</nowiki></pre> then you need to set in <code><nowiki>/etc/default/nfs-common</nowiki></code>: <pre><nowiki> NEED_IDMAPD=yes</nowiki></pre> and restart nfs-common <pre><nowiki> # /etc/init.d/nfs-common restart</nowiki></pre> The "unknown Filesystem" Error will disappear as well. === NFSv4 with Kerberos === You need a working Kerberos (MIT or Heimdal) KDC (Key Distribution Center) before continuing. NFS4 and Kerberos work fine with Ubuntu 8.04; they do not seem to work with the (much) older Ubuntu 6.06, or at least I couldn't get Heimdal to work correctly. Please note, that we have three different entities: the Kerberos-server; the NFS-server and the NFS-client. Your Kerberos-server (or KDC) and NFS-server could be the same machine, but they could also very well be separate entities. We will use separate "prompts" to distinguish, i.e. if you see <pre><nowiki> KDC$ echo "hello" </nowiki></pre> ... this means you need to type echo "hello" on the KDC. Please note that you can now (with Ubuntu 8.04 and later) use any encryption type you want, there is no more need to extract only ''des-cbc-crc'', as most sites suggest. See [http://mailman.mit.edu/pipermail/kerberos/2008-May/013698.html this mailinglist message]. ===== MIT ===== * On the nfs-server and nfs-client you need at least the ''krb5-user'' and optional ''libpam-krb5'' if you wish to authenticate against krb5. <pre><nowiki> # apt-get install krb5-user # apt-get install libpam-krb5 </nowiki></pre> ===== Heimdal ===== * On the nfs-server and nfs-client you need ''heimdal-clients'' and optional ''libpam-krb5'' if you wish to authenticate against krb5. <pre><nowiki> # apt-get install heimdal-clients # apt-get install libpam-krb5 </nowiki></pre> * You need the gss kernel modules on nfs-servers and nfs-clients. <pre><nowiki> # modprobe rpcsec_gss_krb5 </nowiki></pre> Add ''rpcsec_gss_krb5'' to ''/etc/modules'' to have it loaded automatically. (I'm pretty sure they're loaded automatically though). ==== Create and distribute credentials ==== NFSv4 needs machine credentials for the server and every client, which wants to use the NFSv4 security features. Create the credentials for the nfs-server and all nfs-clients on the Kerberos KDC and distribute the extraced keys with scp to the destination You can make sure that only this entry has been created by executing "sudo klist -e -k /etc/krb5.keytab". ===== Heimdal ===== Authenticate as your admin user. You can do this from any machine in your kerberos-domain, as long as your kadmind is running; then add principals for your server and client machines. Replace "nfs-server.domain" with the fully qualified domain name of the machines. For example, if your server is called "snoopy" and your domain is "office.example.com", you would add a principal named "nfs/snoopy.office.example.com" for the server. Note: kadmin must be run with -l (locally) on the KDC if there is no kadmind. Please be aware of https://bugs.launchpad.net/ubuntu/+source/heimdal/+bug/309738/ <pre><nowiki> $ kinit kadmin/admin $ kadmin add -r nfs/nfs-server.domain $ kadmin add -r nfs/nfs-client.domain </nowiki></pre> Now add these to the keytab-files on your NFS-server and client. Log in to your NFSserver (as root, because you will need to edit the /etc/krb5.keytab file) and initialize as Kerberos administrator. If your domain is fully kerberized, logging in as root will automatically give you the right access, in which case you don't need to use "kinit" anymore. <pre><nowiki> NFSserver# kinit kadmin/admin NFSserver# ktutil get nfs/nfs-server.domain </nowiki></pre> And add it to the client's keytab file: <pre><nowiki> NFSclient# kinit kadmin/admin NFSclient# ktutil get nfs/nfs-client.domain </nowiki></pre> ===== MIT ===== The information below is not correct. You don't need the "des-cbc-crc" anymore and copying the key with "scp" is probably not necessary. (Could anyone with MIT knowledge clear this up, please? Valentijn) <pre><nowiki> # kinit admin/admin # kadmin -q "addprinc -randkey nfs/nfs-server.domain" # kadmin -q "ktadd -e des-cbc-crc:normal -k /root/keytab.nfs-server nfs/nfs-server.domain" # scp -p /root/keytab.nfs-server nfs-server.domain:/etc/krb5.keytab # kadmin -q "addprinc -randkey nfs/nfs-client.domain" # kadmin -q "ktadd -e des-cbc-crc:normal -k /root/keytab.nfs-client nfs/nfs-client.domain" # scp -p /root/keytab.nfs-client nfs-client.domain:/etc/krb5.keytab # kdestroy </nowiki></pre> ==== NFSv4 Server with Kerberos ==== * Check your machine credentials in ''/etc/krb5.keytab''. Use "ktutil" (MIT) or "ktutil list" (Heimdal) MIT: <pre><nowiki> # ktutil ktutil: rkt /etc/krb5.keytab ktutil: list slot KVNO Principal ---- ---- --------------------------------------------------------------------- 1 2 nfs/nfs-server.domain@DOMAIN </nowiki></pre> Heimdal: <pre><nowiki> # ktutil list FILE:/etc/krb5.keytab: Vno Type Principal 6 des-cbc-md5 nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM 6 des-cbc-md4 nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM 6 des-cbc-crc nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM 6 aes256-cts-hmac-sha1-96 nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM 6 des3-cbc-sha1 nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM 6 arcfour-hmac-md5 nfs/snoopy.office.example.com@OFFICE.EXAMPLE.COM </nowiki></pre> etcetera (I removed the krb4 entries as you probably won't use them anyway). MIT extra information: <pre><nowiki> # sudo klist -e -k /etc/krb5.keytab Keytab name: FILE:/etc/krb5.keytab KVNO Principal ---- -------------------------------------------------------------------------- 1 nfs/nfs-server.domain@DOMAIN (DES cbc mode with CRC-32) </nowiki></pre> * In <code><nowiki>/etc/default/nfs-kernel-server</nowiki></code> we set: <pre><nowiki> NEED_SVCGSSD=yes </nowiki></pre> * In <code><nowiki>/etc/default/nfs-common</nowiki></code> we set: <pre><nowiki> NEED_IDMAPD=yes </nowiki></pre> * To export our directories from the example above to a local network 192.198.1.0/24 and addt we add the following two lines to <code><nowiki>/etc/exports</nowiki></code> <pre><nowiki> /export 192.168.1.0/24(rw,fsid=0,insecure, \ no_subtree_check,async,anonuid=65534,anongid=65534) /export gss/krb5(rw,fsid=0,insecure, \ no_subtree_check,async,anonuid=65534,anongid=65534) /export/users 192.168.1.0/24(rw,nohide,insecure, \ no_subtree_check,async,anonuid=65534,anongid=65534) /export/users gss/krb5(rw,nohide,insecure, \ no_subtree_check,async,anonuid=65534,anongid=65534) </nowiki></pre> Please note that you can specify allowed hosts only in the ''any authentication'' flavor. gss/krb5 flavours are accessible from anywhere, if do not use an additional firewall rules. To export only with secure authentication flavors do not include a ''host(...)'' line in ''/etc/exports'' To display your exports enter: <pre><nowiki> # exportfs -v </nowiki></pre> ==== NFSv4 Client with Kerberos ==== * Check your machine credentials in ''/etc/krb5.keytab'' MIT: <pre><nowiki> # ktutil ktutil: rkt /etc/krb5.keytab ktutil: list slot KVNO Principal ---- ---- --------------------------------------------------------------------- 1 2 nfs/nfs-client.domain@DOMAIN </nowiki></pre> Heimdal: <pre><nowiki> # ktutil list FILE:/etc/krb5.keytab: Vno Type Principal 6 des-cbc-md5 nfs/client.office.example.com@OFFICE.EXAMPLE.COM 6 des-cbc-md4 nfs/client.office.example.com@OFFICE.EXAMPLE.COM 6 des-cbc-crc nfs/client.office.example.com@OFFICE.EXAMPLE.COM 6 aes256-cts-hmac-sha1-96 nfs/client.office.example.com@OFFICE.EXAMPLE.COM 6 des3-cbc-sha1 nfs/client.office.example.com@OFFICE.EXAMPLE.COM 6 arcfour-hmac-md5 nfs/client.office.example.com@OFFICE.EXAMPLE.COM </nowiki></pre> * In <code><nowiki>/etc/default/nfs-common</nowiki></code> we set: <pre><nowiki> NEED_IDMAPD=yes NEED_GSSD=yes </nowiki></pre> * We can ''secure'' mount the complete export tree with: <pre><nowiki> # mount -t nfs4 -o sec=krb5 nfs-server:/ /mnt</nowiki></pre> * We can also ''secure'' mount an exported ''subtree'' with: <pre><nowiki> # mount -t nfs4 -o sec=krb5 nfs-server:/users /home/users</nowiki></pre> === Troubleshooting === First, take care of proper logging - by default almost nothing is logged. e.g. to enable 3rd level verbose logging for rpc.gssd, append the following to <code><nowiki>/etc/default/nfs-common</nowiki></code>: <pre><nowiki> RPCGSSDOPTS="-vvv" </nowiki></pre> After restarting nfs-common (<code><nowiki>/etc/init.d/nfs-common restart</nowiki></code>) check that the daemon has received new arguments: <pre><nowiki> ps xuwa | grep grep rpc.gssd root 9857 0.0 0.4 2496 1220 ? Ss 02:17 0:00 /usr/sbin/rpc.gssd -vvv </nowiki></pre> Then look for its log output in damon.log: <pre><nowiki> tail -f /var/log/daemon.log </nowiki></pre> For the server, you can e.g. raise rpc.svcgssd log level in <code><nowiki>/etc/default/nfs-kernel-server</nowiki></code>: <pre><nowiki> RPCSVCGSSDOPTS="-vvv" </nowiki></pre> Browse the <code><nowiki>/etc/init.d/nfs-*</nowiki></code> init scripts to see other variables that you can set in <code><nowiki>/etc/defaults</nowiki></code>. If using Kerberos, enable logging in <code><nowiki>/etc/krb5.conf</nowiki></code>: <pre><nowiki> [logging] kdc = SYSLOG:INFO:DAEMON admin_server = SYSLOG:INFO:DAEMON default = SYSLOG:INFO:DAEMON </nowiki></pre> === Links === * [http://www.citi.umich.edu/projects/nfsv4/linux Umich CITI intructions] * [http://www.vanemery.com/Linux/NFSv4/NFSv4-no-rpcsec.html Learning NFSv4 with Fedora Core 2] [[category:CategoryCleanup]] [[category:CategoryNetworking]] [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:NFSv4Howto
。