天天看點

zabbix 2.4 yum安裝

安裝Zabbix-Server

安裝Zabbix官方源

<code>rpm -ivh </code>

<code>http:</code><code>//repo</code><code>.zabbix.com</code><code>/zabbix/2</code><code>.4</code><code>/rhel/6/x86_64/zabbix-release-2</code><code>.4-1.el6.noarch.rpm</code>

<a href="http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0%C2%A0" target="_blank"></a>

安裝zabbix服務端(這裡安裝的是2.4版本)

<code>yum -y </code><code>install</code> <code>zabbix-server  zabbix-server-mysql  zabbix-agent zabbix-get</code>

<code>#修改配置檔案:</code>

<code>vi</code> <code>/etc/zabbix/zabbix_server</code><code>.conf</code>

<code>DBHost=localhost               </code>

<code>DBName=zabbix                 </code>

<code>DBUser=zabbix                 </code>

<code>DBPassword=zabbix</code>

<code> </code> 

<code>#啟動zabbix</code>

<code>/etc/init</code><code>.d</code><code>/zabbix-server</code> <code>start</code>

<code>/etc/init</code><code>.d</code><code>/zabbix-agent</code> <code>start</code>

<code>#設定開機啟動:</code>

<code>chkconfig zabbix-server on</code>

<code>chkconfig zabbix-agent on</code>

安裝php:(預設安裝的是5.3版本)

<code>yum </code><code>install</code> <code>php php-fpm</code>

<code>vim </code><code>/etc/php</code><code>.ini</code>

<code>post_max_size = 16M</code>

<code>max_execution_time = 300</code>

<code>max_input_time = 300</code>

<code>date</code><code>.timezone = Asia</code><code>/Shanghai</code>

<code>/etc/init</code><code>.d</code><code>/php-fpm</code> <code>start</code>

<code>chkconfig php-fpm on</code>

安裝mysql:(預設安裝的是5.1版本)

<code>yum </code><code>install</code> <code>-y mysql mysql-server</code>

<code>chkconfig mysqld on    </code><code>#加入開機啟動</code>

<code>/etc/init</code><code>.d</code><code>/mysqld</code> <code>start  </code><code>#啟動mysql資料庫</code>

建立zabbix的資料庫

<code>mysqladmin -u rootpassword </code><code>'mysql'</code>

<code>mysql -uroot –pmysql</code>

<code>create database zabbixcharacter </code><code>set</code> <code>utf8; </code>

<code>grant all on zabbix.*to zabbix@localhost identified by </code><code>'zabbix'</code><code>;</code>

<code>flush privileges;</code>

<code>#導入Zabbix-Server資料庫:</code>

<code>cd</code> <code>/usr/share/doc/zabbix-server-mysql-2</code><code>.4.8</code><code>/create/</code> 

<code>mysql -uzabbix-pzabbix zabbix &lt;schema.sql    </code><code>#導入資料結構</code>

<code>mysql -uzabbix -pzabbix zabbix&lt;images.sql    </code><code>#導入圖檔</code>

<code>mysql -uzabbix -pzabbix zabbix&lt;data.sql    </code><code>#導入資料</code>

 安裝zabbix Client

<code>rpm-Uvh </code>

安裝zabbix agent:

<code>yum -y </code><code>install</code> <code>zabbix-agent zabbix-get</code>

編輯配置檔案:

<code>sed</code> <code>-i </code><code>'s#Server=127.0.0.1#Server=server_ip#g'</code><code>/etc/zabbix/zabbix_agentd</code><code>.conf</code>

<code>grepServer= </code><code>/etc/zabbix/zabbix_agentd</code><code>.conf</code>

<code>啟動zabbix agent:</code>

##########################################

<code>mysql安裝遇到的錯誤:</code>

<code>/usr/bin/mysqladmin</code><code>: errorwhile loading shared libraries: libmysqlclient.so.16: cannot </code><code>open</code> <code>shared objectfile: No such </code><code>file</code> <code>or directory</code>

<code>解決辦法:yum reinstallmysql-libs –y</code>

<code>Zabbix安裝以後一直在一地步和第二步之間循環,無法進入第三步。</code>

<code>解決:</code>

<code>mkdir</code> <code>/var/lib/php/session</code><code>–p</code>

<code>chown</code> <code>–Rnginx.nginx </code><code>/var/lib/php/session</code>

<code>這樣就解決了。</code>

使用zabbix監控mysql資料庫:

Zabbix官方也自帶了MySQL監控模闆,但是生産環境推薦使用percona的監控插件。

<code>https:</code><code>//www</code><code>.percona.com</code><code>/doc/percona-monitoring-plugins/1</code><code>.1</code><code>/zabbix/index</code><code>.html</code>

手工添加一台mysql資料庫的監控(agent端):

<code>安裝percona倉庫:</code>

<code>rpm-ivh http:</code><code>//www</code><code>.percona.com</code><code>/downloads/percona-release/redhat/0</code><code>.1-3</code><code>/percona-release-0</code><code>.1-3.noarch.rpm</code>

部署監控環境:

<code>yum </code><code>install</code> <code>zabbix22-agent php php-mysql -y</code>

<code>yum </code><code>install</code> <code>percona-zabbix-templates -y         </code><code>#安裝監控模闆</code>

<code>vi</code> <code>/etc/zabbix_agentd</code><code>.conf</code>

<code>include=</code><code>/etc/zabbix_agentd</code><code>.conf.d/</code>

<code>#mkdir /etc/ zabbix_agentd.conf.d/</code>

複制模闆到該目錄下:

<code>cp</code><code>/var/lib/zabbix/percona/templates/userparameter_percona_mysql</code><code>.conf</code><code>/etc/zabbix_agentd</code><code>.conf.d/</code>

讓php可以連接配接到mysql上:

<code>vim </code><code>/var/lib/zabbix/percona/scripts/ss_get_mysql_stats</code><code>.php.cnf</code>

<code>&lt;?php</code>

<code>$mysql_user=</code><code>'root'</code><code>;</code>

<code>$mysql_pass=</code><code>'password'</code><code>;</code>

測試并修改監控腳本:

<code>/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper</code><code>.sh gg</code>

<code>/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper</code><code>.shrunning-slave</code>

導入zabbix模闆:

<code>将</code><code>/var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2</code><code>.0.9-sver1.1.6.xml</code>

<code>下載下傳到本地,然後在zabbix上導入</code>

<code>Configuration -&gt; Templates-&gt; Import</code>

本文轉自 王家東哥 51CTO部落格,原文連結:http://blog.51cto.com/xiaodongge/1919348