一、zabbix服务端安装:
官方下载:http://www.zabbix.com/download.php
1.安装配置所需要软件(zabbix需要一个lamp环境)
[root@localhost ~]# yum install httpd php php-devel php-gd php-bcmath php-mbstring mysql-devel mysql-serverphp-xml php-mysql gd net-snmp net-snmp-devel net-snmp-utils
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# chkconfig mysqld on
[root@localhost ~]# chkconfig snmpd on
2.编译安装 zabbix
[root@localhost ~]# useradd zabbix
[root@localhost ~]# tar zxvf zabbix-2.0.0.tar.gz
[root@localhost ~]# cd zabbix-2.0.0
[root@localhost zabbix-2.0.0]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
[root@localhost zabbix-2.0.0]# make install
3.配置数据库:
[root@localhost ~]# /etc/init.d/mysqld start #启动mysql
[root@localhost ~]# mysqladmin -uroot password 'abc123' #配置用户密码
[root@localhost ~]# mysql -uroot -pabc123
mysql> create database zabbix character set utf8;
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'abc123';
#建立一个zabbix用户
mysql> quit
导入zabbix数据库
[root@localhost ~]# cd zabbix-2.0.0/database/mysql/
[root@localhost mysql]# mysql -uzabbix -pabc123 zabbix < schema.sql
[root@localhost mysql]# mysql -uzabbix -pabc123 zabbix < p_w_picpaths.sql
[root@localhost mysql]# mysql -uzabbix -pabc123 zabbix < data.sql
配置zabbix连接数据库选项
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=abc123
DBSocket=/var/lib/mysql/mysql.sock #注意你的mysql.sock位置
DBPort=3306
4.配置启动服务
[root@localhost zabbix-2.0.0]# cp misc/init.d/redhat/zabbix_* /etc/init.d/
[root@localhost zabbix-2.0.0]# vim /etc/init.d/zabbix_server_ctl
BASEDIR=/usr/local/zabbix #修改为zabbix安装的路径
[root@localhost zabbix-2.0.0]# vim /etc/init.d/zabbix_agentd_ctl
BASEDIR=/usr/local/zabbix #修改为zabbix安装的路径
[root@localhost ~]# echo "/etc/init.d/zabbix_server_ctl start" >> /etc/rc.local
[root@localhost ~]# echo "/etc/init.d/zabbix_agentd_ctl start" >> /etc/rc.local
[root@localhost ~]# /etc/init.d/zabbix_server_ctl start
[root@localhost ~]# /etc/init.d/zabbix_agentd_ctl start
5.配置zabbix web管理接口
修改httpd
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
DirectoryIndex index.php index.html index.html.var #增加一个index.php
[root@localhost ~]# /etc/init.d/httpd start
[root@localhost ~]# mkdir /var/www/html/zabbix
[root@localhost ~]# cp -a zabbix-2.0.0/frontends/php/* /var/www/html/zabbix/
[root@localhost html]# chown apache:apache -R /var/www/html/zabbix/
打开http://192.168.209.128/zabbix/将会看到zabbix安装向导
点击“Next>>看到zabbix对系统一些软件要求特性,不满足条件的以红色显示“Fail”
以上看到对PHP配置有一定的要求,下面对/etc/php.ini进行修改,修改完成后点“Retry”直到满足条件后继续下一步
(修改/etc/php.ini记得重启httpd服务)
[root@localhost ~]# vim /etc/php.in
post_max_size = 8M
max_execution_time = 30
max_input_time = 60
修改:
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
[root@localhost ~]# /etc/init.d/httpd restart
配置数据库选项(输入完成后Test connection)
Zabbix端口号
检查配置信息是否正确
最后一步完成
通过web登录,默认用户:admin 密码:zabbix
如需要显示中文可通过:右上角“Profile”--"Language" 选择“chinese(zh_CN)”之后保存
二、客户端安装
下载地址:http://www.zabbix.com/download.php
[root@localhost ~]# useradd zabbix
[root@localhost ~]# mkdir /usr/local/zabbix/
[root@localhost ~]# tar zxf zabbix_agents_2.0.0.linux2_6.i386.tar.gz -C /usr/local/zabbix/
[root@localhost ~]# ln -s /usr/local/zabbix/bin/* /usr/local/bin/
[root@localhost ~]# ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
[root@localhost ~]# echo "/usr/local/zabbix/sbin/zabbix_agent start" >>/etc/rc.local #开机自启动
官网上下载相应平台的agent包里没有运行agent所需的配置文件,可以从zabbix Server上拷贝一份zabbix.agentd.conf放到/usr/local/etc目录下,这个配置文件是所有平台都通用的。
修改zabbix.agentd.conf
[root@localhost ~]# vim /usr/local/etc/zabbix_agentd.conf
将server修改成zabbix_server的服务器IP
Server=192.168.209.128
手动启动:
[root@localhost ~]# zabbix_agentd start
[root@localhost ~]# netstat -nlp | grep zabbix_agentd
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2855/zabbix_agentd
三、其他
1.错误:通过 web 访问时出现了php的错误
date() [<a href='function.date'>function.date</a>]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead [include/page_header.php:184]
解决:
[root@localhost ~]# vim /etc/php.ini
;date.timezone =
修改为:
date.timezone = Asia/Chongqing
重启httpd服务,刷新后正常
2.参考别人安装zabbix,在导入数据库时,顺序为:schema.sql--- data.sql--- p_w_picpaths.sql,根据这个顺序,等出以下信息:
[root@localhost mysql]# mysql -uzabbix -pabc123 zabbix < schema.sql
[root@localhost mysql]# mysql -uzabbix -pabc123 zabbix < data.sql
ERROR 1452 (23000) at line 2739: Cannot add or update a child row: a foreign key constraint fails (`zabbix/sysmaps_elements`, CONSTRAINT `c_sysmaps_elements_2` FOREIGN KEY (`iconid_off`) REFERENCES `p_w_picpaths` (`p_w_picpathid`))
改为:schema.sql--- p_w_picpaths.sql---data.sql 则正常。
转载于:https://blog.51cto.com/liyaoyi/953948