树莓派4b部署 samba 遇到的问题
一、硬件问题
之前有一个树莓派3b,在samba共享的时候,看视频很卡。经过排查,发现是网线的问题,之前用的网线是不知道从哪儿捡回来的线。换了根网线之后,用iperf3,测试网速直接从100mbps 升到300mbps。
于是直接网购了几条超6类线。
二、smb.config 设置问题。
安装过程不再赘述。
iperf3测试速度在940mbps。但是samba共享复制文件速度竟然只有2~3MBps。这不科学啊!
在网上搜索了一下优化方法。其主要为修改smb.config文件。主流的配置方法如下:
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=1048576 SO_SNDBUF=1048576
aio read size = 65536
aio write size = 65536
aio write behind = true
write cache size = 2097152
max xmit = 65536
large readwrite = yes
use sendfile = yes
min receivefile size = 16384
getwd cache = true
follow symlinks = no
wide links = no
log level = 0
配置完成之后,发现速度可以达到 60MBps。但是无法达到理论满速110MBps。
经过调查。
通过 samba 自带的 testparm 命令,配置文件的选项大多数都没用。特别是 套接字选项 socket options。参考:https://wiki.samba.org/index.php/Performance_Tuning
write cache size 这个选项虽然被删除了,但是在raspberrypi的系统上设置之后的影响很大。//samba -V 4.9.5
https://wiki.samba.org/index.php/Samba_4.12_Features_added/changed#smb.conf_.22write_cache_size.22
最后根据网上的资料 和我自己测试的结果,只有这两项是需要配置的。
https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html
min receivefile size = 16384
write cache size = 262144
基本上可以跑到满带宽。
版权声明:本文为movax21h原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。