|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!cgroups简介
把持组(cgroups)是一个linux内核特征,它同意你指定内核应当怎样给一个历程组分派特定的资本。你能够用cgroups指定在某一个组中的历程利用几cpu工夫、体系内存、收集带宽、大概这些资本的组合。
(选自马哥教导的微信公家平台)
cgroups利用
<divstyle="padding:0px;margin:0px;color:rgb(85,85,85);font-family:宋体,ArialNarrow,arial,serif;font-size:14px;line-height:28px;"><divclass="syntaxhighlighterbash"id="highlighter_179047"style="width:720px;padding:0px!important;margin:0.3em0px!important;border-radius:0px!important;border:0px!important;bottom:auto!important;float:none!important;left:auto!important;line-height:1.1em!important;outline:0px!important;overflow-y:visible!important;overflow-x:auto!important;position:relative!important;right:auto!important;top:auto!important;vertical-align:baseline!important;box-sizing:content-box!important;font-family:Consolas,BitstreamVeraSansMono,CourierNew,Courier,monospace!important;font-size:1em!important;min-height:inherit!important;background-image:none!important;background-attachment:initial!important;background-size:initial!important;background-origin:initial!important;background-clip:initial!important;background-position:initial!important;background-repeat:initial!important;"><divclass="container"style="padding:0px!important;margin:0px!important;border-radius:0px!important;border:0px!important;bottom:auto!important;float:none!important;left:auto!important;line-height:1.1em!important;outline:0px!important;overflow:visible!important;position:relative!important;right:auto!important;top:auto!important;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-size:1em!important;min-height:inherit!important;background:none!important;">[size=1em]#下载一个能够摹拟cpu高负载的工具,mathomatic是质数天生器,会加年夜处置器的负荷
[size=1em]wgethttp://mathomatic.orgserve.de/mathomatic-16.0.5.tar.bz2
[size=1em]
[size=1em]tarxfmathomatic-16.0.5.tar.bz2
[size=1em]cdmathomatic-16.0.5/primes/
[size=1em]make&&makeinstall#编译装置
[size=1em]
[size=1em]#centos7体系必要装置libcgroup-tools包,才有cgroup设置下令
[size=1em]yuminstall-ylibcgroup-tools.x86_64
[size=1em]
[size=1em]#创立两个分歧cpu资本分派的组
[size=1em]cgcreate-gcpu:/large#详细下令利用cgcreate-h
[size=1em]cgcreate-gcpu:/small
[size=1em]
[size=1em]#cpu.shares是cpu把持的一个属性,更多的属性
[size=1em]#能够到/sys/fs/cgroup/cpu目次下检察,默许值是1024,值越年夜,能取得更多的cpu工夫
[size=1em]cgset-rcpu.shares=512small
[size=1em]
[size=1em]#cgexec启动一个cgroup义务
[size=1em]matho-primes0999999999>/dev/null&#天生一个从0到999999999的质数列表
[size=1em]cgexec-gcpu:small/usr/local/bin/matho-primes0999999999>/dev/null&#背景运转
[size=1em]
[size=1em]#利用top下令检察发明cpu被100%占用,由于是一个独自的历程,它利用尽量多的cpu
[size=1em]#cgroups限定仅在两个或多个以长进程合作cpu资本时起感化
[size=1em]PIDUSERPRNIVIRTRESSHRS%CPU%MEMTIME+COMMAND
[size=1em]6726root20092082540488R99.90.00:34.47matho-primes
[size=1em]
<divclass="linenumber28index27alt1"style="white-space:nowrap;padding:0px1em!important;margin:0px!important;border-radius:0px!important;border:0px!important;bottom:auto!important;float:none!important;left:auto!important;line-height:1.1em!important;outline:0px!important;overflow:visible!important;position:static!important;right:auto!important;top:auto!important;vertical-align:baseline!important;width:auto!important;box-sizing:content-box!important;font-size:1em!important;min-height:inherit!important;background-image:none!important;background-attachment:initial!important;background-size:initial!important;background-origin:initial!important;background-clip:initial!important;background-position:initial!important;background-repeat:initial!important;">cgexec-gcpu:large |
|