{"id":12018,"date":"2024-07-31T17:44:47","date_gmt":"2024-08-01T00:44:47","guid":{"rendered":"https:\/\/www.xh86.me\/?p=12018"},"modified":"2024-07-31T17:52:02","modified_gmt":"2024-08-01T00:52:02","slug":"12018","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=12018","title":{"rendered":"\u4e00\u952e\u5b89\u88c5Zabbix 7.0 LTS\u3001MySQL\u3001Nginx\u548cGrafana"},"content":{"rendered":"<p>!\/bin\/bash<\/p>\n<p># \u66f4\u65b0\u7cfb\u7edf<br \/>\napt update &amp;&amp; apt upgrade -y<\/p>\n<p># \u5b89\u88c5\u6240\u9700\u7684\u8f6f\u4ef6\u5305<br \/>\napt install -y gnupg2 wget lsb-release<\/p>\n<p># \u6dfb\u52a0Zabbix\u5b98\u65b9\u4ed3\u5e93<br \/>\nwget -qO- https:\/\/repo.zabbix.com\/zabbix\/7.0\/debian\/pool\/main\/z\/zabbix-release\/zabbix-release_7.0-1%2Bdebian12_all.deb | dpkg -i &#8211;<\/p>\n<p># \u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868<br \/>\napt update<\/p>\n<p># \u5b89\u88c5Zabbix\u670d\u52a1\u5668\u3001\u524d\u7aef\u548c\u4ee3\u7406<br \/>\napt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-agent<\/p>\n<p># \u5b89\u88c5MySQL\u6570\u636e\u5e93\u670d\u52a1\u5668<br \/>\napt install -y mysql-server<\/p>\n<p># \u8bbe\u7f6eMySQL root\u7528\u6237\u5bc6\u7801<br \/>\nMYSQL_ROOT_PASSWORD=&#8221;XXXXX&#8221;<\/p>\n<p># \u542f\u52a8MySQL\u670d\u52a1\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8<br \/>\nsystemctl start mysql<br \/>\nsystemctl enable mysql<\/p>\n<p># \u5b89\u5168\u5b89\u88c5MySQL\uff0c\u5e76\u8bbe\u7f6eroot\u5bc6\u7801\u548c\u5b57\u7b26\u96c6<br \/>\nmysql_secure_installation &lt;&lt;EOF<\/p>\n<p>y<br \/>\n$MYSQL_ROOT_PASSWORD<br \/>\n$MYSQL_ROOT_PASSWORD<br \/>\ny<br \/>\ny<br \/>\ny<br \/>\ny<br \/>\nEOF<\/p>\n<p># \u521b\u5efaZabbix\u6570\u636e\u5e93\u548c\u7528\u6237\uff0c\u5e76\u8bbe\u7f6e\u5bc6\u7801\uff0c\u9002\u914d\u4e2d\u6587\u5b57\u7b26<br \/>\nmysql -u root -p$MYSQL_ROOT_PASSWORD -e &#8220;CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;&#8221;<br \/>\nmysql -u root -p$MYSQL_ROOT_PASSWORD -e &#8220;CREATE USER &#8216;zabbix&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;XXXXX&#8217;;&#8221;<br \/>\nmysql -u root -p$MYSQL_ROOT_PASSWORD -e &#8220;GRANT ALL PRIVILEGES ON zabbix.* TO &#8216;zabbix&#8217;@&#8217;localhost&#8217;;&#8221;<br \/>\nmysql -u root -p$MYSQL_ROOT_PASSWORD -e &#8220;FLUSH PRIVILEGES;&#8221;<\/p>\n<p># \u5bfc\u5165\u521d\u59cb\u67b6\u6784\u548c\u6570\u636e<br \/>\nzcat \/usr\/share\/doc\/zabbix-server-mysql*\/create.sql.gz | mysql -uzabbix -pDsadmin1129! zabbix<\/p>\n<p># \u914d\u7f6eZabbix\u670d\u52a1\u5668<br \/>\nsed -i &#8216;s\/# DBPassword=\/DBPassword=XXXXXX\/g&#8217; \/etc\/zabbix\/zabbix_server.conf<\/p>\n<p># \u914d\u7f6ePHP\u65f6\u533a\u4e3a\u7f8e\u56fd\u6d1b\u6749\u77f6\u65f6\u533a<br \/>\nsed -i &#8216;s\/# php_value\\[date\\.timezone\\] = Europe\\\/Riga\/php_value\\[date\\.timezone\\] = America\\\/Los_Angeles\/g&#8217; \/etc\/zabbix\/nginx.conf<\/p>\n<p># \u542f\u52a8Zabbix\u670d\u52a1\u5668\u548c\u4ee3\u7406\u8fdb\u7a0b<br \/>\nsystemctl restart zabbix-server zabbix-agent<br \/>\nsystemctl enable zabbix-server zabbix-agent<\/p>\n<p># \u914d\u7f6eNginx\u4ee5\u4f7f\u7528Zabbix\u524d\u7aef<br \/>\nsed -i &#8216;s\/# listen 8080;\/ listen 80;\/g&#8217; \/etc\/zabbix\/nginx.conf<br \/>\nsed -i &#8216;s\/# server_name example.com;\/ server_name localhost;\/g&#8217; \/etc\/zabbix\/nginx.conf<\/p>\n<p># \u542f\u52a8Nginx\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8<br \/>\nsystemctl restart nginx<br \/>\nsystemctl enable nginx<\/p>\n<p># \u5b89\u88c5Grafana<br \/>\n# \u6dfb\u52a0Grafana GPG key\u548c\u4ed3\u5e93<br \/>\nwget -q -O &#8211; https:\/\/packages.grafana.com\/gpg.key | apt-key add &#8211;<br \/>\nadd-apt-repository &#8220;deb https:\/\/packages.grafana.com\/oss\/deb stable main&#8221;<\/p>\n<p># \u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\u5e76\u5b89\u88c5Grafana<br \/>\napt update<br \/>\napt install -y grafana<\/p>\n<p># \u542f\u52a8Grafana\u670d\u52a1\u5e76\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8<br \/>\nsystemctl start grafana-server<br \/>\nsystemctl enable grafana-server<\/p>\n<p># \u6253\u5370\u5b89\u88c5\u5b8c\u6210\u4fe1\u606f<br \/>\necho &#8220;Zabbix 7.0 LTS \u548c Grafana \u5df2\u6210\u529f\u5b89\u88c5\u5e76\u914d\u7f6e\u5b8c\u6210\uff01&#8221;<br \/>\necho &#8220;\u8bf7\u8bbf\u95ee http:\/\/\u670d\u52a1\u5668IP \u4ee5\u5b8c\u6210Zabbix\u524d\u7aef\u7684\u8bbe\u7f6e\u3002&#8221;<br \/>\necho &#8220;\u8bf7\u8bbf\u95ee http:\/\/\u670d\u52a1\u5668IP:3000 \u4ee5\u8bbf\u95eeGrafana\u3002&#8221;<\/p>\n<p>&nbsp;<\/p>\n<p>\u5c06\u6b64\u811a\u672c\u4fdd\u5b58\u4e3a\u4e00\u4e2a`.sh`\u6587\u4ef6\uff08\u4f8b\u5982`install_zabbix_grafana.sh`\uff09\uff0c\u7136\u540e\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6267\u884c\u5b83\uff1a<\/p>\n<p>chmod +x install_zabbix_grafana.sh<br \/>\nsudo .\/install_zabbix_grafana.sh<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>!\/bin\/bash # \u66f4\u65b0\u7cfb\u7edf apt update &amp;&amp; apt upgrade -y  [&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],"tags":[],"class_list":["post-12018","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12018","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=12018"}],"version-history":[{"count":4,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12018\/revisions"}],"predecessor-version":[{"id":12022,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12018\/revisions\/12022"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}