系统环境:
[root@it3246 ~]# cat/etc/RedHat-release
CentOS release 6.5(Final)
1.在已有的LAMP或者LNMP的基础上安装zabbix,安装一些依赖包:
[root@it3246 ~]# yum -y
install gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql
httpd-manual mod_ssl mod_perl mod_auth_mysql php-gd php-xml php-mbstring
php-ldap php-pear php-xmlrpc php-bcmath mysql-connector-odbc mysql-devel
libdbi-dbd-mysql net-snmp-devel curl-devel unixODBC-devel OpenPMI-devel
java-devel libxml2-devel
2.在系统中添加一个管理zabbix的用户:
[root@it3246 ~]#groupaddzabbix
[root@it3246 ~]#useraddzabbix -g zabbix -s /sbin/nologin -m
3.登陆mysql数据库,创建zabbix系统的数据库,添加授权账号
mysql> createdatabase zabbix character set utf8;
mysql> grantall privileges on zabbix.* to zabbix@localhost identified by ‘zabbix’;
mysql> flushprivileges;
4.编译安装zabbix
下载地址:
wget http://nchc.dl.sourceforge.net/project/zabbix/ZABBIXLatest Stable/2.2.6/zabbix-2.2.6.tar.gz
[root@it3246 src]# tar
xf zabbix-2.2.6.tar.gz
[root@it3246 src]# ls
LAMP zabbix-2.2.6
zabbix-2.2.6.tar.gz
[root@it3246 src]# cd
zabbix-2.2.6
[root@it3246
zabbix-2.2.6]#
./configure
–prefix=/usr/local/zabbix –enable-server –enable-agent
–with-mysql
–with-net-snmp –with-libcurl
5.导入数据库(源码包的里面包含的数据库初始表,这里mysql设置密码是123456,在操作时候可以更改为自己系统mysql数据库的密码)
进入zabbix安装包中,按照如下命令查看mysql文件
mysql -uroot -p123456 zabbix < ./schema.sql
[root@it3246 mysql]#
mysql -uroot -p123456 zabbix < ./images.sql
[root@it3246 mysql]#
mysql -uroot -p123456 zabbix < ./data.sql
注意:[root@it3246 mysql]# mysql -uroot -p123456 zabbix < ./data.sql
ERROR 1146 (42S02) at line 2: Table ‘zabbix.hosts’doesn’t exist
错误提示:在第二行表 zabbix.hosts文件不存在。此时差错肯定在表上。
6.修改zabbixServer的配置文件
配置zabbix 连接数据库的账号密码
[root@it3246 mysql]#vim/usr/local/zabbix/etc/zabbix_server.conf
替换:DBUser=root换成DBUser=zabbix
添加:DBPassword
DBPassword=123456
脚本替换
sed-i ‘s/^DBUser=.*$/DBUser=zabbix/g’ /usr/local/zabbix/etc/zabbix_server.conf
sed-i ‘s/^.*DBPassword=.*$/DBPassword=zabbix/g’/usr/local/zabbix/etc/zabbix_server.conf
sed-i ‘s/BASEDIR=/usr/local/BASEDIR=/usr/local/zabbix/g’/etc/init.d/zabbix_server
sed-i ‘s/BASEDIR=/usr/local/BASEDIR=/usr/local/zabbix/g’/etc/init.d/zabbix_agentd
7.配置启动脚本,授予启动权限
[root@it3246zabbix-2.2.6]# pwd
/usr/local/src/zabbix-2.2.6
[root@it3246zabbix-2.2.6]# ls
aclocal.m4 conf configure.ac INSTALL man upgrades
AUTHORS config.guess COPYING install-sh misc
bin config.log database m4 missing
build config.status depcomp Makefile NEWS
ChangeLog config.sub frontends Makefile.am README
compile configure include Makefile.in src
cpmisc/init.d/Fedora/core/zabbix_server /etc/init.d/
[root@it3246zabbix-2.2.6]#
cpmisc/init.d/fedora/core/zabbix_agentd /etc/init.d/
[root@it3246zabbix-2.2.6]#
[root@it3246zabbix-2.2.6]cp-R frontends/php/ /var/www/html/zabbix
[root@it3246zabbix-2.2.6]# chmod +x /etc/init.d/zabbix_agentd
8.添加服务端口:
[root@it3246zabbix-2.2.6]# cat >>/etc/services <<EOF
> zabbix-agent10050/tcp Zabbix Agent
> zabbix-agent10050/udp Zabbix Agent
> zabbix-trapper10051/tcp Zabbix Trapper
> zabbix-trapper10051/udp Zabbix Trapper
> EOF
9.启动服务,并且加入开机启动项
[root@it3246zabbix-2.2.6]# /etc/init.d/zabbix_server start
Startingzabbix_server: /etc/init.d/functions:line 546: /usr/local/sbin/zabbix_server: 没有那个文件或目录
[失败] /etc/init.d/httpdstart
[root@it3246zabbix-2.2.6]# /etc/init.d/zabbix_server start
Startingzabbix_server: /etc/init.d/functions:line 546: /usr/local/sbin/zabbix_server: 没有那个文件或目录
[root@it3246zabbix-2.2.6]#
echo”/etc/init.d/zabbix_server start”>>/etc/rc.local
[root@it3246zabbix-2.2.6]#
echo”/etc/init.d/zabbix_agentd start”>>/etc/rc.local
错误提示
解决
(1)进入zabbix_server zabbix_agentd配置文件
[root@it3246zabbix-2.2.6]# vim /etc/init.d/zabbix_server
(2)修改BASEDIR选项
BASEDIR=/usr/local/zabbix
(3)修改完成后,重新启动httpd。
10.web页面配置
10.1 配置http访问好了后web登陆:http://ip/zabbix主要会报一些php报错的信息,对应的修改就好了,date.timezone = Asia/Shanghai
进入该页面按照提示一步一步初始化。
报错: