当前位置: 首页 > news >正文

西安网站设计公司排名网页设计课程速成班

西安网站设计公司排名,网页设计课程速成班,谷歌优化培训,网站建设岗位有哪些1. IO处理过程磁盘IO经常会成为系统的一个瓶颈#xff0c;特别是对于运行数据库的系统而言。数据从磁盘读取到内存#xff0c;在到CPU缓存和寄存器#xff0c;然后进行处理#xff0c;最后写回磁盘#xff0c;中间要经过很多的过程#xff0c;下图是一个以write为例的 Li…1. IO处理过程磁盘IO经常会成为系统的一个瓶颈特别是对于运行数据库的系统而言。数据从磁盘读取到内存在到CPU缓存和寄存器然后进行处理最后写回磁盘中间要经过很多的过程下图是一个以write为例的 Linux 磁盘IO子系统的架构可以看到IO操作分成了四个层面1)文件系统缓存处理数据必须先从磁盘读到缓存然后修改然后刷会磁盘。缓存的刷新涉及到两个参数vm.dirty_background_ratio、vm.dirty_ratio。还有刷新写回时使用到 bio 结构bio的组成是由磁盘上相邻的block组成的所以这里进行了优化。2)block layer该层就涉及到 IO调度算法IO调度算法在mysql服务器是一个很重要的调优手段。系统中所有进程申请的IO操作全部在这里进行排队等待调度然后写回磁盘。调度算法有四种1 Anticipatory: 适用于个人PC单磁盘系统2 CFQ(Complete Fair Queuing)默认的IO调度算法完全公平的排队调度算法。每一个进程的IO请求会安排进一个专门的IO队列然后按照进程组来公平的调度IO也就是每一个进程组之间按照公平的方式来调度IO。显然他适合多用户的系统但是极为不适合作为数据库系统的IO调度算法因为显而易见数据库系统中数据库进程肯定是IO最多的一个进程组然后它却只能获得和其它进程一样多的IO调度机会。所以显然这是极为不合理的。数据库系统绝对不要使用该调度算法。3 Deadline: 按照截止期限来循环在各个IO队列中进行调度所以它提供了一个近实时的IO系统并且磁盘throughput也很好也不会造成starvation.一般mysql系统建议采用该调度算法。4 NOOP: 简单的FIFO队列进行调度No operation的意思是它没有进行额外的将临近的IO进行合并的操作所以它对CPU的使用极少。该调度算法特别适合于SSD。因为SSD在对待顺序IO和随机IO没有什么区别。所以它不需要对临近的IO进行合并。避免了合并操作对CPU的使用。所以一般而言对于mysql的系统如果是SSD那么应该使用NOOP调度算法如果是磁盘就应该使用Deadline调度算法。查看与修改IO调度算法临时修改[rootlocalhost ~]# cat /sys/block/sda/queue/schedulernoop anticipatory deadline [cfq][rootlocalhost ~]# echo noop /sys/block/sda/queue/scheduler[rootlocalhost ~]# cat /sys/block/sda/queue/scheduler[noop] anticipatory deadline cfq永久修改# vi /boot/grub/menu.lst更改到如下内容:kernel /boot/vmlinuz-2.6.18-8.el5 ro rootLABEL/ elevatordeadline rhgb quiet重启之后,查看调度方法:# cat /sys/block/sda/queue/schedulernoop anticipatory [deadline] cfq已经是deadline了3)磁盘驱动层对于顺序读系统而言很容易在磁盘接口层的带宽上成为瓶颈所在4)磁盘对于随机读多的系统而言磁盘很容易成为瓶颈所在一般的优化就是使用RAID或者换SSD2. IO瓶颈检测2.1 使用 iostat 查看磁盘IO显示单位问题默认iostat是以磁盘的block为单位也可以使用 -k 来指定以 kilobytes 为单位或者使用 -m 指定 megabytes 为单位统计开始时间问题默认iostat和vmstat相似默认第一次/行都是从开机到目前的一个数据可以使用 -y 选项去掉第一次/行的数据CPU与磁盘 iostat 默认会显示cpu和磁盘的数据如果只要cpu数据可以使用 -c 选项如果只需要磁盘数据可以使用 -d 选项时间间隔和重复次数[interval [times]] 表示磁盘统计数据的间隔时间和次数-x : 该选项显示具体的扩展信息[rootlocalhost ~]# iostatLinux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)avg-cpu: %user %nice %system %iowait %steal %idle0.60 0.00 7.80 0.31 0.00 91.30Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnscd0 0.02 0.21 0.00 536 0sda 2.00 78.60 8.43 198702 21312[rootlocalhost ~]# iostat -cLinux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)avg-cpu: %user %nice %system %iowait %steal %idle0.48 0.00 6.51 0.25 0.00 92.76[rootlocalhost ~]# iostat -d -kLinux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtnscd0 0.02 0.08 0.00 268 0sda 1.69 31.17 4.15 99363 13224[rootlocalhost ~]# iostat -d -mLinux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtnscd0 0.02 0.00 0.00 0 0sda 1.69 0.03 0.00 97 12[rootlocalhost ~]# iostat -d -m -xLinux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilscd0 0.02 0.00 0.02 0.00 0.00 0.00 10.94 0.00 4.96 4.88 0.01sda 1.22 0.48 1.13 0.56 0.03 0.00 41.66 0.01 6.83 5.27 0.89[rootlocalhost ~]# iostat -d -m -x 2 3Linux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilscd0 0.02 0.00 0.01 0.00 0.00 0.00 10.94 0.00 4.96 4.88 0.01sda 1.19 0.48 1.10 0.55 0.03 0.00 41.52 0.01 6.81 5.25 0.87Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilscd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilscd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda 0.00 0.00 0.00 0.51 0.00 0.00 8.00 0.00 3.00 3.00 0.15[rootlocalhost ~]# iostat -y -d -m -x 2 3Linux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilscd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilscd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilscd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00字段含义Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn 分别表示每秒读取block的个数每秒写block的个数总共读了多少个block总共写了多少个blocktps: Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device. Multiple logical requests can be combined into a single I/O request to the device. A transfer is of indeterminate size.(就是对磁盘每秒请求多少次IO操作)rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilrrqm/s wrqm/s 表示的磁盘读和写时每秒发生多少次相邻磁盘的merge操作rrqm: read request merge; wrqm:write request merger/s w/s 表示每秒读的次数写的次数rMB/s wMB/s 表示每秒读多少MB写多少MBavgrq-szThe average size (in sectors) of the requests that were issued to the device. 平均一个IO请求涉及到多少个sectoravgqu-szThe average queue length of the requests that were issued to the device. IO队列的平均长度该数值很重要。awaitThe average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.平均每一个IO花费了多少毫秒(包括在IO队列中的排队时间和读写操作花费的时间)。这里可以理解为IO的响应时间一般地系统IO响应时间应该低于5ms如果大于10ms就比较大了。svctm弃用%util Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%. 在统计时间内所有处理IO时间除以总共统计时间。例如如果统计间隔1秒该设备有0.8秒在处理IO而0.2秒闲置那么该设备 的%util 0.8/1 80%所以该参数暗示了设备的繁忙程度。一般地如果该参数是100%表示设备已经接近满负荷运行了(当然如果是多磁盘即使%util是100%因 为磁盘的并发能力所以磁盘使用未必就到了瓶颈)。CPU的 %iowait io等待很高磁盘的 avgqu-sz数值很大await数值很高%util数值很高都可能预示着磁盘存在瓶颈或者磁盘出现问题或者故障。2.2 使用 iostat 查看磁盘每个分区的IO上面查看的都是整个磁盘的IO情况下面的命令可以查看具体某个磁盘的所有分区的IO情况[rootlocalhost ~]# iostat -x -d -m -p sda 2 3Linux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilsda 0.82 0.43 0.76 0.52 0.02 0.00 38.49 0.01 6.27 4.82 0.62sda1 0.80 0.42 0.53 0.51 0.02 0.00 45.09 0.01 6.92 5.50 0.57sda2 0.01 0.02 0.12 0.01 0.00 0.00 9.70 0.00 2.95 2.79 0.04sda3 0.01 0.00 0.07 0.00 0.00 0.00 8.67 0.00 3.72 3.65 0.03Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilsda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await svctm %utilsda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda2 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00sda3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00[rootlocalhost ~]# iostat -d -m -p sda 2 3Linux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtnsda 1.25 0.02 0.00 97 18sda1 1.02 0.02 0.00 92 17sda2 0.13 0.00 0.00 2 0sda3 0.07 0.00 0.00 1 0Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtnsda 0.00 0.00 0.00 0 0sda1 0.00 0.00 0.00 0 0sda2 0.00 0.00 0.00 0 0sda3 0.00 0.00 0.00 0 0Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtnsda 0.00 0.00 0.00 0 0sda1 0.00 0.00 0.00 0 0sda2 0.00 0.00 0.00 0 0sda3 0.00 0.00 0.00 0 02.3 使用 vmstat 查看磁盘IO[rootlocalhost ~]# vmstat 2 4procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu-----r b swpd free buff cache si so bi bo in cs us sy id wa st0 0 0 454900 21808 76776 0 0 20 4 97 81 0 5 95 0 00 0 0 454892 21808 76772 0 0 0 8 83 106 0 3 97 0 01 0 0 454760 21816 76772 0 0 0 44 101 153 1 5 94 0 00 0 0 454760 21816 76784 0 0 0 0 57 68 0 1 99 0 0bi: Blocks received from a block device (blocks/s). 每秒读取多少个block到内存bo: Blocks sent to a block device (blocks/s). 每秒内存写出多少个block到磁盘2.4 使用 sar -b 查看磁盘IO[rootlocalhost ~]# sar -b 2 4Linux 2.6.32-504.el6.i686 (localhost.localdomain) 10/09/2015 _i686_ (1 CPU)03:53:21 PM tps rtps wtps bread/s bwrtn/s03:53:23 PM 0.00 0.00 0.00 0.00 0.0003:53:25 PM 0.00 0.00 0.00 0.00 0.0003:53:27 PM 0.00 0.00 0.00 0.00 0.0003:53:29 PM 0.00 0.00 0.00 0.00 0.00Average: 0.00 0.00 0.00 0.00 0.00tps: 上面有介绍rtps: 表示读的tpswtps: 表示写的tps;bread/s: 每秒读多少个blockbwrtn/s: 每秒写多少个block;2.5 使用 iotop 找到IO最多的进程/线程iotop类似于top命令默认按照IO排序iotop :iotop 是可以交互的Use the left and right arrows to change the sorting, r to reverse the sorting order, o to toggle the --onlyoption, p to toggle the --processes option, a to toggle the --accumulated option, q to quit or i to change thepriority of a thread or a process’ thread(s). Any other key will force a refresh.1)利用左右键 可以选择排序的字段默认按照IO倒序可以按照SWAPINDISK WRITE 等等字段排序使用左右方向键即可2)利用 p键 可以在按照 进程显示 和按照 线程显示之间切换3)r 键可以改变排序的方向倒序 和 顺序查看mysqld的IOiotop -k -u mysql (-k 表示KB-u mysql表示显示mysql用户的所有进程的IO):3. 实例分析$iostat -d -k 1 |grep sda10Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtnsda10 60.72 18.95 71.53 395637647 1493241908sda10 299.02 4266.67 129.41 4352 132sda10 483.84 4589.90 4117.17 4544 4076sda10 218.00 3360.00 100.00 3360 100sda10 546.00 8784.00 124.00 8784 124sda10 827.00 13232.00 136.00 13232 136上面看到磁盘每秒传输次数平均约400每秒磁盘读取约5MB写入约1MB。iostat -d -x -k 1Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %utilsda 1.56 28.31 7.84 31.50 43.65 3.16 21.82 1.58 1.19 0.03 0.80 2.61 10.29sda 1.98 24.75 419.80 6.93 13465.35 253.47 6732.67 126.73 32.15 2.00 4.70 2.00 85.25sda 3.06 41.84 444.90 54.08 14204.08 2048.98 7102.04 1024.49 32.57 2.10 4.21 1.85 92.24可以看到磁盘的平均响应时间5ms磁盘使用率80。磁盘响应正常但是已经很繁忙了。4. 磁盘IO优化磁盘IO在优化之前首先要弄清楚系统的IO情况是随机IO多还是顺序IO多是大文件IO多还是小文件IO多(小文件IO一般也就是随机IO)。比如随机IO多那么就可以通过加磁盘使用RAID技术来优化如果是顺序IO遇到瓶颈一般可能是磁盘驱动的带宽有瓶颈就可以换一个更快的disk controller。搞清楚是磁盘有瓶颈还是磁盘驱动的带宽有瓶颈。因为磁盘IO的操作分成了4个层面所以IO的优化也可以从这四个方面入手1)正对mysql系统的调优还需要选择正确的IO调度算法如果是SSD选择NOOP调度算法如果是磁盘那么选择deadline调度算法2)针对mysql还显然可以通过maser-slave来读写分离进行磁盘IO优化。3)另外增大内存可以对更多的磁盘文件进行缓存也能减轻IO压力。4)还有文件系统的挂载选项 noatime, nodiratime也能减轻IO压力另外选择正确的文件系统也能提高磁盘的tps. mysql数据库推荐使用XFS文件系统。注上面显示的磁盘IO的数据很多都是0这是因为数据来自于虚拟机中的Linux系统。相关标签磁盘 基础本文原创发布php中文网转载请注明出处感谢您的尊重
http://www.huolong8.cn/news/419746/

相关文章:

  • 网站开发需求范本网站技术维护费
  • 简述网站的制作步骤网页游戏平台大全
  • 开发小网站排名手机购物网站模版
  • 做网站找谁好网站建设报告心得体会
  • dede网站建设黄山网站开发
  • 网站制作的流程包括公司网站开通
  • 晋州有做网站的吗室内设计作品
  • 东营网站建设收益高微信营销 网站建设
  • 山西网络推广哪家专业seo搜索引擎优化平台
  • 开服网站建设网站系统修改不了怎么回事
  • 东莞知名企业排名seo石家庄
  • 行业网站怎么建设快对作业小程序入口
  • 渔具网站建设策划书前言律师在哪个网站做
  • 宁波做网站十大公司哪家好美食网站的设计与实现
  • 网站设计的汕头公司南宁五象新区建设投资集团网站
  • 湖南建设信息网站安徽招标投标信息网
  • 做网站运营的要求微信红包封面分销平台
  • 建一个素材网站多少钱文山城乡建设部网站首页
  • 北京网站搭建哪家好dedecms手机网站仿制
  • 长沙长沙建设网站虾米音乐 wordpress
  • 柳州柳北建设局网站可以拔下来做的网站吗
  • seo免费优化网站营销宝
  • 网站在哪里建立哪个程序做下载网站好
  • 做设计找素材那个网站最好用上海找做网站公司哪家好
  • 网站备案注销查询中国工程建设信息平台
  • 做网站可以用自己的主机徐州做英文网站的公司
  • 站长网站素材网网站开发与设计模板
  • 中国核工业二三建设有限公司阳江seo网站推广
  • 嘉定企业网站开发建设wordpress淘宝推广
  • 网站建设ppt模板下载除了个性化阶段