macOS 上的 SMB 速度非常慢

macOS 上的 SMB 速度非常慢

由于我最近买了一台新的 Mac Pro(运行 Catalina 10.15.2),我使用 10 GBit 以太网将它连接到我的 Debian 10/Proxmox 服务器。

但是,当连接到共享时,我只能获得 150-300 MB/s 的读/写性能。

这是我当前的 smb.conf:

[global]         
    netbios name = server         
    realm = MY.DOMAIN         
    security = ADS
    workgroup = MYDOMAIN

    wins server = my.domain.test

    winbind enum users = Yes
    winbind enum groups = Yes
    winbind use default domain = Yes
    winbind refresh tickets = Yes
    winbind nested groups = No


    idmap config MYDOMAIN:backend = ad
    idmap config MYDOMAIN:schema_mode = rfc2307
    idmap config MYDOMAIN:range = 10000-20000

    log file = /var/log/samba/log.%m
    log level = 1 
    printcap name = /etc/printcap
    load printers = no
    username map = etc/samba/user.map
    vfs objects = recycle acl_xattr catia fruit streams_xattr
    map acl inherit = yes
    store dos attributes = yes   
    oplocks = no

    # Enable the recycle bin
    recycle:repository = /tank/storage/.recycle/%U
    recycle:touch = Yes
    recycle:keeptree = Yes
    recycle:versions = Yes
    recycle:noversions = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
    recycle:exclude = *.tmp,*.temp,*.o,*.obj,*.TMP,*.TEMP
    recycle:excludedir = /recycle,/tmp,/temp,/TMP,/TEMP

    # Apple
    fruit:aapl = yes
    fruit:encoding = native
    fruit:locking = none
    fruit:metadata = stream
    fruit:resource = file


[share1]         
    path = /tank/share1
    read only = no       
    valid users = @"MYDOMAIN\share1-Access"
[share2]
    path = /tank/share2
    read only = no
    valid users = @"MYDOMAIN\share2-Access"
[timemachine]
    path = /tank/timemachine
    read only = no
    valid users = @"MYDOMAIN\timemachine-Access"
    oplocks = no
    fruit:aapl = yes
    fruit:time machine = yes
[downloads]
    path = /tank/downloads
    read only = no
    valid users = @"MYDOMAIN\downloads-Acccess"
[cloud-backup]
    path = /tank/cloud-backup
    read only = no
    writeable = yes
    valid users = @"MYDOMAIN\cloud-backup-Access"

答案1

macOS Big Sur 及更高版本上 SMB3 的实现具有多通道支持(参见此文章)。这有助于大大提高性能;但是,在 Samba 4.15 之前,server multi channel support = Yes/etc/samba/smb.conf 中的设置会导致每次安装了共享的客户端重新启动时都出现恐慌。

我一直在我的 macOS 客户端 (/etc/nsmb.conf) 上使用以下设置:

signing_required = no
protocol_vers_map=6
port445=no_netbios

我还在 Samba 中禁用了很多我不需要的功能:

[global]
allow dns updates = disabled
client min protocol = SMB3_11
dcerpc endpoint servers = rpcecho
delete veto files = Yes
disable netbios = Yes
disable spoolss = Yes
dns forwarder = 192.168.1.1
dns proxy = No
enhanced browsing = No
# Next line requires catia (needed if no Windows clients?)
fruit:encoding = native
fruit:metadata = stream
# Do not use NFS access control entries
fruit:nfs_aces = No
# Enable extended attributes (requires streams_xattr)
fruit:resource = xattr
# Next line is already the default
;fruit:zero_file_id = Yes
host msdfs = No
inherit acls = Yes
inherit permissions = Yes
lm announce = No
load printers = No
log file = /var/log/samba/log.smbd
log level = 1
logging = file
max log size = 10000
# Next 2 lines defer mDNS config to Avahi (better for icon and Time Machine)
mdns name = mdns
multicast dns register = No
name resolve order = host bcast
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = "*New Password:*" %n\n "*Reenter New Password:*" %n\n "*Password changed.*"
passwd program = /usr/bin/passwd %u
printcap cache time = 0
printcap name = /dev/null
printable = No
printing = bsd
restrict anonymous = 2
rpc_daemon:spoolssd = disabled
rpc_server:epmapper = disabled
rpc_server:winreg = disabled
rpc_server:lsarpc = disabled
rpc_server:samr = disabled
rpc_server:netlogon = disabled
rpc_server:netdfs = disabled
rpc_server:dssetup = disabled
rpc_server:wkssvc = disabled
rpc_server:spoolss = disabled
rpc_server:svcctl = disabled
rpc_server:ntsvcs = disabled
rpc_server:eventlog = disabled
rpc_server:initshutdown = disabled
rpc_server:mdssvc = disabled
server max protocol = SMB3_11
server min protocol = SMB3_11
# Next line experimental until 4.15 - macOS clients support multi-channel SMB3
;server multi channel support = Yes
server role = standalone server
server services = rpc, smb
server string = %h server (Samba 4.13.14, Ubuntu 21.10)
show add printer wizard = No
smb ports = 445
unix password sync = Yes
use sendfile = Yes
veto files = /._*/.DS_Store/
vfs objects = catia fruit streams_xattr

[homes]
browseable = No
comment = Home Directory
fruit:time machine = No
guest ok = No
spotlight = No
valid users = %S
writable = Yes

[Backup]
comment = Time Machine
fruit:time machine = Yes
guest ok = No
path = /external/%U
spotlight = No
valid users = %U
writable = Yes

将来,我计划重新启用服务器多通道支持。不想安装从源代码编译 Samba 4.15 所需的所有依赖项。

顺便说一句,我发现本文如果您使用 ZFS,那么这会很有趣(我根据以 tank/ 开头的目录名称怀疑这一点)。

答案2

SMB 在 Mac 上非常糟糕,而且一直如此。我的建议是:不要担心,只需安装 netatalk;您将毫无困难地获得 1GB/s。或者使用 NFS,它也会毫无问题地达到 1GB/s。然而,Netatalk 是最安全的选择,一些应用程序通过 NFS 可能会表现得很奇怪。此外,Netatalk 在身份验证、文件权限等方面的表现与 Samba 一致。

我甚至使用“Hackintoshes”比较过性能:同一台运行 Windows 的机器通过 SMB 可达到 900MB/s,但运行时为 250 MB/s;但通过 Appleshare 可达到 1GB/s。

相关内容