查看完整版本: CentOS 下使用 yum 安裝監測工具 - Zabbix 2.2 for Nginx


bruceman 2016-8-3 09:01

CentOS 下使用 yum 安裝監測工具 - Zabbix 2.2 for Nginx

Zabbix 是基於 PHP 及 MySQL 開發, 所以需要先安裝 LNMP 環境, 可以參考本站另一篇文章 <br><a href="http://dz.adj.idv.tw/thread-173544-1-1.html" target="_blank">在 CentOS 7 下整合 Nginx 1.10 + MariaDB 5.5 + PHP 7.0 </a><br><br><br>Step 1: Set Up Nginx, MySQL and PHP<br><br>安裝好 Nginx, PHP 及 MySQL 後, 可以根據不同的系統, 安裝相應的 RPM 檔啟用 Zabbix Repository:<br><br>RHEL 7, CentOS 7:<br># rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-release-2.2-1.el7.noarch.rpm<br><br>RHEL 6, CentOS 6:<br># rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm<br><br>RHEL 5, CentOS 6:<br># rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/5/x86_64/zabbix-release-2.2-1.el5.noarch.rpm<a href="http://repo.zabbix.com/zabbix/2.2/rhel/5/x86_64/zabbix-release-2.2-1.el5.noarch.rpm" target="_blank"></a><br><br>安裝了 Zabbix 的 Repository 後, 可以直接用 YUM 安裝 Zabbix, 執行以下指令安裝 Zabbix 及相關套件:<br># <font color="Red">yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway</font><br><br>接著建立 Zabbix 的 Nginx 設定檔, 建立檔案 /etc/nginx/conf.d/zabbix.conf:<br># vi /etc/nginx/conf.d/zabbix.conf<br><br>[quote]<br>server {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;server_name zabbix.adj.com.tw;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;root /var/www/zabbix/;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;index index.php index.html;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; access_log&nbsp;&nbsp;/var/log/nginx/zabbix.log;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;error_log&nbsp;&nbsp;/var/log/nginx/zabbix.error;<br><br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;location ~ \.php$ {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;include&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;/etc/nginx/fastcgi_params;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;fastcgi_param&nbsp; &nbsp;SCRIPT_FILENAME $document_root$fastcgi_script_name;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;fastcgi_param&nbsp; &nbsp;QUERY_STRING&nbsp; &nbsp; $query_string;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;fastcgi_pass&nbsp; &nbsp; 127.0.0.1:9000;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;fastcgi_intercept_errors on;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;error_page&nbsp; &nbsp;&nbsp; &nbsp;403 404 502 503 504&nbsp;&nbsp;http://zabbix.adj.com.tw/index.php;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br><br>&nbsp; &nbsp; location ~* \.(css|gif|jpeg|jpg|js|txt|png|tif|tiff|ico|jng|bmp|doc|pdf|rtf|xls|xpi|zip|tgz|gz|bz2|tar|mid|midi|mp3)$ {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;root /var/www/zabbix/;<br>&nbsp; &nbsp; }<br>}<br>[/quote]<br><br>再來修改權限並重新啟動nginx:<br># chown nginx:nginx /etc/zabbix/web/<br># ln -s /usr/share/zabbix /var/www/<br># service php-fpm restart<br># service nginx restart<br><br>現在要建立 Zabbix 的 MySQL 帳號及資料庫, 登入 MySQL:<br># mysql -u root -p<br><br>以下會建立 zabbix 帳號及資料庫, 密碼是 zabbix_pw<br>[quote]<br>mysql&gt; CREATE DATABASE zabbix;<br>mysql&gt; GRANT ALL PRIVILEGES on zabbix.* to 'zabbix'@'localhost' IDENTIFIED BY 'zabbix_pw';<br>mysql&gt; FLUSH PRIVILEGES;<br>mysql&gt; quit<br>[/quote]<br><br>建立資料庫後, 將 Zabbix 初始資料表匯入資料庫:<br># cd /usr/share/doc/zabbix-server-mysql*<br># mysql -u zabbix -p zabbix &lt; ./create/schema.sql <br># mysql -u zabbix -p zabbix &lt; ./create/images.sql <br># mysql -u zabbix -p zabbix &lt; ./create/data.sql<br><br>現在可以啟動 Zabbix Server:<br># service zabbix-server start <br><br>然後用瀏覽器開啟 Zabbix 的安裝程式, 例如當設定的網址是 zabbix.adj.com.tw , 則開啟以下網址:<br>http://zabbix.adj.com.tw/<br><br>這樣就會進入安裝畫面囉~<br><br>參考資料:<br><a href="https://www.luzem.com/2014/11/17/centos-6-6-zabbix-server-2-4-with-nginx-1-6-and-mysql-5-6/" target="_blank">https://www.luzem.com/2014/11/17/centos-6-6-zabbix-server-2-4-with-nginx-1-6-and-mysql-5-6/</a><br><a href="http://www.linuxtechi.com/install-zabbix-3-0-on-centos-7-rhel-7/" target="_blank">http://www.linuxtechi.com/install-zabbix-3-0-on-centos-7-rhel-7/</a><br>

plurk 2016-8-3 14:04

如果只是要安裝zabbix-agent 就可以只使用這兩個command<br><br># rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm<br># yum install zabbix-agent<br><br>然後修改設定檔..紅色依照使用者實際狀況填寫~<br><br># vi /etc/zabbix/zabbix_agentd.conf<br>[quote]<br>Server=<font color="Red">192.168.1.7</font><br>ServerActive=<font color="Red">192.168.1.7</font><br>Hostname=<font color="Red">www.adj.com.tw</font><br>[/quote]<br><br># service zabbix-agent start<br><br>這樣就可以囉~<br>
頁: [1]
查看完整版本: CentOS 下使用 yum 安裝監測工具 - Zabbix 2.2 for Nginx