×ðÁú¿­Ê±

LinuxÉϵÄDockerÈÝÆ÷¼à¿Ø£ºÔõÑùʵʱ¼à²âÈÝÆ÷µÄÐÔÄܺͿµ½¡×´Ì¬ £¿

linuxÉϵÄdockerÈÝÆ÷¼à¿Ø£ºÔõÑùʵʱ¼à²âÈÝÆ÷µÄÐÔÄܺͿµ½¡×´Ì¬ £¿

ÔÚ½ñÌìµÄÔÆÅÌËãʱ´ú £¬DockerÒѾ­³ÉΪÁËÒ»ÖÖ³£¼ûµÄÈÝÆ÷»¯ÊÖÒÕ¡£Í¨¹ýDocker £¬ÎÒÃÇ¿ÉÒÔÀû±ãµØ½¨Éè¡¢°²ÅźÍÖÎÀíÓ¦ÓóÌÐò¡£È»¶ø £¬¹ØÓÚÔÚÉú²úÇéÐÎÖÐÔËÐеÄDockerÈÝÆ÷ £¬ÎÒÃDZØÐè¾ÙÐÐÐÔÄܼà¿Ø £¬ÒÔÈ·±£ÆäÕý³£ÔËÐв¢ÊµÊ±·¢Ã÷Ï¢Õù¾öÎÊÌâ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃLinuxÉϵŤ¾ßºÍÒªÁìÀ´ÊµÊ±¼à²âDockerÈÝÆ÷µÄÐÔÄܺͿµ½¡×´Ì¬¡£

Ò»¡¢Ê¹ÓÃDocker StatsÏÂÁîʵʱ¼à²âÈÝÆ÷µÄÐÔÄÜ

Docker StatsÏÂÁî¿ÉÒÔÌṩÈÝÆ÷µÄʵʱÐÔÄܲÎÊý £¬°üÀ¨CPUʹÓÃÂÊ¡¢ÄÚ´æʹÓÃÂÊ¡¢ÍøÂçIO¡¢¿éIOµÈ¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´Éó²éÈÝÆ÷µÄÐÔÄÜ״̬£º

docker stats <container_id>

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬ ÊÇÒª¼à²âµÄÈÝÆ÷µÄID¡£¸ÃÏÂÁ»áÒÔʵʱµÄ·½·¨Õ¹Ê¾ÈÝÆ÷µÄÐÔÄܲÎÊý £¬ÎÒÃÇ¿ÉÒÔͨ¹ýCtrl+CÀ´×èֹչʾ¡£

´úÂëʾÀý£º

$ docker stats 4a29e009a6c5
CONTAINER           CPU %               MEM USAGE / LIMIT    MEM %               NET I/O             BLOCK I/O           PIDS
4a29e009a6c5        0.03%               5.047MiB / 15.56GiB   0.03%               3.39kB / 0B         78.8kB / 0B         8

µÇ¼ºó¸´ÖÆ

ÉÏÊöʾÀýչʾÁËÈÝÆ÷µÄCPUʹÓÃÂÊ¡¢ÄÚ´æʹÓÃÂÊ¡¢ÍøÂçIO¡¢¿éIOµÈ²ÎÊý¡£

¶þ¡¢Ê¹ÓÃcAdvisor¾ÙÐÐÈÝÆ÷µÄÖÜÈ«¼à¿Ø

ÔÚÈÝÆ÷¼à¿ØÁìÓò £¬cAdvisor£¨Container Advisor£©ÊÇÒ»¸ö±¸ÊÜÍÆÐíµÄ¹¤¾ß £¬Ëü¿ÉÒÔÌṩÖÜÈ«µÄÈÝÆ÷ÐÔÄܼà¿ØºÍÆÊÎö¡£cAdvisor¿ÉÒÔ¼à²âÈÝÆ÷µÄCPU¡¢ÄÚ´æ¡¢Îļþϵͳ¡¢ÍøÂçµÈÖ¸±ê £¬²¢Ìṩ¿ÉÊÓ»¯µÄ¼à¿Ø½çÃæ £¬Àû±ãÓû§¾ÙÐÐÈÝÆ÷µÄʵʱ¼à¿ØºÍÀúÊ·Êý¾ÝÆÊÎö¡£

ÏÂÃæÊÇÔõÑùʹÓÃcAdvisorÀ´¼à¿ØDockerÈÝÆ÷µÄ°ì·¨£º

µÚÒ»²½ £¬×°ÖÃcAdvisor

¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°ÖÃcAdvisor£º

$ docker run 
  --volume=/:/rootfs:ro 
  --volume=/var/run:/var/run:rw 
  --volume=/sys:/sys:ro 
  --volume=/var/lib/docker/:/var/lib/docker:ro 
  --publish=8080:8080 
  --detach=true 
  --name=cadvisor 
  google/cadvisor:latest

µÇ¼ºó¸´ÖÆ

µÚ¶þ²½ £¬»á¼ûcAdvisorµÄ¼à¿Ø½çÃæ

Ò»µ©cAdvisor×°ÖÃÀֳɲ¢ÔËÐÐ £¬¿ÉÒÔͨ¹ýä¯ÀÀÆ÷»á¼ûlocalhost:8080À´Éó²écAdvisorµÄ¼à¿Ø½çÃæ¡£ÔÚ¼à¿Ø½çÃæÖÐ £¬¿ÉÒÔÑ¡ÔñÉó²éÌض¨ÈÝÆ÷µÄ¼à¿ØÊý¾Ý¡£

´úÂëʾÀý£º

$ docker run 
  --volume=/:/rootfs:ro 
  --volume=/var/run:/var/run:rw 
  --volume=/sys:/sys:ro 
  --volume=/var/lib/docker/:/var/lib/docker:ro 
  --publish=8080:8080 
  --detach=true 
  --name=cadvisor 
  google/cadvisor:latest

$ open http://localhost:8080

µÇ¼ºó¸´ÖÆ

ÒÔÉÏʾÀýչʾÁËÔõÑùͨ¹ýDockerÔËÐÐcAdvisor £¬²¢Í¨¹ýä¯ÀÀÆ÷»á¼û¼à¿Ø½çÃæ¡£

Èý¡¢Ê¹ÓÃPrometheusºÍGrafana¾ÙÐÐÈÝÆ÷¼à¿Ø

³ýÁËcAdvisor £¬ÉÐÓÐһЩÆäËû¹¤¾ßÒ²¿ÉÒÔÓÃÀ´¼à¿ØDockerÈÝÆ÷µÄÐÔÄÜ¡£PrometheusÊÇÒ»ÖÖÓÃÓÚ¼à¿ØºÍ¾¯±¨µÄϵͳ £¬¶øGrafanaÔòÊÇÒ»¸öÊý¾Ý¿ÉÊÓ»¯ºÍÆÊÎö¹¤¾ß¡£ÕâÁ½¸ö¹¤¾ß¿ÉÒÔÏ໥ÅäºÏ £¬ÌṩǿʢµÄÈÝÆ÷¼à¿Ø¹¦Ð§¡£

ÏÂÃæÊÇÔõÑùʹÓÃPrometheusºÍGrafanaÀ´¼à¿ØDockerÈÝÆ÷µÄ°ì·¨£º

µÚÒ»²½ £¬×°ÖÃPrometheusºÍGrafana

¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°ÖÃPrometheusºÍGrafana£º

$ docker run -d -p 9090:9090 --name=prometheus prom/prometheus
$ docker run -d -p 3000:3000 --name=grafana grafana/grafana

µÇ¼ºó¸´ÖÆ

µÚ¶þ²½ £¬ÉèÖÃPrometheus¼à¿ØDockerÈÝÆ÷

¿ÉÒÔͨ¹ýÐÞ¸ÄPrometheusµÄÉèÖÃÎļþÀ´¼à¿ØDockerÈÝÆ÷¡£ÒÔÏÂÊÇÒ»¸öʾÀýÉèÖÃÎļþ£º

global:
  scrape_interval: 15s
  external_labels:
    monitor: 'docker-monitor'

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'cadvisor'
    static_configs:
      - targets: ['cadvisor:8080']

µÇ¼ºó¸´ÖÆ

µÚÈý²½ £¬ÉèÖÃGrafana¿ÉÊÓ»¯DockerÈÝÆ÷¼à¿Ø

ÔÚGrafanaÖÐ £¬¿ÉÒÔͨ¹ýPrometheus×÷ΪÊý¾ÝÔ´À´¿ÉÊÓ»¯DockerÈÝÆ÷µÄ¼à¿ØÊý¾Ý¡ £¿ÉÒÔͨ¹ýÒÔÏ°취À´ÉèÖÃGrafanaµÄÊý¾ÝÔ´ºÍÒDZí°å£º

ÔÚä¯ÀÀÆ÷Öлá¼ûhttp://localhost:3000À´·­¿ªGrafanaµÄ½çÃæ¡£

µÇ¼Grafana £¬È»ºóÌí¼ÓPrometheus×÷ΪÊý¾ÝÔ´¡£

½¨ÉèÒDZí°å £¬²¢Ìí¼Ó¼à¿ØÃæ°å¡£

ͨ¹ýÉÏÊö°ì·¨ £¬¿ÉÒÔÍê³ÉPrometheusºÍGrafanaµÄ×°ÖúÍÉèÖà £¬²¢¿ÉʵÏÖDockerÈÝÆ÷µÄ¼à¿ØºÍ¿ÉÊÓ»¯¡£

½áÂÛ

ÔÚ±¾ÎÄÖÐ £¬ÎÒÃÇÏÈÈÝÁËÔõÑùʹÓÃLinuxÉϵŤ¾ßºÍÒªÁìÀ´ÊµÊ±¼à²âDockerÈÝÆ÷µÄÐÔÄܺͿµ½¡×´Ì¬¡£Í¨¹ýDocker StatsÏÂÁî¡¢cAdvisor¡¢PrometheusºÍGrafanaµÈ¹¤¾ß £¬ÎÒÃÇ¿ÉÒÔÀû±ãµØ¾ÙÐÐÈÝÆ÷µÄ¼à¿ØºÍÊý¾ÝÆÊÎö¡£Í¨¹ýʵʱ·¢Ã÷ÈÝÆ÷µÄÐÔÄÜÎÊÌâ £¬ÎÒÃÇ¿ÉÒÔÌá¸ßÓ¦ÓóÌÐòµÄÎȹÌÐԺͿɿ¿ÐÔ¡£Ï£Íû±¾ÎĶÔÄúÔÚʹÓÃDockerʱµÄÐÔÄܼà¿ØÌṩÁËһЩ×ÊÖú¡£

ÒÔÉϾÍÊÇLinuxÉϵÄDockerÈÝÆ÷¼à¿Ø£ºÔõÑùʵʱ¼à²âÈÝÆ÷µÄÐÔÄܺͿµ½¡×´Ì¬ £¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿