zabbix監控的搭建mysql
zabbix是一個基於WEB界面的提供分佈式系統監視以及網絡監視功能的企業級的開源解決方案。linux
zabbix的應用場景:web
推薦博客:https://my.oschina.net/xiaotaochen/blog/1519497sql
1、安裝server端數據庫
一、首先在server端安裝一個網絡yum包:vim
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm安全
二、安裝zabbix server端:監控端服務器
yum install -y zabbix-server-mysql zabbix-web-mysql網絡
三、安裝數據庫:mariadb分佈式
yum groupinstall -y mariadb mariadb-client
四、修改mariadb配置文件
vim /etc/my.cnf
character-set-server=utf8 #設置字符集爲utf8
innodb_file_per_table=1 #讓innodb的每一個表文件單獨存儲
五、將mariadb服務開機自動啓動和重啓服務:
systemctl enable mariadb
systemctl restart mariadb
執行安全操做:
mysql_secure_installation
mysql -uroot -predhat
建立數據庫zabbix,受權給用戶zabbix訪問本地數據庫:
a、MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
b、MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
c、MariaDB [(none)]> flush privileges;
在數據庫裏面導入表:
cd /usr/share/doc/zabbix-server-mysql-3.2.1/
解壓縮:gzip -d create.sql.gz
mv /usr/share/doc/zabbix-server-mysql-3.2.1/create.sql /root
登陸zabbix數據庫:mysql -uzabbix -pzabbix zabbix
將create.sql表導入數據庫:source create.sql
六、配置文件vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
七、重啓服務(使用rhel7.2,否則7.0要升級)
systemctl enable zabbix-server.service
systemctl restart zabbix-server.service
八、PHP:在配置文件修改時區
重啓http服務:
systemctl restart httpd
九、實驗的驗證:http://172.25.254.132/zabbix
注意:防火牆這邊我都沒設置,故能夠直接關閉防火牆和關閉selinux
2、安裝客戶端(zabbix-agent):
一、在agent端上安裝網絡yum源包:
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
二、安裝監控主機zabbix-agent
a、yum install -y zabbix-agent
b、要修改好配置文件以後才啓動服務。
vim /etc/zabbix/zabbix_agentd.conf 配置文件
Server=172.25.254.132 監控的服務器是誰!
Hostname=chen 監控主機:hostname最左邊的字段
systemctl restart zabbix-agent.service 配置改完重啓服務
三、建立主機
四、對zabbix-get命令簡單的測試
在server端安裝zabbix-get包!
yum install -y zabbix-get
zabbix_get --help
zabbix_get -s 172.25.254.133 -k system.hostname
zabbix_get -s 172.25.254.131 -k system.cpu.util[0,user,avg5]