5月 292018
Ubuntu16.04安装NFS客户端并挂载NFS存储
安装NFS客户端组件
root@localhost:~# apt-get update root@localhost:~# apt-get install nfs-common Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.4.0-87 linux-headers-4.4.0-87-generic linux-image-4.4.0-87-generic linux-image-extra-4.4.0-87-generic Use 'apt autoremove' to remove them. The following additional packages will be installed: keyutils libevent-2.0-5 libnfsidmap2 libtirpc1 rpcbind Suggested packages: open-iscsi watchdog The following NEW packages will be installed: keyutils libevent-2.0-5 libnfsidmap2 libtirpc1 nfs-common rpcbind 0 upgraded, 6 newly installed, 0 to remove and 80 not upgraded. Need to get 493 kB of archives. After this operation, 1,693 kB of additional disk space will be used. Do you want to continue? [Y/n] Y
挂载NAS存储并查看挂载信息
root@localhost:~# mount -t nfs -o vers=4.0 9999f94a9b0-biz99.cn-hongkong.nas.aliyuncs.com:/ /data root@localhost:~# df -h Filesystem Size Used Avail Use% Mounted on udev 2.0G 0 2.0G 0% /dev tmpfs 396M 2.8M 393M 1% /run /dev/vda1 99G 2.7G 91G 3% / tmpfs 2.0G 0 2.0G 0% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup tmpfs 396M 0 396M 0% /run/user/0 9999f94a9b0-biz99.cn-hongkong.nas.aliyuncs.com:/ 1.0P 0 1.0P 0% /data root@localhost:~#
设置NFS在系统启动时自动挂载
root@localhost:~# vi /etc/fstab 9999f94a9b0-biz99.cn-hongkong.nas.aliyuncs.com:/ /data nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
手动挂载和自动挂载mount输出的差异
9999f94a9b0-biz99.cn-hongkong.nas.aliyuncs.com:/ on /data type nfs4 (rw,relatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.22.105.10,local_lock=none,addr=10.22.107.25) 9999f94a9b0-biz99.cn-hongkong.nas.aliyuncs.com:/ on /data type nfs4 (rw,noatime,vers=4.0,rsize=1048576,wsize=1048576,namlen=255,acregmin=1800,acregmax=1800,acdirmin=1800,acdirmax=1800,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.22.105.10,local_lock=none,addr=10.22.107.25)
NFS性能参数调优
root@localhost:~# cat /proc/sys/sunrpc/tcp_slot_table_entries 2 root@localhost:~# root@localhost:~# echo "options sunrpc tcp_slot_table_entries=128" >> /etc/modprobe.d/sunrpc.conf root@localhost:~# echo "options sunrpc tcp_max_slot_table_entries=128" >> /etc/modprobe.d/sunrpc.conf root@localhost:~# sysctl -w sunrpc.tcp_slot_table_entries=128 sunrpc.tcp_slot_table_entries = 128 root@localhost:~# cat /proc/sys/sunrpc/tcp_slot_table_entries 128 root@localhost:~#