发布于 2023-07-21 13:52:06 来源:衡天主机 作者:衡天编辑组
在 Linux 中,你可以使用 speedtest-cli
和 fio
这两个工具来测试网速和磁盘 IO 性能。
speedtest-cli
: 一个命令行工具,用于测试网络连接的速度。可以通过以下命令进行安装:
bash<button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; touch-action: manipulation; margin: 0px 0px 0px auto; color: #e8e8e8; font-size: 12px; font-family: inherit; line-height: inherit; overflow: visible; appearance: button; font-weight: inherit; padding: 0px; background-image: none; cursor: pointer; display: flex; gap: 0.5rem; background-color: rgba(255, 0, 0, 0); border: 0px solid #d9d9e3;"><textarea style="box-sizing: border-box; border-style: initial; border-color: white; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; appearance: none; touch-action: manipulation; margin: 0px; color: rgba(255, 255, 255, 0); font-size: 1rem; font-family: inherit; line-height: 1.5rem; overflow: hidden; resize: none; font-weight: inherit; padding: 0.5rem 0.75rem; background-color: rgba(255, 0, 0, 0); border-radius: 0px; z-index: -9; width: 0px; height: 0px; position: absolute;"></textarea>复制</button>
pip install speedtest-cli
安装完成后,使用以下命令进行测试:
bash<button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; touch-action: manipulation; margin: 0px 0px 0px auto; color: #e8e8e8; font-size: 12px; font-family: inherit; line-height: inherit; overflow: visible; appearance: button; font-weight: inherit; padding: 0px; background-image: none; cursor: pointer; display: flex; gap: 0.5rem; background-color: rgba(255, 0, 0, 0); border: 0px solid #d9d9e3;"><textarea style="box-sizing: border-box; border-style: initial; border-color: white; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; appearance: none; touch-action: manipulation; margin: 0px; color: rgba(255, 255, 255, 0); font-size: 1rem; font-family: inherit; line-height: 1.5rem; overflow: hidden; resize: none; font-weight: inherit; padding: 0.5rem 0.75rem; background-color: rgba(255, 0, 0, 0); border-radius: 0px; z-index: -9; width: 0px; height: 0px; position: absolute;"></textarea>复制</button>
speedtest-cli
运行命令后,它将连接到最近的服务器,并测量你的网络带宽的下载和上传速度。
fio
: 一个用于测试磁盘 IO 性能的强大工具。可以通过以下命令进行安装:
bash<button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; touch-action: manipulation; margin: 0px 0px 0px auto; color: #e8e8e8; font-size: 12px; font-family: inherit; line-height: inherit; overflow: visible; appearance: button; font-weight: inherit; padding: 0px; background-image: none; cursor: pointer; display: flex; gap: 0.5rem; background-color: rgba(255, 0, 0, 0); border: 0px solid #d9d9e3;"><textarea style="box-sizing: border-box; border-style: initial; border-color: white; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; appearance: none; touch-action: manipulation; margin: 0px; color: rgba(255, 255, 255, 0); font-size: 1rem; font-family: inherit; line-height: 1.5rem; overflow: hidden; resize: none; font-weight: inherit; padding: 0.5rem 0.75rem; background-color: rgba(255, 0, 0, 0); border-radius: 0px; z-index: -9; width: 0px; height: 0px; position: absolute;"></textarea>复制</button>
sudo apt-get install fio # 对于基于 Debian 的系统,如 Ubuntu
sudo yum install fio # 对于基于 Red Hat 的系统,如 CentOS
安装完成后,可以使用 fio
命令执行各种 IO 测试。例如,可以使用以下命令运行顺序读取测试:
bash<button class="flex ml-auto gap-2" style="--tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; touch-action: manipulation; margin: 0px 0px 0px auto; color: #e8e8e8; font-size: 12px; font-family: inherit; line-height: inherit; overflow: visible; appearance: button; font-weight: inherit; padding: 0px; background-image: none; cursor: pointer; display: flex; gap: 0.5rem; background-color: rgba(255, 0, 0, 0); border: 0px solid #d9d9e3;"><textarea style="box-sizing: border-box; border-style: initial; border-color: white; --tw-border-spacing-x: 0; --tw-border-spacing-y: 0; --tw-translate-x: 0; --tw-translate-y: 0; --tw-rotate: 0; --tw-skew-x: 0; --tw-skew-y: 0; --tw-scale-x: 1; --tw-scale-y: 1; --tw-scroll-snap-strictness: proximity; --tw-ring-offset-width: 0px; --tw-ring-offset-color: #fff; --tw-ring-color: rgba(59,130,246,0.5); --tw-ring-offset-shadow: 0 0 transparent; --tw-ring-shadow: 0 0 transparent; --tw-shadow: 0 0 transparent; --tw-shadow-colored: 0 0 transparent; appearance: none; touch-action: manipulation; margin: 0px; color: rgba(255, 255, 255, 0); font-size: 1rem; font-family: inherit; line-height: 1.5rem; overflow: hidden; resize: none; font-weight: inherit; padding: 0.5rem 0.75rem; background-color: rgba(255, 0, 0, 0); border-radius: 0px; z-index: -9; width: 0px; height: 0px; position: absolute;"></textarea>复制</button>
fio --name=random-read --ioengine=libaio --iodepth=1 --rw=randread --bs=4k --direct=0 --size=1G --numjobs=1 --runtime=60 --group_reporting
运行命令后,它将对磁盘进行随机读取测试,并输出测试结果。
请注意,在使用这些命令之前,确保已经安装了相应的工具,并且具有适当的权限。此外,还可以根据需要调整命令的参数和选项,以满足你的测试需求。