首页 文章 精选 留言 我的

精选列表

搜索[微隔离服务],共10028篇文章
优秀的个人博客,低调大师

Docker核心原理-资源隔离和限制

通常情况运行docker容器没有指定具体哪个cpu和内存的分配,其实docker官方给出了,docker容器可以运行在指定CPU上通过docker run --help可以看到: 先制作docker镜像: 编写Dockerfile 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 [root@linux-node1~] #cdstress/ [root@linux-node1stress] #catDockerfile FROMcentos ADDepel-6.repo /etc/yum .repos.d/ RUNyum-y install stress&&yumcleanall ENTRYPOINT[ "stress" ] [root@linux-node1stress] # [root@linux-node1stress] #dockerbuild-tstress. SendingbuildcontexttoDockerdaemon4.096kB Step1:FROMcentos --->970633036444 Step2:ADDepel-6.repo /etc/yum .repos.d/ --->77600d6b488e Removingintermediatecontainerf141f47cb34f Step3:RUNyum-y install stress&&yumcleanall --->Running in 0949035c73da Loadedplugins:fastestmirror,ovl http: //mirrors .aliyuncs.com /epel/6/x86_64/repodata/98697cba0d79c083725de0c38b11c15878b35f5e27262becc02cd7ed1a13ac22-updateinfo .xml.bz2:[Errno12]Timeoutonhttp: //mirrors .aliyuncs.com /epel/6/x86_64/repodata/98697cba0d79c083725de0c38b11c15878b35f5e27262becc02cd7ed1a13ac22-updateinfo .xml.bz2:(28, 'Connectiontimedoutafter30001milliseconds' ) Tryingothermirror. Determiningfastestmirrors *base:mirrors.zju.edu.cn *epel:mirrors.aliyun.com *extras:mirrors.zju.edu.cn *updates:mirrors.cqu.edu.cn ResolvingDependencies -->Runningtransactioncheck --->Packagestress.x86_640:1.0.4-4.el6willbeinstalled -->FinishedDependencyResolution DependenciesResolved ================================================================================ PackageArchVersionRepositorySize ================================================================================ Installing: stressx86_641.0.4-4.el6epel36k TransactionSummary ================================================================================ Install1Package Totaldownloadsize:36k Installedsize:89k Downloadingpackages: Runningtransactioncheck Runningtransaction test Transaction test succeeded Runningtransaction Installing:stress-1.0.4-4.el6.x86_641 /1 install -info:Nosuch file ordirectory for /usr/share/info/stress .info Verifying:stress-1.0.4-4.el6.x86_641 /1 Installed: stress.x86_640:1.0.4-4.el6 Complete! Loadedplugins:fastestmirror,ovl Cleaningrepos:baseepelextrasupdates Cleaningupeverything Cleaninguplistoffastestmirrors --->504c747b9b51 Removingintermediatecontainer0949035c73da Step4:ENTRYPOINTstress --->Running in ea8d8eb8fb87 --->7e1e0e5cf825 Removingintermediatecontainerea8d8eb8fb87 Successfullybuilt7e1e0e5cf825 [root@linux-node1stress] #dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE stresslatest7e1e0e5cf825Aboutaminuteago214MB ningx- file v01460b5af495c43daysago531.9MB nginx /ningx 1.9.3v02097c98e3cb2b3daysago534.6MB nginx1.9.3d2cfb9ed3f2b3daysago534.6MB docker.io /centos latest97063303644411daysago196.7MB [root@linux-node1stress] # 查看docker run命令帮助输出: 1 2 3 4 5 6 7 [root@linux-node1stress] #dockerrun--help|grepcpu --cpu-sharesCPUshares(relativeweight) --cpu-periodLimitCPUCFS(CompletelyFairScheduler)period --cpu- quota LimitCPUCFS(CompletelyFairScheduler) quota --cpuset-cpusCPUs in which toallowexecution(0-3,0,1) --cpuset-memsMEMs in which toallowexecution(0-3,0,1) [root@linux-node1stress] # 启动一个容器: 1 2 [root@linux-node1stress] #dockerrun-it--rm--cpuset-cpus=0stress--cpu1 stress:info:[1]dispatchinghogs:1cpu,0io,0vm,0hdd 在另外一个窗口查看使用情况cpu: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 [root@linux-node1~] #top top -00:55:15up13:39,2 users ,loadaverage:0.58,0.47,0.69 Tasks:406total,2running,404sleeping,0stopped,0zombie %Cpu0:100.0us,0.0sy,0.0ni,0.0 id ,0.0wa,0.0hi,0.0si,0.0st %Cpu1:0.3us,0.3sy,0.0ni,99.3 id ,0.0wa,0.0hi,0.0si,0.0st %Cpu2:0.0us,0.0sy,0.0ni,100.0 id ,0.0wa,0.0hi,0.0si,0.0st %Cpu3:0.0us,0.0sy,0.0ni,100.0 id ,0.0wa,0.0hi,0.0si,0.0st KiBMem:773004total,204488 free ,194528used,373988buff /cache KiBSwap:2098172total,2096324 free ,1848used.399644availMem PIDUSERPRNIVIRTRESSHRS%CPU%MEMTIME+COMMAND 5944root2007260920R100.00.00:52.46stress 335root200000S0.30.01:17.95kworker /3 :1 1569root200553044136242952S0.31.80:13.46tuned 4779root200000S0.30.00:02.25kworker /1 :1 5946root20015794825041548R0.30.30:00.18 top 同样,再开启一个窗口: 1 2 [root@linux-node1stress] #dockerrun-it--rmstress--cpu1 stress:info:[1]dispatchinghogs:1cpu,0io,0vm,0hdd 再查切换到其他窗口查看cpu使用情况 1 2 3 4 5 6 7 8 9 10 [root@linux-node1~] #top top -00:57:52up13:41,3 users ,loadaverage:1.50,0.96,0.84 Tasks:414total,2running,412sleeping,0stopped,0zombie %Cpu0:100.0us,0.0sy,0.0ni,0.0 id ,0.0wa,0.0hi,0.0si,0.0st %Cpu1:0.0us,0.0sy,0.0ni,100.0 id ,0.0wa,0.0hi,0.0si,0.0st %Cpu2:0.0us,0.0sy,0.0ni,100.0 id ,0.0wa,0.0hi,0.0si,0.0st %Cpu3:0.0us,2.7sy,0.0ni,97.3 id ,0.0wa,0.0hi,0.0si,0.0st KiBMem:773004total,195560 free ,199560used,377884buff /cache KiBSwap:2098172total,2096576 free ,1596used.393660availMem PIDUSERPRNIVIRTRESSHRS%CPU%MEMTIME+COMMAND 注意命令: docker run -it --rm stress --cpu 1 docker run -it --rm --cpuset-cpus=0 stress --cpu 1 --cpuset-cpus后面跟cpu总个数,为docker容器指定的,而--cpu是用多少个cpu来运行,只能是1、2、3、4 ...N等等 本文转自027ryan 51CTO博客,原文链接:http://blog.51cto.com/ucode/1836484,如需转载请自行联系原作者

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册