![经过身份验证的用户的 CIFS/SMB 文件传输速度很慢](https://linux22.com/image/1505302/%E7%BB%8F%E8%BF%87%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81%E7%9A%84%E7%94%A8%E6%88%B7%E7%9A%84%20CIFS%2FSMB%20%E6%96%87%E4%BB%B6%E4%BC%A0%E8%BE%93%E9%80%9F%E5%BA%A6%E5%BE%88%E6%85%A2.png)
如何配置 CIFS 以使本地和域用户拥有快速的传输速度?
我确实在使用 CIFS / SMB / Samba 与用户结合时遇到了大量性能问题。这与 Active Directory (AD) 的启用或禁用无关。本地用户和域用户的数据传输速度非常慢。作为来宾用户则没问题。
但是我无法弄清楚导致认证用户出现瓶颈的原因是什么?如何配置 Samba 以避免出现此问题?
CIFS/SMB 传输速度
User ----------- write ------------ read
Root ---------- 21.3MB/s -------- 21.8MB/s
Domain -------- 19.7MB/s -------- 19.4MB/s
Guest----------105.1MB/s ------- 101.2MB/s
(Root via AFP 109.7MB/s ------- 108.9MB/s)
使用 1GB 垃圾连续读写进行测试。
SMB4配置文件
[global]
server max protocol = SMB3_11
encrypt passwords = yes
dns proxy = no
strict locking = no
oplocks = yes
deadtime = 1
max log size = 51200
max open files = 588197
logging = file
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
getwd cache = yes
guest account = nobody
map to guest = Bad User
obey pam restrictions = yes
directory name cache size = 0
kernel change notify = no
panic action = /usr/local/libexec/samba/samba-backtrace
nsupdate command = /usr/local/bin/samba-nsupdate -g
server string = FreeNAS File Server
ea support = yes
store dos attributes = yes
lm announce = yes
acl allow execute always = true
dos filemode = yes
multicast dns register = yes
domain logons = no
idmap config *: backend = tdb
idmap config *: range = 90000001-100000000
server role = member server
workgroup = MYDOMAIN
realm = MYDOMAIN.LAN
security = ADS
client use spnego = yes
cache directory = /var/tmp/.cache/.samba
local master = no
domain master = no
preferred master = no
ads dns update = yes
winbind cache time = 7200
winbind offline logon = yes
winbind enum users = yes
winbind enum groups = yes
winbind nested groups = yes
winbind use default domain = no
winbind refresh tickets = yes
idmap config MYDOMAIN: backend = rid
idmap config MYDOMAIN: range = 20000-90000000
allow trusted domains = no
client ldap sasl wrapping = plain
template shell = /bin/sh
template homedir = /home/%D/%U
netbios name = S-FREENAS
pid directory = /var/run/samba
create mask = 0666
directory mask = 0777
client ntlmv2 auth = yes
dos charset = CP437
unix charset = UTF-8
log level = 1
[temp]
path = /mnt/zfs03/temp
printable = no
veto files = /.snapshot/.windows/.mac/.zfs/
writeable = yes
browseable = yes
vfs objects = zfs_space zfsacl aio_pthread streams_xattr catia fruit
hide dot files = yes
guest ok = yes
nfs4:mode = special
nfs4:acedup = merge
nfs4:chown = true
zfsacl:acesort = dontcare
以 root 身份传输时的 TOP:
last pid: 46255; load averages: 0.81, 0.49, 0.39 up 2+01:33:28 10:49:23
45 processes: 3 running, 42 sleeping
CPU: 11.7% user, 0.0% nice, 0.9% system, 0.0% interrupt, 87.4% idle
Mem: 273M Active, 3125M Inact, 15G Wired, 230M Cache, 734M Free
ARC: 14G Total, 985M MFU, 12G MRU, 290K Anon, 63M Header, 202M Other
Swap: 8192M Total, 148K Used, 8191M Free
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
46144 root 1 102 0 337M 29744K CPU4 4 1:46 100.00% smbd
2443 root 1 -52 r0 6304K 2272K CPU1 1 13:39 0.10% watchdogd
11480 root 12 21 0 241M 20348K nanslp 1 18:20 0.00% collectd
4655 root 6 21 0 409M 183M select 7 7:11 0.00% python2.7
19466 root 1 52 0 237M 64044K select 7 2:46 0.00% python2.7
2779 root 1 20 0 36500K 18216K select 5 0:56 0.00% ntpd
1919 root 1 20 0 79388K 5024K kqread 3 0:16 0.00% syslog-ng
以访客身份转机时使用 TOP
last pid: 46439; load averages: 0.91, 0.68, 0.49 up 2+01:37:13 10:53:08
45 processes: 1 running, 44 sleeping
CPU: 0.8% user, 0.0% nice, 3.6% system, 1.9% interrupt, 93.7% idle
Mem: 273M Active, 3125M Inact, 15G Wired, 230M Cache, 734M Free
ARC: 14G Total, 1332M MFU, 13G MRU, 8994K Anon, 64M Header, 203M Other
Swap: 8192M Total, 148K Used, 8191M Free
PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
46407 root 1 46 0 337M 29760K select 4 0:14 38.09% smbd
11480 root 12 21 0 241M 20380K nanslp 3 18:22 0.20% collectd
19466 root 1 52 0 237M 64044K select 6 2:46 0.20% python2.7
2443 root 1 -52 r0 6304K 2272K nanslp 2 13:40 0.10% watchdogd
4655 root 6 20 0 409M 183M select 6 7:15 0.00% python2.7
2779 root 1 20 0 36500K 18216K select 3 0:56 0.00% ntpd
硬件
- 华擎 C2750D4I
- 英特尔八核 Avoton C2750
- 16GB DDR3 1600 ECC 内存 4
- WD Red Pro 4TB(2 个条纹镜子)
- 1GB/秒局域网
- FreeNAS OS 9.10.1
- 32GB USB2.0 记忆棒