主题 : 关于samba性能优化问题 复制链接 | 浏览器收藏 | 打印
级别: 风云使者
UID: 36096
精华: 3
发帖: 2513
金钱: 14075 两
威望: 2815 点
贡献值: 3 点
综合积分: 5086 分
注册时间: 2011-01-11
最后登录: 2015-11-15
楼主  发表于: 2012-09-01 09:31

 关于samba性能优化问题

暑假那会儿低价入了个x86的ION一代主板,正好手头上有硬盘、RAM条子,加上我们的电视当显示器就成了个HTPC,兼NAS(文件共享服务器之类的东西),


系统Ubuntu 12.04.1 桌面版,文件共享服务器软件用的是samba 3.6.3,用来存家里的照片和我自己的学习资料啥的。


不过目前发现一个比较烦人的问题,就是小文件传输很快,但大的(250MB以上)就慢,而且容易导致samba”间歇性假死“(卡住,速度极慢,然后又恢复回去,有时可能smbd进程直接死掉,但直接死掉发生概率很小很小)。后来谷歌一下,找到这个:http://niyunjiu.iteye.com/blog/661141


按照他说的搞了一下,貌似samba不再”装死“,但传输速度提升不明显,请问还有啥方案可以让samba更快吗?


我那台HTPC的配置如下:


CPU:板载Intel Atom N330 双核四线程


RAM 2GB DDR3 1066


硬盘:320GB


GPU:Nvidia Geforce 9400M


驱动都装好了,Kernel是Ubuntu apt软件仓库的3.2.0-30


附上我的smb.conf配置文件:


(放在下面,稍等就发上来)
极度缺钱,求捐赠……支付宝兼邮箱:huming2207@qq.com
级别: 风云使者
UID: 36096
精华: 3
发帖: 2513
金钱: 14075 两
威望: 2815 点
贡献值: 3 点
综合积分: 5086 分
注册时间: 2011-01-11
最后登录: 2015-11-15
1楼  发表于: 2012-09-01 09:32
samba配置文件

复制代码
  1. #======================= Global Settings =======================
  2. [global]
  3.    workgroup = WORKGROUP
  4.    server string = HuServer
  5. #   wins support = no
  6. ;   wins server = w.x.y.z
  7.    dns proxy = no
  8. ;   name resolve order = lmhosts host wins bcast
  9. #### Networking ####
  10. # The specific set of interfaces / networks to bind to
  11. # This can be either the interface name or an IP address/netmask;
  12. # interface names are normally preferred
  13. ;   interfaces = 127.0.0.0/8 eth0
  14. # Only bind to the named interfaces and/or networks; you must use the
  15. # 'interfaces' option above to use this.
  16. # It is recommended that you enable this feature if your Samba machine is
  17. # not protected by a firewall or is a firewall itself.  However, this
  18. # option cannot handle dynamic or non-broadcast interfaces correctly.
  19. ;   bind interfaces only = yes
  20. #### Debugging/Accounting ####
  21. # This tells Samba to use a separate log file for each machine
  22. # that connects
  23.    log file = /var/log/samba/log.%m
  24. # Cap the size of the individual log files (in KiB).
  25.    max log size = 1000
  26. # If you want Samba to only log through syslog then set the following
  27. # parameter to 'yes'.
  28. #   syslog only = no
  29. # We want Samba to log a minimum amount of information to syslog. Everything
  30. # should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
  31. # through syslog you should set the following parameter to something higher.
  32.    syslog = 0
  33. # Do something sensible when Samba crashes: mail the admin a backtrace
  34.    panic action = /usr/share/samba/panic-action %d
  35. ####### Authentication #######
  36. #   security = user
  37.    encrypt passwords = true
  38.    passdb backend = tdbsam
  39.    obey pam restrictions = yes
  40.    follow symlinks = no
  41.    use sendfile = yes
  42.    read raw = yes
  43.    write raw = yes
  44.    aio read size = 16384
  45.    aio write size = 16384
  46.    write cache size = 262144
  47.    max xmit = 65536
  48.    large readwrite = yes
  49.    getwd cache = yes
  50.    strict locking = no
  51.    fake oplocks = yes
  52.    oplocks = no
  53.    unix password sync = yes
  54.    passwd program = /usr/bin/passwd %u
  55.    passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
  56.    pam password change = yes
  57.    map to guest = bad user
  58. ########## Domains ###########
  59. ;   domain logons = yes
  60. ;   logon path = \\%N\profiles\%U
  61. # Another common choice is storing the profile in the user's home directory
  62. # (this is Samba's default)
  63. #   logon path = \\%N\%U\profile
  64. # The following setting only takes effect if 'domain logons' is set
  65. # It specifies the location of a user's home directory (from the client
  66. # point of view)
  67. ;   logon drive = H:
  68. #   logon home = \\%N\%U
  69. # The following setting only takes effect if 'domain logons' is set
  70. # It specifies the script to run during logon. The script must be stored
  71. # in the [netlogon] share
  72. # NOTE: Must be store in 'DOS' file format convention
  73. ;   logon script = logon.cmd
  74. # This allows Unix users to be created on the domain controller via the SAMR
  75. # RPC pipe.  The example command creates a user account with a disabled Unix
  76. # password; please adapt to your needs
  77. ; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
  78. # This allows machine accounts to be created on the domain controller via the
  79. # SAMR RPC pipe.  
  80. # The following assumes a "machines" group exists on the system
  81. ; add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u
  82. # This allows Unix groups to be created on the domain controller via the SAMR
  83. # RPC pipe.  
  84. ; add group script = /usr/sbin/addgroup --force-badname %g
  85. ########## Printing ##########
  86. # If you want to automatically load your printer list rather
  87. # than setting them up individually then you'll need this
  88. #   load printers = yes
  89. # lpr(ng) printing. You may wish to override the location of the
  90. # printcap file
  91. ;   printing = bsd
  92. ;   printcap name = /etc/printcap
  93. # CUPS printing.  See also the cupsaddsmb(8) manpage in the
  94. # cupsys-client package.
  95. ;   printing = cups
  96. ;   printcap name = cups
  97. ############ Misc ############
  98. # Using the following line enables you to customise your configuration
  99. # on a per machine basis. The %m gets replaced with the netbios name
  100. # of the machine that is connecting
  101. ;   include = /home/samba/etc/smb.conf.%m
  102. # Most people will find that this option gives better performance.
  103. # See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html
  104. # for details
  105. # You may want to add the following on a Linux system:
  106. #         SO_RCVBUF=8192 SO_SNDBUF=8192
  107. #   socket options = TCP_NODELAY
  108. # The following parameter is useful only if you have the linpopup package
  109. # installed. The samba maintainer and the linpopup maintainer are
  110. # working to ease installation and configuration of linpopup and samba.
  111. ;   message command = /bin/sh -c '/usr/bin/linpopup "%f" "%m" %s; rm %s' &
  112. # Domain Master specifies Samba to be the Domain Master Browser. If this
  113. # machine will be configured as a BDC (a secondary logon server), you
  114. # must set this to 'no'; otherwise, the default behavior is recommended.
  115. #   domain master = auto
  116. # Some defaults for winbind (make sure you're not using the ranges
  117. # for something else.)
  118. ;   idmap uid = 10000-20000
  119. ;   idmap gid = 10000-20000
  120. ;   template shell = /bin/bash
  121. # The following was the default behaviour in sarge,
  122. # but samba upstream reverted the default because it might induce
  123. # performance issues in large organizations.
  124. # See Debian bug #368251 for some of the consequences of *not*
  125. # having this setting and smb.conf(5) for details.
  126. ;   winbind enum groups = yes
  127. ;   winbind enum users = yes
  128. # Setup usershare options to enable non-root users to share folders
  129. # with the net usershare command.
  130. # Maximum number of usershare. 0 (default) means that usershare is disabled.
  131. ;   usershare max shares = 100
  132. # Allow users who've been granted usershare privileges to create
  133. # public shares, not just authenticated ones
  134.    usershare allow guests = yes
  135. #======================= Share Definitions =======================
  136. # Un-comment the following (and tweak the other settings below to suit)
  137. # to enable the default home directory shares. This will share each
  138. # user's home director as \\server\username
  139. ;[homes]
  140. ;   comment = Home Directories
  141. ;   browseable = no
  142. # By default, the home directories are exported read-only. Change the
  143. # next parameter to 'no' if you want to be able to write to them.
  144. ;   read only = yes
  145. # File creation mask is set to 0700 for security reasons. If you want to
  146. # create files with group=rw permissions, set next parameter to 0775.
  147. ;   create mask = 0700
  148. # Directory creation mask is set to 0700 for security reasons. If you want to
  149. # create dirs. with group=rw permissions, set next parameter to 0775.
  150. ;   directory mask = 0700
  151. # By default, \\server\username shares can be connected to by anyone
  152. # with access to the samba server. Un-comment the following parameter
  153. # to make sure that only "username" can connect to \\server\username
  154. # The following parameter makes sure that only "username" can connect
  155. #
  156. # This might need tweaking when using external authentication schemes
  157. ;   valid users = %S
  158. # Un-comment the following and create the netlogon directory for Domain Logons
  159. # (you need to configure Samba to act as a domain controller too.)
  160. ;[netlogon]
  161. [share]
  162. path = (此处略,防止隐私泄露,你懂的)
  163. available = yes
  164. browseable = yes
  165. public = yes
  166. writeable = yes
  167. create mode = 0777
  168. guest ok = no
  169. force create mode = 0777
  170. directory mode = 0777
  171. force directory mode = 0777
极度缺钱,求捐赠……支付宝兼邮箱:huming2207@qq.com
级别: 风云使者
UID: 36096
精华: 3
发帖: 2513
金钱: 14075 两
威望: 2815 点
贡献值: 3 点
综合积分: 5086 分
注册时间: 2011-01-11
最后登录: 2015-11-15
2楼  发表于: 2012-09-01 09:37
那个配置文件我是基于ubuntu原配的改来的,有点乱

明天开学了,唉……趁最后期限把这东西整明白,开学用着舒服点
极度缺钱,求捐赠……支付宝兼邮箱:huming2207@qq.com
级别: 骑士
UID: 29604
精华: 9
发帖: 171
金钱: 1830 两
威望: 366 点
贡献值: 9 点
综合积分: 522 分
注册时间: 2010-10-01
最后登录: 2016-04-13
3楼  发表于: 2012-09-02 10:39
还是windows用起来不纠结。
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
4楼  发表于: 2012-09-02 11:39

 回 3楼(benjaminwan) 的帖子

那Linux又纠结在哪儿呢
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 风云使者
UID: 36096
精华: 3
发帖: 2513
金钱: 14075 两
威望: 2815 点
贡献值: 3 点
综合积分: 5086 分
注册时间: 2011-01-11
最后登录: 2015-11-15
5楼  发表于: 2012-09-02 16:49
引用第3楼benjaminwan于2012-09-02 10:39发表的  :
还是windows用起来不纠结。
这smbfs文件共享是微软原创的非开源技术吧?貌似以前samba团队起诉过微软(借助GPL之类的开源规定),成功了,然后弄到了关键的技术,实用性大幅提升,但实际跟windows原生的比起来还是差一点。我这本来想用FTP做文件共享的(用vsftpd+最优化的配置,性能比这快samba多了),但windows explorer自带的ftp客户端功能不好用,如果再用第三方的客户端又太麻烦了,所以还是用samba。
极度缺钱,求捐赠……支付宝兼邮箱:huming2207@qq.com
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
贡献值: 71 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
6楼  发表于: 2012-09-02 19:02

 回 5楼(huhu2207) 的帖子

这个理由让我太失望了,难道你想一辈子被微软劫持吗?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 风云使者
UID: 36096
精华: 3
发帖: 2513
金钱: 14075 两
威望: 2815 点
贡献值: 3 点
综合积分: 5086 分
注册时间: 2011-01-11
最后登录: 2015-11-15
7楼  发表于: 2012-09-02 19:22

 Re:回 5楼(huhu2207) 的帖子

引用第6楼kasim于2012-09-02 19:02发表的 回 5楼(huhu2207) 的帖子 :
这个理由让我太失望了,难道你想一辈子被微软劫持吗?
Of couse not,but 的确他们的那个是稳定点
极度缺钱,求捐赠……支付宝兼邮箱:huming2207@qq.com