对通过 WAN 连接在 SUSE Multi-Linux Manager Server 与 Proxy 之间同步时间过长的问题进行查错

Depending on what changes are executed in the WebUI or via an API call to distribution or system settings, cobbler sync command may be required to transfer files from SUSE Multi-Linux Manager Server to SUSE Multi-Linux Manager Proxy systems. To accomplish this, Cobbler uses a list of proxies specified in /etc/cobbler/settings.

Due to its design, cobbler sync is not able to sync only the changed or recently added files.

Instead, executing cobbler sync triggers a full sync of the /srv/tftpboot directory to all specified proxies configured in /etc/cobbler/settings. It is also influenced by the latency of the WAN connection between the involved systems.

The process of syncing may take a considerable amount of time to finish according to the logs in /var/log/cobbler/.

例如,该过程开始时间为:

Thu Jun  3 14:47:35 2021 - DEBUG | running python triggers from /var/lib/cobbler/triggers/task/sync/pre/*
Thu Jun  3 14:47:35 2021 - DEBUG | running shell triggers from /var/lib/cobbler/triggers/task/sync/pre/*

结束时间为:

Thu Jun  3 15:18:49 2021 - DEBUG | running shell triggers from /var/lib/cobbler/triggers/task/sync/post/*
Thu Jun  3 15:18:49 2021 - DEBUG | shell triggers finished successfully

传输量大约为 1.8 GB。传输花费了将近 30 分钟。

By comparison, copying a single big file of the same size as /srv/tftboot completes within several minutes.

Switching to an rsync-based approach to copy files between SUSE Multi-Linux Manager Server and Proxy may help to reduce the transfer and wait times.

The script does not accept command line options. Before running the script, you need to manually edit it and set correctly MLMHOSTNAME, MLMIP and MLMPROXY1 variables for it to work correctly.

不支持调整该脚本的个别设置。该脚本及其包含的注释旨在提供传输过程以及要考虑的步骤的概述。如需进一步的帮助,请联系 SUSE 咨询部门。

对于以下情况,最好使用建议的脚本用法:

  • SUSE Multi-Linux Manager 代理系统是通过 WAN 连接的;

  • /srv/tftboot contains a high number of files for distributions and client PXE boot files, in total several thousand files;

  • Any proxy in /etc/cobbler/settings has been disabled, otherwise SUSE Multi-Linux Manager will continue to sync content to the proxies.

    #proxies:
    # - "MLMproxy.MLMproxy.test"
    # - "MLMproxy2.MLMproxy.test"
过程:分析新的同步速度
  1. 为 SUSE Multi-Linux Manager 与相关系统之间的 TCP 流量创建转储。

    • 在 SUSE Multi-Linux Manager 服务器上:

      tcpdump -i ethX -s 200 host <SUSE Manager Proxy 的 IP 地址> and not ssh
    • 在 SUSE Multi-Linux Manager 代理上:

      tcpdump -i ethX -s 200 host <SUSE Manager 的 IP 地址> and not ssh
    • 这样就只会捕获大小为 200 的软件包,但足以运行分析。

    • 将 ethX 调整为由 SUSE Multi-Linux Manager 用来与代理通信的相应网络接口。

    • 最后,不会捕获 ssh 通信,从而进一步减少了软件包的数量。

  2. Start a cobbler sync.

    • To force a sync, delete the Cobbler json cache file first and then issue cobbler sync:

      rm /var/lib/cobbler/pxe_cache.json
      cobbler sync
  3. When {command]cobbler sync is finished, stop the TCPdumps.

  4. Open the TCPdumps using Wireshark, go to Statistics > Conversations and wait for the dump to be analyzed.

  5. 切换到“TCP”选项卡。此选项卡上显示的数字是在 SUSE Multi-Linux Manager 服务器与 SUSE Multi-Linux Manager 代理之间捕获的对话总数。

  6. Look for the column Duration.

    • 首先按升序排序,找出传输文件所花费的最短时间。

    • 继续按降序排序,找出大文件传输时间的最大值,例如内核和 initrd 传输。

      忽略端口 4505 和 4506,因为它们用于 Salt 通信。

TCPdumps 分析结果表明,将大小约为 1800 字节的小文件从 SUSE Multi-Linux Manager Server 传输到 Proxy 大约花费了 0.3 秒。

此处的大文件不多,而大量的小文件导致建立了大量连接,因为每传输一个文件就要创建新的 TCP 连接。

因此,在知道最短传输时间和所需连接数(在本示例中大约为 5000)的情况下,可以大致估算出总传输时间:5000 * 0.3 / 60 = 25 分钟。