Sysbench 是一个开源的多用途基准测试实用程序,用于评估 CPU、内存、I/O 和数据库 (MySQL) 性能的参数特性测试。该工具对于 MySQL 参数测试非常重要,尤其是在运行密集型数据库负载时。
系统环境
安装sysbench
首先安装epel源,然后进行安装sysbench
[root@server1 ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/epel-release-latest-8.noarch.rpm
[root@server1 ~]# yum -y install sysbench

使用 sysbench 工具执行 CPU 基准测试
要评估 CPU 性能,请使用以下命令进行 CPU 基准测试:
[root@server1 ~]# sysbench --test=cpu run

完整的报表统计会显示在终端上,但这里重要的是total time会显示在General statistics下,用于测试CPU性能。
还可以使用以下命令获取 CPU 基准测试选项:
[root@server1 ~]# sysbench --test=cpu help

命令参数可以根据你的要求进行修改。例如,使用以下命令对 CPU 性能进行基准测试:
[root@server1 ~]# sysbench --test=cpu --cpu-max-prime=20000 run

使用 sysbench 工具对内存进行基准测试
要测试内存性能,请在终端上键入以下基本命令:
[root@server1 ~]# sysbench --test=memory run

可以通过检查Total operations和传输数据量这两个参数来测试内存性能。
news.yesky.com/hotnews/90/309819090.shtml
www.donews.com/news/detail/4/2977560.html
使用下面命令查看和测试内存性能相关的选项:
[root@server1 ~]# sysbench --test=memory help

使用 sysbench 工具对 I/O 进行基准测试
I/O 性能测试与 CPU 和内存测试略有不同。在文件 I/O 测试中,需要创建一个大于 RAM 大小的测试文件。一般的顺序写入 I/O 性能测试可以使用以下命令完成:
[root@server1 ~]# sysbench --test=fileio --file-test-mode=seqwr run

使用下面命令获取I/O测试的更多选项:
[root@server1 ~]# sysbench --test=fileio --file-test-mode=seqwr help

上面显示许多选项。只需根据你的要求设置参数值,并测试你的 Linux 系统的 I/O 性能。
性能测试完成后,使用以下命令删除测试文件:
[root@server1 ~]# sysbench --test=fileio cleanup

总结
在本教程中,我们描述了如何在 Linux 系统上安装 sysbench 实用程序以及如何测试系统的 CPU、内存和 I/O 的性能。
网友评论