官术网_书友最值得收藏!

Performance tuning the Samba server

In this recipe, we will look at Samba configuration parameters in order to get optimum performance out of your Samba installation.

Getting ready

You will need root access or an account with sudo privileges.

It is assumed that you have installed the Samba server and it is properly working.

How to do it…

  1. Open the Samba configuration file located at /etc/samba/smb.conf:
    $ sudo vi /etc/samba/smb.conf
    
  2. Add or edit the following options under the global section of the configuration file:
    [global]
    log level = 1
    socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=131072 SO_SNDBUF=131072 SO_KEEPALIVE
    read raw = Yes
    write raw = Yes
    strict locking = No
    oplocks = yes
    max xmit = 65535
    dead time = 15
    getwd cache = yes
    aio read size = 16384
    aio write size = 16384
    use sendfile = true
  3. Save the configuration file and restart the Samba service:
    $ sudo service smbd restart
    

How it works…

The Samba server provides various configuration parameters. It uses TCP sockets to connect with clients and for data transfer. You should compare Samba's performance with similar TCP services such as FTP.

The preceding example lists some commonly used configuration options for Samba. Some of these options may work for you and some of them may not. The latest Samba version ships with default values for these options that work fairly well for common network conditions. As always, test these options one at a time or in a group, and benchmark each modification to get optimum performance.

The explanation for the preceding is as follows:

  • log level: The default log level is set to 0. Samba produces a lot of debugging information and writing all this to disk is a slow operation. Increasing the log level results in increased logs and poor performance. Unless you are debugging the server, it is good to have the log level set to the lowest value.
  • socket options: These are the TCP/IP stack level options.
  • read raw and write raw: These options enable Samba to use large read and writes to a network up to 64 KB in a single request. Some older clients may have issues with raw reads and writes. Check your setup before using these options.
  • dead time and so_keepalive: These options set periodic checks for dead connections and close such connections and free unused memory.
  • oplocks: This allows clients to cache files locally and results in overall performance improvement. The default setting disables oplocks.
  • aio read size and aio write size: This Asynchronous IO (AIO) allows Samba to read and write asynchronously when a file's size is bigger than the specified size values.

You can find various other options and respective explanations in the Samba manual pages. Use the following command to open the manual pages on your server:

$ man smbd
主站蜘蛛池模板: 香河县| 宁蒗| 朔州市| 文安县| 威信县| 永福县| 光泽县| 托里县| 北辰区| 资中县| 顺昌县| 瑞昌市| 清涧县| 当雄县| 唐山市| 周至县| 罗定市| 民县| 乌兰察布市| 铁岭市| 邵阳县| 峡江县| 平南县| 封丘县| 岳阳县| 漾濞| 丰城市| 东辽县| 仁怀市| 清远市| 阳朔县| 鲁甸县| 玉门市| 社会| 库尔勒市| 乌拉特后旗| 嫩江县| 舟山市| 霞浦县| 吴桥县| 宝山区|