AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 584487
Accepted
Gaia
Gaia
Asked: 2014-03-26 13:49:27 +0800 CST2014-03-26 13:49:27 +0800 CST 2014-03-26 13:49:27 +0800 CST

磁盘写入操作期间 CPU 使用率异常

  • 772

我有一个不错的 CentOS 6.5 专用主机(CentOS 6.5/E3-1230 3.2Ghz 四核 + HT/16GB/Software Raid 1 SATA II/ WD2503ABYX /ext4),默认 CentOS 内核和 grub 中的“elevator=deadline”。

I/O 写入操作会导致 CPU 使用率急剧上升。读取工作正常。例如,

dd if=/dev/zero of=test bs=1048576 count=2048

导致主机的 CPU 利用率飙升至 3 或 4 以上。在正常操作下,它保持在 0.40 以下,但当有一些更密集的 I/O 操作时,一切都会停止。

mpstat 1在这些dd测试中显示io 等待在 20-25%。

这是磁盘布局:

Disk /dev/sda: 251.1 GB, 251059544064 bytes
255 heads, 63 sectors/track, 30522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c6673

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sda2              26         548     4194304   fd  Linux raid autodetect
Partition 2 does not end on cylinder boundary.
/dev/sda3             548       30523   240775168   fd  Linux raid autodetect

Disk /dev/sdb: 251.1 GB, 251059544064 bytes
255 heads, 63 sectors/track, 30522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00095c99

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          26      204800   fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sdb2              26         548     4194304   fd  Linux raid autodetect
Partition 2 does not end on cylinder boundary.
/dev/sdb3             548       30523   240775168   fd  Linux raid autodetect

Disk /dev/md2: 246.6 GB, 246552588288 bytes
2 heads, 4 sectors/track, 60193503 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/md1: 4293 MB, 4293910528 bytes
2 heads, 4 sectors/track, 1048318 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/mapper/vg_main-LogVol00: 246.5 GB, 246549577728 bytes
255 heads, 63 sectors/track, 29974 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


Disk /dev/md0: 209 MB, 209702912 bytes
2 heads, 4 sectors/track, 51197 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

问题(高 CPU 使用率)在去年 12 月下旬的某个时候开始发生,这让我相信它与软件有关(磁盘 susbsystem 已由 DC 的人检查过)。

我接下来应该运行哪些测试来尝试隔离问题?

PS:我不是在寻找性能最大化技巧。服务器未充分利用。我只是想减少磁盘写入期间的 CPU 负载。

更新:问题重新设计以更好地描述问题。

更新:找到解决方案当我遇到这篇文章时,我终于发现了问题所在。

root> modprobe vhost_net root> echo vhost_net > /etc/modules

由于某种原因,virtio 接口之前没有加载驱动程序。现在一切都很好。

linux
  • 1 1 个回答
  • 2576 Views

1 个回答

  • Voted
  1. Best Answer
    Matthew Ife
    2014-03-26T13:58:31+08:002014-03-26T13:58:31+08:00

    在 CentOS 上,dirty_ratio设置为 20%。

    这意味着写出一个文件

    dd if=/dev/zero of=test bs=1048576 count=2048
    

    实际上将数据作为回写(最多 3.2GB)写入内存,而不是实际将其写入磁盘。

    它在 VM 上的速度较慢(但不是实际的性能基准),因为您可能为 VM 本身分配了低得多的内存分配(比如说 2G),这导致dirty_writeback在强制内容之前只提供约 400MB 的写回磁盘。

    如果您运行该命令,然后运行sync,您会注意到 sync 需要很长时间才能返回。

    您需要执行以下命令来运行您的命令,以更好地了解您的实际吞吐量。

    dd if=/dev/zero of=test oflag=sync bs=1048576 count=2048
    
    • 4

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve