{"id":11294,"date":"2023-04-01T02:41:15","date_gmt":"2023-04-01T09:41:15","guid":{"rendered":"https:\/\/www.xh86.me\/?p=11294"},"modified":"2023-04-01T02:51:00","modified_gmt":"2023-04-01T09:51:00","slug":"%e7%94%a8docker%e5%ae%89%e8%a3%85zabbix%e5%92%8cgrafana%e7%9a%84%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=11294","title":{"rendered":"Debian\u4e0b\u7528docker\u5b89\u88c5zabbix\u548cgrafana\u7684\u811a\u672c"},"content":{"rendered":"<p>#!\/bin\/bash<\/p>\n<p># \u68c0\u67e5\u811a\u672c\u662f\u5426\u4ee5root\u6743\u9650\u8fd0\u884c<br \/>\nif [[ $EUID -ne 0 ]]; then<br \/>\necho &#8220;This script must be run as root&#8221;<br \/>\nexit 1<br \/>\nfi<\/p>\n<p># \u5b89\u88c5Docker<br \/>\napt-get update<br \/>\napt-get -y install apt-transport-https ca-certificates curl gnupg lsb-release<br \/>\ncurl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | gpg &#8211;dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<br \/>\necho &#8220;deb [arch=amd64 signed-by=\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/debian $(lsb_release -cs) stable&#8221; | tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null<br \/>\napt-get update<br \/>\napt-get -y install docker-ce docker-ce-cli containerd.io<\/p>\n<p># \u4e0b\u8f7d\u5e76\u542f\u52a8Zabbix\u670d\u52a1\u5668\u5bb9\u5668<br \/>\ndocker run -d \\<br \/>\n&#8211;name zabbix-server \\<br \/>\n-p 10051:10051 \\<br \/>\n-e DB_SERVER_HOST=&lt;db_server_host&gt; \\<br \/>\n-e MYSQL_USER=&lt;mysql_user&gt; \\<br \/>\n-e MYSQL_PASSWORD=&lt;mysql_password&gt; \\<br \/>\n-e MYSQL_DATABASE=&lt;mysql_database&gt; \\<br \/>\n-e ZBX_SERVER_NAME=&lt;zabbix_server_name&gt; \\<br \/>\nzabbix\/zabbix-server-mysql:latest<\/p>\n<p># \u4e0b\u8f7d\u5e76\u542f\u52a8Zabbix\u4ee3\u7406\u5bb9\u5668<br \/>\ndocker run -d \\<br \/>\n&#8211;name zabbix-agent \\<br \/>\n&#8211;link zabbix-server:zabbix \\<br \/>\n-e ZBX_HOSTNAME=&lt;zabbix_agent_hostname&gt; \\<br \/>\n-e ZBX_SERVER_HOST=&lt;zabbix_server_host&gt; \\<br \/>\nzabbix\/zabbix-agent:latest<\/p>\n<p># \u4e0b\u8f7d\u5e76\u542f\u52a8Grafana\u5bb9\u5668<br \/>\ndocker run -d \\<br \/>\n&#8211;name grafana \\<br \/>\n-p 3000:3000 \\<br \/>\ngrafana\/grafana:latest<\/p>\n<p># \u6253\u5370\u767b\u5f55\u4fe1\u606f<br \/>\necho &#8220;Zabbix Web: http:\/\/&lt;host&gt;:8080\/zabbix\/&#8221;<br \/>\necho &#8220;Grafana Web: http:\/\/&lt;host&gt;:3000\/&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u6b64\u811a\u672c\u9700\u8981\u60a8\u5148\u5b89\u88c5Docker\uff0c\u5e76\u4f7f\u7528<code>docker run<\/code>\u547d\u4ee4\u624b\u52a8\u4e0b\u8f7d\u548c\u542f\u52a8Zabbix\u548cGrafana\u5bb9\u5668\u3002\u5728\u6267\u884c\u6b64\u811a\u672c\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Docker\uff0c\u5e76\u5c06\u811a\u672c\u4e2d\u7684<code>&lt;db_server_host&gt;<\/code>\u3001<code>&lt;mysql_user&gt;<\/code>\u3001<code>&lt;mysql_password&gt;<\/code>\u3001<code>&lt;mysql_database&gt;<\/code>\u3001<code>&lt;zabbix_server_name&gt;<\/code>\u3001<code>&lt;zabbix_agent_hostname&gt;<\/code>\u548c<code>&lt;zabbix_server_host&gt;<\/code>\u66ff\u6362\u4e3a\u60a8\u7684\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e3b\u673a\u540d\u3001MySQL\u7528\u6237\u3001MySQL\u5bc6\u7801\u3001MySQL\u6570\u636e\u5e93\u540d\u3001Zabbix\u670d\u52a1\u5668\u540d\u79f0\u3001Zabbix\u4ee3\u7406\u4e3b\u673a\u540d\u548cZabbix\u670d\u52a1\u5668\u4e3b\u673a\u540d\u3002<\/p>\n<p>\u6267\u884c\u811a\u672c\u540e\uff0c\u60a8\u5c06\u80fd\u591f\u901a\u8fc7Zabbix\u548cGrafana\u7684Web\u754c\u9762\u8fdb\u884c\u76d1\u63a7\u548c\u6570\u636e\u53ef\u89c6\u5316\u3002\u8bf7\u786e\u4fdd\u5c06\u811a\u672c\u4e2d\u7684<code>&lt;host&gt;<\/code>\u66ff\u6362\u4e3a\u60a8\u7684\u4e3b\u673aIP\u5730\u5740\u6216\u57df\u540d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash # \u68c0\u67e5\u811a\u672c\u662f\u5426\u4ee5root\u6743\u9650\u8fd0\u884c if [[ $EUID -ne 0 ]]; the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,3],"tags":[],"class_list":["post-11294","post","type-post","status-publish","format-standard","hentry","category-linux","category-system"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/11294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11294"}],"version-history":[{"count":3,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/11294\/revisions"}],"predecessor-version":[{"id":11297,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/11294\/revisions\/11297"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}