Zabbix简介
基于web的开源软件,开源监控系统状态也可以监控网络设备。
和nagios不同的是zabbix会把获取的数据保存在数据库中,所以zabbix需要有数据库支持
Zabbix还可以自动发现主机和网络设备
支持邮件和短信告警
Zabbix大多配置都可以在web界面配置完成
官网http://www.zabbix.com/  

 

安装zabbix

关闭防火墙

[root@localhost src]# service iptables stop 

[root@localhost src]# setenforce 0

 

安装epel扩展源,否则yum安装不了zabbix

rpm -ivh http://www.lishiming.net/data/p_w_upload/forum/month_1211/epel-release-6-7.noarch.rpm

 


安装rpm包的lamp环境 yum install -y  httpd mysql mysql-libs php php-mysql mysql-server php-bcmath php-gd php-mbstring
安装zabbix服务端:yum install  zabbix20 zabbix20-agent zabbix20-server  zabbix20-server-mysql zabbix20-web zabbix20-web-mysql net-snmp-devel

 

安装zabbix服务端:

yum install  zabbix20 zabbix20-agent zabbix20-server  zabbix20-server-mysql zabbix20-web zabbix20-web-mysql net-snmp-devel

 

启动apache

[root@localhost src]# /etc/init.d/httpd restart

有提示:正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

解决办法:vi /etc/httpd/conf/httpd.conf

找到:ServerName localhost:80

取消注释。

重启apache

[root@localhost src]# /etc/init.d/httpd restart
停止 httpd:                                               [确定]
正在启动 httpd:                                           [确定]

ok没有错误提示啦。

 

查看mysql是否启动:

[root@localhost src]# ps aux |grep mysqld
root      6458  0.0  0.0 103244   872 pts/1    S+   15:51   0:00 grep mysqld
[root@localhost src]# /etc/init.d/mysqld start   启动mysql服务

 

查看mysql版本:

[root@localhost src]# mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1Server version: 5.1.73 Source distribution

 

启动zabbix-server;zabbix-agent服务

[root@localhost src]# /etc/init.d/zabbix-server start; /etc/init.d/zabbix-agent start
Starting Zabbix server:                                    [确定]
Starting Zabbix agent:                                     [确定] 

 

创建zabbix数据库

 [root@localhost src]# mysql -uroot -p
Enter password:    直接回车 没有密码

mysql> create database zabbix;   创建zabbix数据库
Query OK, 1 row affected (0.00 sec)

 

导入zxbbix数据库;

[root@localhost src]# mysql -uroot -p --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/schema.sql

 

[root@localhost src]# mysql -uroot -p --default-character-set=utf8 zabbix < /usr/share/zabbix-mysql/p_w_picpaths.sql

 

[root@localhost src]# mysql -uroot --default-character-set=utf8 -p zabbix < /usr/share/zabbix-mysql/data.sql
Enter password:

 

网页安装zabbix

浏览器访问 http://ip/zabbix, 默认会有“It is not safe to rely on the system‘s timezone settings ”这样的警告信息,需要vim /etc/php.ini 设置 date.timezone=“Asia/Shanghai”点next

修改php.ini文件,查找 ;date.timezone = ,把前面的分号去掉在 “=”后面加上时区。

比如:Asia/Chongqing (重庆),Asia/Shanghai (上海),Asia/Urumqi (乌鲁木齐),Asia/Macao (澳门),Asia/Hong_Kong (香港),Asia/Taipei (台北),PRC


;date.timezone =
改成:
date.timezone = 'Asia/Shanghai'

 

修改完成后重启apache

[root@localhost src]# /etc/init.d/httpd restart

 

回到网页界面点next  有三处红色的需要在/etc/php.ini 修改 ,直接搜索相应的文件修改即可

Zabbix安装_安装

 

NEXT 这一步需要在服务器上给root用户创建密码

[root@localhost src]# mysqladmin -uroot password '123456'

尝试用root设置的密码登录下数据库:

[root@localhost src]# mysql -uroot -p123456

Database typeMySQL
Database host
Database port 0 - use default port
Database namezabbix
Userroot
Password123456

 

host:localhost  port:10051  name:server   执行下一步

Host
Port
Name

Zabbix安装_Zabbi_02

 

Zabbix安装_Zabbi_03

 

配置文件存放位置/etc/zabbix/web/zabbix.conf.php

Zabbix安装_安装_04

Zabbix安装_安装_05

 默认管理员账号为 admin:zabbix

 

配置下配置文件

这时会遇到“zabbix server is not running”这样的错误,需要编辑一 /etc/zabbix/zabbix_server.conf ,配置DBUser, DBPassword

[root@localhost src]# vim /etc/zabbix/zabbix_server.conf

DBHost=localhost

DBName=zabbix

DBUser=root

DBPassword=123456

修改完这几项后保存退出!

 

重启zabbix-server

[root@localhost src]# /etc/init.d/zabbix-server restart
Shutting down Zabbix server:                               [确定]
Starting Zabbix server:                                    [确定] 

 

查看监听的端口是否正常

[root@localhost src]# netstat -lnp

 

接入要监控的主机

先安装epel扩展源

rpm -ivh http://www.lishiming.net/data/p_w_upload/forum/month_1211/epel-release-6-7.noarch.rpm

在客户端上yum install zabbix20-agent

 

vim /etc/zabbix_agentd.conf //更改Server=服务端ip; ServerActive=0.0.0.0:10050; Hostname=aming(自定义,但要唯一)
启动客户端 /etc/init.d/zabbix-agent start

 

服务端上命令行测试:zabbix_get -s 客户端ip -p10050 -k "system.hostname"

 

在web界面下,点”configuration” --> “host” --> 右上角点”Create Host”  其中host name,  visible name自定义,可以选择groups,这里默认即可,ip address 写入客户端ip