{"id":342,"date":"2016-09-24T13:41:46","date_gmt":"2016-09-24T05:41:46","guid":{"rendered":"https:\/\/yyshell.com\/?p=342"},"modified":"2016-09-27T12:54:16","modified_gmt":"2016-09-27T04:54:16","slug":"%e5%88%a9%e7%94%a8zabbix%e9%bb%98%e8%ae%a4%e7%9a%84mysql%e6%a8%a1%e6%9d%bf%e7%9b%91%e6%8e%a7mysqlmariadb","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=342","title":{"rendered":"\u5229\u7528zabbix\u9ed8\u8ba4\u7684mysql\u6a21\u677f\u76d1\u63a7mysql,mariadb"},"content":{"rendered":"<p>\u4e4b\u524d\u5199\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u642d\u5efazabbix\u670d\u52a1\u7684<a href=\"https:\/\/yyshell.com\/?p=219\">\u6559\u7a0b<\/a>\uff0c\u5f53\u65f6\u662f\u57fa\u4e8ezabbix2.4\u7684\uff0c\u76ee\u524d\uff0czabbix\u7684\u6700\u65b0\u7248\u672c\u5df2\u7ecf\u662f3.2\uff0c\u6709\u5f88\u591a\u65b0\u7684\u529f\u80fd\uff0c\u4f46\u81ea\u5df1\u516c\u53f8\u7528\u7684\u8fd8\u662fzabbix 3.0 lts\u957f\u671f\u652f\u6301\u7248\u672c\u3002MySQL\u4f5c\u4e3a\u6700\u5e38\u7528\u7684\u6570\u636e\u5e93\u4e4b\u4e00\uff0czabbix\u5df2\u7ecf\u9ed8\u8ba4\u81ea\u5e26\u6a21\u677f\uff0c\u6dfb\u52a0\u76f8\u5e94\u7684\u76d1\u63a7\u8fd8\u662f\u5f88\u7b80\u5355\u7684\u3002\u672c\u6b21\u5c31\u4ee5zabbix 3.0\u4e3a\u4f8b\uff0c\u8fdb\u884c\u6dfb\u52a0\u3002<\/p>\n<p>\u4ee5\u4e0b\u64cd\u4f5c\u5728\u88ab\u76d1\u63a7\u7684\u673a\u5668\u4e2d\u914d\u7f6e\uff0c\u5fc5\u987b\u5b89\u88c5\u4e86zabbix-agent\uff0c\u5728\u76d1\u63a7\u7684\u9879\u76ee\u4e2d\uff0c\u9009\u62e9mysql\u6a21\u677f\uff0c\u6dfb\u52a0\u5b8c\u6bd5\u540e\uff0c\u8fdb\u5165\u670d\u52a1\u5668\u5185\u90e8\u64cd\u4f5c\u3002<\/p>\n<p>\u65b0\u5efa\u76ee\u5f55\u5e76\u66f4\u6539\u5c5e\u4e3b\u7528\u6237\u4e3azabbix\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">mkdir -m 700 \/var\/lib\/zabbix\r\nchown zabbix:zabbix \/var\/lib\/zabbix<\/pre>\n<p>\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0c\u6211\u4eec\u4e13\u95e8\u5efa\u7acb\u4e00\u4e2a\u4f4e\u6743\u9650\u7684mysql\u7528\u6237\uff0c\u7528\u6765\u67e5\u770b\u5404\u79cd\u72b6\u6001\u3002<\/p>\n<pre class=\"lang:sh decode:true \">mysql -uroot -p -e\"GRANT USAGE ON *.* TO 'zabbixsql'@'localhost' IDENTIFIED BY 'zabbixsql'\";\r\nmysql -uroot -p -e\"flush privileges\"<\/pre>\n<p>\u6d4b\u8bd5\u4e0b\u65b0\u5efa\u7684\u7528\u6237\u80fd\u4e0d\u80fd\u67e5\u770b\u72b6\u6001<\/p>\n<pre class=\"lang:sh decode:true \">mysql -uzabbixsql -pzabbixsql -e\"status\"<\/pre>\n<p>\u8f93\u51fa\u662f\u8fd9\u6837\uff1a<\/p>\n<blockquote><p>&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nmysql Ver 15.1 Distrib 5.5.50-MariaDB, for Linux (x86_64) using readline 5.1<\/p>\n<p>Connection id: 445<br \/>\nCurrent database:<br \/>\nCurrent user: zabbixsql@localhost<br \/>\nSSL: Not in use<br \/>\nCurrent pager: stdout<br \/>\nUsing outfile: &#8221;<br \/>\nUsing delimiter: ;<br \/>\nServer: MariaDB<br \/>\nServer version: 5.5.50-MariaDB MariaDB Server<br \/>\nProtocol version: 10<br \/>\nConnection: Localhost via UNIX socket<br \/>\nServer characterset: latin1<br \/>\nDb characterset: latin1<br \/>\nClient characterset: utf8<br \/>\nConn. characterset: utf8<br \/>\nUNIX socket: \/var\/lib\/mysql\/mysql.sock<br \/>\nUptime: 54 min 29 sec<\/p>\n<p>Threads: 23 Questions: 18743 Slow queries: 0 Opens: 76 Flush tables: 2 Open tables: 102 Queries per second avg: 5.733<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8211;<\/p><\/blockquote>\n<p>\u8bf4\u660e\u5df2\u7ecf\u53ef\u4ee5\u67e5\u770b\u72b6\u6001\u4e86\u3002<\/p>\n<p>\u65b0\u5efa\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u4f9bzabbix\u8c03\u7528<br \/>\nvim \/var\/lib\/zabbix\/.my.cnf<\/p>\n<pre class=\"lang:ini decode:true\">[client]\r\nuser=zabbixsql\r\npassword=zabbixsql<\/pre>\n<p>\u8bbe\u7f6e\u4e0b\u6743\u9650<\/p>\n<pre class=\"lang:sh decode:true \">chown zabbix:zabbix \/var\/lib\/zabbix\/.my.cnf\r\nchmod 600 \/var\/lib\/zabbix\/.my.cnf<\/pre>\n<p>\u91cd\u542f\u4e0bzabbix-agent\u670d\u52a1<\/p>\n<pre class=\"lang:sh decode:true \">service zabbix-agent restart<\/pre>\n<p>\u5728zabbix server\u7aef\u6d4b\u8bd5\u4e0b\uff1a<\/p>\n<pre class=\"lang:sh decode:true \">zabbix_get -s 192.168.42.101 -k mysql.status[Uptime]\r\nzabbix_get -s 192.168.42.101 -k mysql.version\r\nzabbix_get -s 192.168.42.101 -k mysql.ping<\/pre>\n<p>\u5982\u679c\u90fd\u6709\u6570\u636e\u53cd\u9988\u51fa\u6765\uff0c\u90a3\u4e48\u5c31\u4ee3\u8868\u914d\u7f6e\u6210\u529f\u4e86\uff0c\u6b64\u65f6\u5728web\u4e0a\u5e94\u8be5\u53ef\u4ee5\u770b\u5230\u76d1\u63a7\u7684\u5404\u9879\u6570\u636e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u5199\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u642d\u5efazabbix\u670d\u52a1\u7684\u6559\u7a0b\uff0c\u5f53\u65f6\u662f\u57fa\u4e8ezabbix2.4\u7684\uff0c\u76ee<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,7],"tags":[29,40],"class_list":["post-342","post","type-post","status-publish","format-standard","hentry","category-linux","category-web","category-7","tag-mysql","tag-zabbix"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=342"}],"version-history":[{"count":3,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/342\/revisions"}],"predecessor-version":[{"id":345,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/342\/revisions\/345"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}