Docker部署inluxdb,grafana,prometheus环境

创建网络
  1. 查看现有网络:docker network ls

[root@zhulang home]# docker network ls
NETWORK ID NAME DRIVER SCOPE
874979f64b45 bridge bridge local
3eaf2e5dea55 host host local
962e1d6cfa34 none null local

  1. 创建网络:docker network create mynet,mynet为网络名

[root@zhulang home]# docker network create mynet
f73d04c62fd7ecd4313d6702a4f4bb2293c652bafecb12c7cabd8f441a876e5c

  1. 查看创建的网络:docker network inspect mynet

[root@zhulang home]# docker network inspect mynet
[
{
"Name": "mynet",
"Id": "f73d04c62fd7ecd4313d6702a4f4bb2293c652bafecb12c7cabd8f441a876e5c",
"Created": "2021-01-17T14:43:15.085120773+08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.21.0.0/16",
"Gateway": "172.21.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]

Docker部署influxdb
  1. 获取镜像:docker pull influxdb

[root@zhulang home]# docker pull influxdb
Using default tag: latest
latest: Pulling from library/influxdb
2587235a7635: Pull complete
953fe5c215cb: Pull complete
d4d3f270c7de: Pull complete
d81696497404: Pull complete
febe82b40114: Pull complete
9a89692c7853: Pull complete
5b833af9a4dc: Pull complete
69d297038fc8: Pull complete
Digest: sha256:fe53382e9fa49dd1ac079143ac5b26bfb4fb0ba32ac9b4b61c859a16943b1bff
Status: Downloaded newer image for influxdb:latest
docker.io/library/influxdb:latest

  1. 启动influxdb容器并命名为jmeterdb:docker run -d -p 8086:8086 --name jmeterdb --net mynet influxdb

[root@zhulang home]# docker run -d -p 8086:8086 --name jmeterdb --net mynet influxdb
2771fd54e2ae8576b67a52ecbfe20423e3cfab374c558161d2698926f6ae448d

  1. 进入该容器:docker exec -it jmeterdb /bin/bash

[root@zhulang home]# docker exec -it jmeterdb /bin/bash
root@2771fd54e2ae:/#

  1. 进入建数据库:influx

root@2771fd54e2ae:/# influx
Connected to http://localhost:8086 version 1.8.3
InfluxDB shell version: 1.8.3

  1. 创建数据库并查看是否创建成功

create database jmeterdb;
show databases;
name: databases
name


_internal
jmeterdb

  1. 通过jmeter测试influxdb数据库是否创建成功

    设置jmeter参数,启动jmeter

在这里插入图片描述

进入容器内的数据库查看是否有数据,有数据代表启动成功

在这里插入图片描述

Docker部署grafana
  1. 获取镜像:docker pull gafana/grafana

[root@zhulang home]# docker pull grafana/grafana
Using default tag: latest
latest: Pulling from grafana/grafana
801bfaa63ef2: Pull complete
efdb3434c59e: Pull complete
8cbdb3f56d34: Pull complete
34f82d4bd2ec: Pull complete
af445b3382af: Pull complete
4f4fb700ef54: Pull complete
8aab09bbec8e: Pull complete
9e81c23e3db5: Pull complete
Digest: sha256:5f19b6c385e8bfb8e5c9ecc7cdd123a453af3cf01e7c20d20059e770f656286d
Status: Downloaded newer image for grafana/grafana:latest
docker.io/grafana/grafana:latest

  1. 在创建的网络下启动grafana:docker run -d -p 3000:3000 --name mygrafana --net mynet grafana/grafana

[root@zhulang home]# docker run -d -p 3000:3000 --name mygrafana --net mynet grafana/grafana
b924a47732ebcb3801def47a72cffeacd5119ace28e2e4bae25df009166029e3

  1. 打开浏览器查看是否启动成功,用户名和密码均为admin
    在这里插入图片描述
grafana中设置influxdb
添加数据源

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TbxYcQdG-1612768905669)(C:\Users\fsy\AppData\Roaming\Typora\typora-user-images\image-20210117153813365.png)]

  1. 导入模板,模板选择id是4026或者5496即可

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-gXMW3jzb-1612768905672)(C:\Users\fsy\AppData\Roaming\Typora\typora-user-images\image-20210117161502532.png)]

Docker部署prometheus
  1. 拉取镜像:docker pull prom/prometheus

[root@zhulang home]# docker pull prom/prometheus
Using default tag: latest
latest: Pulling from prom/prometheus
ea97eb0eb3ec: Pull complete
ec0e9aba71a6: Pull complete
2c56484238c4: Pull complete
e04e22d751fb: Pull complete
725acffe426c: Pull complete
1aa9fa0253f1: Pull complete
d7fc56cae204: Pull complete
0697b0ac3503: Pull complete
1b03755e0f17: Pull complete
2c3149ca37ae: Pull complete
27dc64abca70: Pull complete
7ed50cc292d7: Pull complete
Digest: sha256:943c7c57115a449353e0158dcba4eaab2e56de07b7d552b5145cb6c0d1cbab19
Status: Downloaded newer image for prom/prometheus:latest
docker.io/prom/prometheus:latest

  1. 新建目录,生成prometheus.yaml

[root@zhulang home]# mkdir /home/prometheus
[root@zhulang home]# cd prometheus
[root@zhulang prometheus]#vim prometheus.yml

global:
scrape_interval: 60s
evaluation_interval: 60s

scrape_configs:

  • job_name: prometheus
    static_configs:

    • targets: ['localhost:9090']
      labels:
      instance: prometheus
  • job_name: linux
    static_configs:

    • targets: ['47.106.86.188:9100']
      labels:
      instance: localhost

~

  1. 启动prometheus

[root@zhulang prometheus]# docker run -d -p 9090:9090 -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml --net mynet prom/prometheus
4556160bec678aba8b6ebeaca4e34ea534d7306d2cbbec85a091ac95522cbd65

  1. 访问prometheus

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-K4e1klvz-1612768905673)(C:\Users\fsy\AppData\Roaming\Typora\typora-user-images\image-20210117212803356.png)]

  1. 安装node-exporter,拉取镜像,启动服务

[root@zhulang prometheus]# docker pull prom/node-exporter
Using default tag: latest
latest: Pulling from prom/node-exporter
86fa074c6765: Pull complete
ed1cd1c6cd7a: Pull complete
ff1bb132ce7b: Pull complete
Digest: sha256:cf66a6bbd573fd819ea09c72e21b528e9252d58d01ae13564a29749de1e48e0f
Status: Downloaded newer image for prom/node-exporter:latest
docker.io/prom/node-exporter:latest
[root@zhulang prometheus]# docker run -d -p 9100:9100 --name mynode-exporter --net mynet prom/node-exporter
994c5c645ed32479eb86bf18256869b011b82487dff40860c02d11d66431e94d

访问如下,表示安装成功

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xG8ja1hC-1612768905675)(C:\Users\fsy\AppData\Roaming\Typora\typora-user-images\image-20210117213544432.png)]

  1. 在grafana中安装监控主机的看板,id:9276,如图配置成功

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-V5RoRY7f-1612768905677)(C:\Users\fsy\AppData\Roaming\Typora\typora-user-images\image-20210117214124090.png)]

posted @ 2022-12-08 15:58  竹狼  阅读(886)  评论(0编辑  收藏  举报
<style id="ceshicss"> @media (max-width: 767px){ #set_btn_box {width: 100vw;left: 0;right: 0;bottom: 0;background: hsla(0,0%,100%,.6);height: 49px;display: flex;justify-content: space-between;align-items: center;padding: 12px 40px;border-top: 1px solid #e8e8e8;box-sizing: border-box;} .set_btn {margin-top: 0;} .set_btn.fly_top.fadeIn.animated {position: absolute;right: 10px;bottom: 60px;} .container{bottom:50px}} #mainContent{width:90%} </style> <link href="https://blog-static.cnblogs.com/files/miluluyo/tippy.min.css" rel="stylesheet"> <script src="https://unpkg.com/@popperjs/core@2.4.2/dist/umd/popper.min.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/tippy.js"></script> <link rel='stylesheet' href='https://cdn.bootcss.com/animate.css/3.7.2/animate.min.css'> <script src="https://at.alicdn.com/t/font_1825850_klax1ao4o6.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/three.min.js"></script> <script src='https://blog-static.cnblogs.com/files/miluluyo/star.js'></script> <link rel="stylesheet" href="https://blog-static.cnblogs.com/files/miluluyo/OwO.min.css" /> <script src="https://blog-static.cnblogs.com/files/miluluyo/OwO2.min.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/cute-cnblogs2.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/monitoring2.js"></script> <script> miluframe({ Youself:'https://www.cnblogs.com/faith007/', /*个人的博客园链接*/ /*博客园导航信息*/ custom:[{ name:'首页', link:'https://www.cnblogs.com/faith007/', istarget:false },{ name:'联系', link:'https://msg.cnblogs.com/send/%E7%AB%B9%E7%8B%BC', istarget:true },{ name:'留言板', link:'https://www.cnblogs.com/faith007/p/11578505.html', istarget:false },{ name:'相册', link:'https://www.cnblogs.com/faith007/gallery.html', istarget:false },{ name:'管理', link:'https://i.cnblogs.com/', istarget:true }], /*向别人展示自己的友链信息*/ resume:{ "name":"竹狼", "link":"https://www.cnblogs.com/faith007/", "headurl":"https://files-cdn.cnblogs.com/files/blogs/436273/VCG211321527184.bmp", "introduction":"大道至简,知易行难。" }], /*友链表格头信息,这个可以忽略*/ details:[{ field: 'name', literal: '昵称', },{ field: 'introduction', literal: '标语', },{ field: 'url', literal: '链接地址', },{ field: 'headurl', literal: '头像地址', }], /*浏览器顶部小图标*/ logoimg:'https://images.cnblogs.com/cnblogs_com/miluluyo/1765646/o_200519070633f12.png', /*文章页面标题前的图标,此处图标有扩展,下面会提到图标*/ cuteicon:['icon-caomei','icon-boluo','icon-huolongguo','icon-chengzi','icon-hamigua','icon-lizhi','icon-mangguo','icon-liulian','icon-lizi','icon-lanmei','icon-longyan','icon-shanzhu','icon-pingguo','icon-mihoutao','icon-niuyouguo','icon-xigua','icon-putao','icon-xiangjiao','icon-ningmeng','icon-yingtao','icon-taozi','icon-shiliu','icon-ximei','icon-shizi'], /*赞赏,若true则显示此按钮,false则不显示*/ isGratuity:false, /*赞赏按钮焦点显示赞赏内容,内容可自行更改*/ gratuity:'<div class="popper_box"><p><b>要请我喝奶茶吗 (づ。◕ᴗᴗ◕。)づ</b> </p><div class="popper_box_con"><div class="popper_box_con_li"><img src="https://images.cnblogs.com/cnblogs_com/miluluyo/1765646/o_200521053817wx.png" alt="">微信扫码</div><div class="popper_box_con_li"><img src="https://images.cnblogs.com/cnblogs_com/miluluyo/1765646/o_200521053827zfb.png" >支付宝扫码</div></div><p><b>留下一句你觉得很励志与美的话给我吧~</b>&nbsp;&nbsp;<b><a href="https://www.cnblogs.com/miluluyo/p/12930946.html">GO</a></b></div>' }) </script> <!-- 点赞 --> <canvas width="1777" height="841" style="position: fixed; left: 0px; top: 0px; z-index: 2147483647; pointer-events: none;"></canvas><script src="https://blog-static.cnblogs.com/files/miluluyo/mouse-click.js"></script> <!-- 以下内容是否添加你随意 --> <script> /*在文章页面添加古诗词*/ $("#navigator").after('<div class="poem-wrap"><div class="poem-border poem-left"></div><div class="poem-border poem-right"></div><h1>念两句诗</h1><div id="poem_sentence"></div><div id="poem_info"></div></div>') </script> <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script> <script type="text/javascript"> jinrishici.load(function(result) { var sentence = document.querySelector("#poem_sentence") var info = document.querySelector("#poem_info") sentence.innerHTML = result.data.content info.innerHTML = '【' + result.data.origin.dynasty + '】' + result.data.origin.author + '《' + result.data.origin.title + '》' }); </script> <script type="text/javascript"> /* 鼠标特效,我觉得太花哨了就注释了,喜欢的自己打开注释就可以 */ /*var a_idx = 0; jQuery(document).ready(function($) { $("body").click(function(e) { var a = new Array("❤去活出你自己。❤","❤今天的好计划胜过明天的完美计划。❤","❤不要轻言放弃,否则对不起自己。❤","❤紧要关头不放弃,绝望就会变成希望。❤","❤如果不能改变结果,那就完善过程。❤","❤好好活就是干有意义的事,有意义的事就是好好活!❤","❤你真正是谁并不重要,重要的是你的所做所为。❤","❤你不想为你的信仰冒一下险吗?难道想等你老了,再后悔莫及吗?❤","❤有些鸟儿是关不住的,它的每一根羽毛都闪耀着自由的光辉。❤","❤决定我们成为什么样人的,不是我们的能力,而是我们的选择。❤","❤掉在水里你不会淹死,呆在水里你才会淹死,你只有游,不停的往前游。❤","❤有些路,只能一个人走。❤","❤希望你眼眸有星辰,心中有山海。❤","❤从此以梦为马,不负韶华。❤","❤人的成就和差异决定于其业余时间。❤","❤佛不要你皈依,佛要你欢喜。❤","❤ダーリンのこと 大好きだよ❤","❤小猫在午睡时,地球在转。❤","❤我,混世大魔王,申请做你的小熊软糖。❤","❤决定好啦,要暗暗努力。❤","❤呐,做人呢最紧要开心。❤","❤好想邀请你一起去云朵上打呼噜呀。❤","❤永远年轻,永远热泪盈眶。❤","❤我生来平庸,也生来骄傲。❤","❤我走得很慢,但我从不后退。❤","❤人间不正经生活手册。❤","❤我是可爱的小姑娘,你是可爱。❤","❤数学里,有个温柔霸道的词,有且仅有。❤","❤吧唧一口,吃掉难过。❤","❤你头发乱了哦。❤","❤健康可爱,没有眼袋。❤","❤日月星辰之外,你是第四种难得。❤","❤你是否成为了了不起的成年人?❤","❤大家都是第一次做人。❤","❤何事喧哗?!❤","❤人间有味是清欢。❤","❤你笑起来真像好天气。❤","❤风填词半句,雪斟酒一壶。❤","❤除了自渡,他人爱莫能助。❤","❤昨日种种,皆成今我。❤","❤一梦入混沌 明月撞星辰❤","❤保持独立 适当拥有❤","❤谢谢你出现 这一生我很喜欢❤","❤做自己就好了 我会喜欢你的❤","❤太严肃的话,是没办法在人间寻欢作乐的❤","❤愿你余生可随遇而安,步步慢。❤","❤黄瓜在于拍,人生在于嗨❤","❤奇变偶不变,符号看象限。❤","❤从来如此,便对么?❤","❤今天我这儿的太阳,正好适合晒钙 你呢❤","❤未来可期,万事胜意。❤","❤星光不问赶路人 时光不负有心人❤","❤我当然不会试图摘月,我要月亮奔我而来❤","❤女生要修炼成的五样东西: 扬在脸上的自信,长在心底的善良, 融进血里的骨气,刻进命里的坚强,深到骨子里的教养❤","❤燕去燕归,沧海桑田。纵此生不见,平安惟愿❤","❤我想认识你 趁风不注意❤","❤我一直想从你的窗子里看月亮❤","❤长大应该是变温柔,对全世界都温柔。❤","❤别在深夜做任何决定❤","❤山中何事,松花酿酒,春水煎茶。❤","❤桃李春风一杯酒,江湖夜雨十年灯。❤","❤欲买桂花同载酒,终不似,少年游。❤"); var le = Math.ceil(Math.random()*a.length); var $i = $("<span></span>").text(a[le]);/*a[a_idx]*/ /*a_idx = (a_idx + 1) % a.length; var x = e.pageX, y = e.pageY; $i.css({ "z-index": 999999999999999999999999999999999999999999999999999999999999999999999, "top": y - 20, "left": x, "position": "absolute", "font-weight": "bold", "color": "rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")" }); $("body").append($i); $i.animate({ "top": y - 180, "opacity": 0 }, 2000, function() { $i.remove(); }); }); });*/ </script> <!--音乐,只在PC端宽度>1000px时显示--> <!-- <link rel="stylesheet" href="https://blog-static.cnblogs.com/files/miluluyo/APlayer.min.css"> <div id="player" class="aplayer aplayer-withlist aplayer-fixed" data-id="3116636104" data-server="netease" data-type="playlist" data-order="random" data-fixed="true" data-listfolded="true" data-theme="#2D8CF0"></div> <script src="https://blog-static.cnblogs.com/files/miluluyo/APlayer.min.js"></script> <script src="https://blog-static.cnblogs.com/files/miluluyo/Meting.min.js"></script> --> <!--猫,只在PC端显示,移动端不加载了,因为会卡顿页面--> <!-- <script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script> <script> var mobile_flag = isMobile(); if(mobile_flag){ //console.info("移动端") }else{ //console.info("PC端") L2Dwidget.init({ "model": { "jsonPath": "https://unpkg.com/live2d-widget-model-hijiki/assets/hijiki.model.json", "scale": 1 }, "display": { "position": "left", "width": 100, "height": 200, "hOffset": 70, "vOffset": 0 }, "mobile": { "show": true, "scale": 0.5 }, "react": { "opacityDefault": 0.7, "opacityOnHover": 0.2 } }); window.onload = function(){ $("#live2dcanvas").attr("style","position: fixed; opacity: 0.7; left: 70px; bottom: 0px; z-index: 1; pointer-events: none;") } } </script> --> <script> <script language="javascript" type="text/javascript"> // 生成目录索引列表 // ref: http://www.cnblogs.com/wangqiguo/p/4355032.html // modified by: zzq function GenerateContentList() { var mainContent = $('#cnblogs_post_body'); var h3_list = $('#cnblogs_post_body h3');//如果你的章节标题不是h2,只需要将这里的h2换掉即可 if(mainContent.length < 1) return; if(h3_list.length>0) { var content = '<a name="_labelTop"></a>'; content += '<div id="navCategory" style="color:#152e97;">'; content += '<p style="font-size:18px;"><b>目录</b></p>'; content += '<ul>'; for(var i=0; i<h3_list.length; i++) { var go_to_top = '<div style="text-align: right;"><a href="#_labelTop" style="color:#f68a33">回到顶部</a><a name="_label' + i + '"></a></div>'; $(h3_list[i]).before(go_to_top); var h4_list = $(h3_list[i]).nextAll("h4"); var li3_content = ''; for(var j=0; j<h4_list.length; j++) { var tmp = $(h4_list[j]).prevAll('h3').first(); if(!tmp.is(h3_list[i])) break; var li3_anchor = '<a name="_label' + i + '_' + j + '"></a>'; $(h4_list[j]).before(li3_anchor); li3_content += '<li><a href="#_label' + i + '_' + j + '">' + $(h4_list[j]).text() + '</a></li>'; } var li3_content = ''; if(li3_content.length > 0) li3_content = '<li><a href="#_label' + i + '">' + $(h3_list[i]).text() + '</a><ul>' + li3_content + '</ul></li>'; else li3_content = '<li><a href="#_label' + i + '">' + $(h3_list[i]).text() + '</a></li>'; content += li3_content; } content += '</ul>'; content += '</div><p>&nbsp;</p>'; content += '<hr style="height:1px;border:none;border-top:1px dashed #0066CC;"/>'; if($('#cnblogs_post_body').length != 0 ) { $($('#cnblogs_post_body')[0]).prepend(content); } } } GenerateContentList(); </script>