https://blog.51cto.com/u_17048680/12160388

安装 sysbench

apt install sysbench

cpu测试

sysbench cpu --cpu-max-prime=20000 --threads=8 --time=30 run

内存测试

sysbench --test=memory --threads=12 --memory-block-size=8K --memory-total-size=100G run

内存性能测试

sysbench --test=memory --memory-block-size=8k --memory-total-size=4G run

–memory-block-size指定每个block的大小,–memory-total-size指定总的传输量,另外还有其他选项,可通过命令sysbench –test=memory help进行查看。

磁盘I/O性能测试

首先生成需要测试的文件

sysbench --test=fileio --num-threads=16 --file-num=2 --file-total-size=2G --file-test-mode=rndrw --file-rw-ratio=2 prepare

然后执行测试

sysbench --test=fileio --num-threads=16 --file-num=2 --file-total-size=2G --file-test-mode=rndrw --file-rw-ratio=2 run

最后清理测试文件

sysbench --test=fileio --num-threads=16 --file-num=2 --file-total-size=2G --file-test-mode=rndrw --file-rw-ratio=2 cleanup

–num-threads指定最大创建的线程数,–file-num指定文件数目,–file-taotal-size指定创建的文件总大小,–file-test-mode指定文件读写模式,rndrw为随机读,–file-rw-ratio指定读写比率。另外还有更多的选项可以通过命令sysbench –test=fileio help进行查看。

文档更新时间: 2025-04-29 02:38   作者:月影鹏鹏
IT运维支持-AIWALY-月影工作室