本文主要介绍三种收集VMware ESXi日志包的方法
在日常运维VMware ESXi时,日志是排查故障、分析问题的重要工具。无论是ESXi主机性能异常、存储连接问题,还是虚拟机故障,获取完整的日志包都是定位问题的关键步骤。本篇文章将详细介绍三种收集ESXi日志的方法,涵盖vSphere客户端、ESXi主机客户端和命令行方式,帮助您快速获取所需的日志数据,以便进一步分析和解决问题。
方法一、通过vSphere客户端
第1步,访问vSphere客户端(即vCenter Server的域名或IP地址),并根据提示输入管理员的账户和密码后进行登录

第2步,在主机清单界面,选择要收集日志的主机,然后右键选择“导出系统日志”

第3步,在导出系统日志页面,点击“导出日志”

第4步,确认日志包已经开始下载

第5步,确认日志包下载完毕。

方法二、通过ESXi主机客户端
第1步,访问ESXi主机客户端(即ESXi的域名或管理IP地址),并根据提示输入管理的账户和密码后登录

第2步,在ESXi主机客户端主页,选择主机,然后右键选择“生成支持包”

第3步,若有弹出授权验证页面,再次输入管理员的账户和密码进行登录

第4步,确认已经开始下载日志包

第5步,确认日志包下载完毕

方法三、通过ESXi主机命令行
第1步,访问ESXi主机的命令行,具体步骤请参考:《如何开启VMware ESXi的SSH和Shell服务》

第2步,运行如下命令开始收集ESXi的日志包
[root@esxi-02:~] vm-support

第3步,确认日志收集完毕

第4步,根据提示确认日志的保存位置,使用WinScp工具下载日志包,关于WinSCP软件的下载和连接esxi的具体步骤请【>>点这里<<】



第5步,确认日志包下载完毕

附:可以通过vm-support –help的命令查看vm-support的其它用法,比如可以在vm-support 命令后添加-w /路径/ 指定日志包的保存位置。
[root@esxi-02:~] vm-support --help
usage: vm-support [-h] [-g GROUPS] [-a MANIFESTS] [-e EXCLUDEMANIFESTS] [--manifestdir MANIFESTDIR] [-w WORKINGDIR] [-s] [-E ERRORFILE] [-l] [-z] [-o]
[--listmanifests] [-G] [-t] [-p] [-d DURATION] [-i INTERVAL] [-v VM] [-V] [--action-threads ACTIONTHREADS] [-L] [-D] [-q]
[--loglevel LOGLEVEL] [--version] [--allow-infinite-actions] [--default-timeout DEFAULTTIMEOUT] [--ignore-timeouts] [-r DIRECTORY]
[-x BUNDLE [DIRECTORY ...]]
optional arguments:
-h, --help show this help message and exit
Input:
-g GROUPS, --groups GROUPS
Specify manifest groups. See --listgroups.
-a MANIFESTS, --manifests MANIFESTS
Specify manifest files. See --listmanifests.
-e EXCLUDEMANIFESTS, --excludemanifests EXCLUDEMANIFESTS
Exclude the listed manifests. See --listmanifests.
--manifestdir MANIFESTDIR
Location to search for manifest files.
Output:
-w WORKINGDIR, --workingdir WORKINGDIR
Archive destination.
-s, --stream Stream data to stdout.
-E ERRORFILE, --errorfile ERRORFILE
Prints (non-fatal) errors to specified file (overrides --quiet and --stream).
-l, --listfiles At the end print all gathered files.
-z, --zip Archive bundle in zip format. Default is a gzipped tar archive.
-o, --obfuscate Obfucate hostname in archive path.
List:
--listmanifests List available manifests.
-G, --listgroups List available manifest groups.
-t, --listtags List available manifest tags.
Perfomance measurement:
-p, --performance Gather performance data.
-d DURATION, --duration DURATION
Duration of performance monitoring (in seconds).
-i INTERVAL, --interval INTERVAL
Interval between performance snapshots (in seconds).
VM options:
-v VM, --vm VM Gather detailed information about this specific VM (ie --vm <path to .vmx file>)
-V, --listvms List registered VMs.
Parallel execution:
--action-threads ACTIONTHREADS
Specify the number of actions that will run in parallel.
-L, --legacy Run in legacy mode (no parallel execution).
Misc:
-D, --dryrun Prints out the data that would have been gathered.
-q, --quiet Output only the location of the bundle.
--loglevel LOGLEVEL Set logging to specified level: 0-50 (0=most verbose).
--version Display the version.
--allow-infinite-actions
Wait indefinitely for actions to finish. Use with caution.
--default-timeout DEFAULTTIMEOUT
Set default timeout (300s) for actions without a specified TIMEOUT option. It is ignored when --allow-infinite-actions is used.
--ignore-timeouts Ignore TIMEOUTs as specified in manifest files and use the default timeout.
Reconstruct vm-support bundle:
-r DIRECTORY, --reconstruct DIRECTORY
Unfragment a support bundle directory.
-x BUNDLE [DIRECTORY ...], --extract BUNDLE [DIRECTORY ...]
Extract and reconstruct support bundle.
[root@esxi-02:~]
通过本文介绍的三种方法,您可以轻松收集VMware ESXi的日志包,无论是通过vSphere客户端、ESXi主机客户端,还是直接使用命令行方式,都能满足不同场景下的需求。掌握这些方法,不仅有助于快速定位和解决故障,还能提高日常运维的效率。如果您在日志收集过程中遇到问题,欢迎在评论区交流或查阅相关技术文档获取更多支持。