系统信息:CentOS release 6.5 (Final)
内核信息:2.6.32-431.el6.x86_64
Zabbix server ip:192.168.1.105
Zabbix agent ip:192.168.1.106
安装zabbixserver
安装mysql;
yum -y install mysql-server
编辑mysql配置文件;
vim /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # Disabling symbolic-links is recommendedto prevent assorted security risks symbolic-links=0 character-set-server=utf8 [mysql] default-character-set=utf8 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
重启mysql;
/etc/init.d/mysqld restart
设置开机自启动;
chkconfig mysqld on
创建数据库;
create database zabbix;
对数据库进行授权;
grant all on zabbix.* to zabbix@localhostidentified by "123456";
安装zabbix repo;
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
yum安装zabbix-server;
yum install install zabbix-serverzabbix-server-mysql
修改zabbix_server的配置文件;
vim /etc/zabbix/zabbix_server.conf #修改以下三处配置 DBName=zabbix DBUser=zabbix DBPassword=123456
查看数据库表;
rpm -ql zabbix-server-mysql |grep sql /usr/sbin/zabbix_server_mysql /usr/share/doc/zabbix-server-mysql-2.4.0 /usr/share/doc/zabbix-server-mysql-2.4.0/create /usr/share/doc/zabbix-server-mysql-2.4.0/create/data.sql #默认数据 /usr/share/doc/zabbix-server-mysql-2.4.0/create/p_w_picpaths.sql #zabbix图标相关 /usr/share/doc/zabbix-server-mysql-2.4.0/create/schema.sql #zabbix需要创建哪些表 /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/1.6 /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/1.6/mysql /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/1.6/mysql/patch.sql /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/1.8 /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/1.8/mysql /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/1.8/mysql/patch.sql /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/1.8/mysql/upgrade /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/2.0 /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/2.0/mysql /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/2.0/mysql/patch.sql /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/2.0/mysql/rc4_rc5.sql /usr/share/doc/zabbix-server-mysql-2.4.0/upgrades/dbpatches/2.0/mysql/upgrade
导入sql;
mysql zabbix < /usr/share/doc/zabbix-server-mysql-2.4.0/create/schema.sql mysql zabbix </usr/share/doc/zabbix-server-mysql-2.4.0/create/p_w_picpaths.sql mysql zabbix </usr/share/doc/zabbix-server-mysql-2.4.0/create/data.sql
启动zabbix-server;
/etc/init.d/zabbix-server restart
配置开机自启动;
chkconfig zabbix-server on
查看zabbix启动日志;
tail -f /var/log/zabbix/zabbix_server.log 2199:20140919:023458.237 server #17 started [timer #1] 2201:20140919:023458.241 server #18 started [http poller #1] 2204:20140919:023458.248 server #20 started [history syncer #1] 2205:20140919:023458.250 server #21 started [history syncer #2] 2208:20140919:023458.253 server #22 started [history syncer #3] 2210:20140919:023458.258 server #23 started [history syncer #4] 2211:20140919:023458.259 server #24 started [escalator #1] 2212:20140919:023458.260 server #25 started [proxy poller #1] 2216:20140919:023458.265 server #26 started [self-monitoring #1] 2202:20140919:023458.671 server #19 started [discoverer #1]
检查端口;
netstat -lntp|grep 10051 tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2172/zabbix_server tcp 0 0 :::10051
安装zabbix-web;
yum install -y zabbix-web zabbix-web-mysql
启动apache;
/etc/init.d/httpd restart
设置开机自启动;
chkconfig httpd on
在浏览器里输入服务器的ip地址;
点击next
这里php time zone需要修改时区;
编辑vim /etc/httpd/conf.d/zabbix.conf
找到date.timezone标注部分:
<Directory"/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Order allow,deny Allow from all php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value date.timezoneAsia/Shanghai </Directory>
修改完成之后需要重载一下apache,然后点击页面的retry即可;
点击next;
正确输入之前创建的数据库名、用户及密码;
我这里的数据库名是:zabbix
用户:zabbix
密码:123456
然后点击test connection进行测试连接,出现OK则表示连接正常,可以进行下一步。
在name内指定一个名字,可以根据实际情况自己制定名称。
这里显示的是之前配置的信息列表,可以进行确认,确认无误点击next。
这里显示配置文件已经生成,继续点击finish。
进入了登陆界面,默认用户名:admin 密码:zabbix
安装zabbixagent
首先配置zabbix repo;
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
安装zabbix agent;
yum install -y zabbix-agent
修改agent配置文件;
vim /etc/zabbix/zabbix_agentd.conf
#修改成服务器端的ip
Server=192.168.1.105
启动zabbix agent;
/etc/init.d/zabbix-agent start
添加开机自启动;
chkconfig zabbix-agent on
查看日志文件;
tail -f /var/log/zabbix/zabbix_agentd.log 1868:20140919:060835.219 Starting Zabbix Agent [Zabbix server].Zabbix 2.4.0 (revision 48953). 1868:20140919:060835.219 using configuration file: /etc/zabbix/zabbix_agentd.conf 1868:20140919:060835.220 agent #0 started [main process] 1869:20140919:060835.223 agent #1 started [collector] 1870:20140919:060835.228 agent #2 started [listener #1] 1871:20140919:060835.229 agent #3 started [listener #2] 1873:20140919:060835.229 agent #5 started [active checks #1] 1872:20140919:060835.230 agent #4 started [listener #3] 1873:20140919:060835.230 activecheck configuration update from [127.0.0.1:10051] started to fail (cannotconnect to [[127.0.0.1]:10051]: [111] Connection refused)
上面标注的地方有报错,我们可以编辑etc/zabbix/zabbix_agentd.conf 注释掉#ServerActive=127.0.0.1并且重启zabbix agent即可。