一、安装zabbix

(1)创建用户和组

[root@dbking zabbix-2.2.1]# groupadd zabbix

[root@dbking zabbix-2.2.1]# useradd -g zabbix zabbix

(2)准备数据库

mysql> create database zabbix;

Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to 'root'@'%';

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

(3)导入数据库脚本

[mysql@dbking mysql]$ pwd                                                        

/rpm/zabbix-2.2.1/database/mysql

[mysql@dbking mysql]$ cat schema.sql|mysql -uroot -poracle -h192.168.80.10 zabbix

[mysql@dbking mysql]$ cat images.sql|mysql -uroot -poracle -h192.168.80.10 zabbix

[mysql@dbking mysql]$ cat data.sql|mysql -uroot -poracle -h192.168.80.10 zabbix

(4)编译安装zabbix

[root@dbking zabbix-2.2.1]# yum -y install unixODBC  unixODBC-devel  library  net-snmp net-snmp-devel libssh2-devel  OpenIPMI-devel java*   openldap openldap-devel curl-devel

[root@dbking zabbix-2.2.1]# ./configure --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --prefix=/usr/local/zabbix   --with-openipmi --with-unixodbc --with-ldap --with-ssh2 --enable-java

[root@dbking zabbix-2.2.1]#make && make install

(5)#vi /etc/services 添加格式如下

zabbix-agent    10050/tcp                       # Zabbix Agent

zabbix-agent    10050/udp                      # Zabbix Agent

zabbix-trapper  10051/tcp                       # Zabbix Trapper

zabbix-trapper  10051/udp                      # Zabbix Trapper

(6)编辑配置文件

[root@dbking zabbix-2.2.1]# mkdir /etc/zabbix

[root@dbking zabbix-2.2.1]# cp /usr/local/zabbix/etc/zabbix_server.conf /etc/zabbix/

[root@dbking zabbix-2.2.1]# cp /usr/local/zabbix/etc/zabbix_agentd.conf /etc/zabbix/

[root@dbking zabbix-2.2.1]# chown -R zabbix:zabbix /etc/zabbix/

(7)修改zabbix_server配置文件

[root@dbking zabbix-2.2.1]# vim /etc/zabbix/zabbix_server.conf

--修改数据库、用户、密码

(8)修改zabbix_agantd.conf文件

[root@dbking zabbix-2.2.1]# vim /etc/zabbix/zabbix_agentd.conf

修改hostname为主机名或ip

(9)cp web前段文件

[root@dbking zabbix-2.2.1]# cp -rf frontends/php/ /usr/local/apache2/htdocs/

[root@dbking zabbix-2.2.1]# chown -R zabbix:zabbix /usr/local/apache2/htdocs/php/

(10)修改php相关参数

[root@dbking zabbix-2.2.1]# vim /usr/local/php/etc/php.ini

date.timezone = Asia/Shanghai

post_max_size = 32M

upload_max_filesize = 16M

max_execution_time = 600

max_input_time = 600

memory_limit = 256M

(11)启动zabbix服务

[root@dbking zabbix-2.2.1]# /usr/local/zabbix/sbin/zabbix_server

/usr/local/zabbix/sbin/zabbix_server: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

解决办法:

[root@dbking zabbix-2.2.1]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

[root@dbking zabbix-2.2.1]# ps -ef|grep zabbix

root     24529 11914  0 10:17 pts/1    00:00:00 grep zabbix

[root@dbking zabbix-2.2.1]# /usr/local/zabbix/sbin/zabbix_server start

[root@dbking zabbix-2.2.1]# /usr/local/zabbix/sbin/zabbix_agentd stop

服务启动不了注意mysql授权问题,具体思路如下:

[mysql@dbking mysql]$ set password for 'root'@'192.168.80.10'=password('oracle');

[mysql@dbking mysql]$ grant all privileges on zabbix.* to 'root'@'192.168.80.10';

[mysql@dbking mysql]$ flush privileges;

(12)浏览器输入http://192.168.100.80/zabbix,界面安装:

LAMP下安装zabbix流水_mysql

(13)安装完成后,界面报错如下:

LAMP下安装zabbix流水_mysql_02

解决办法:

将路径中/usr/local/apache2/htdocs/zabbix/include/locales.inc.php的第25行数据注释掉,页面不会显示错误。

25 /*      

26         ini_set('mbstring.internal_encoding', 'UTF-8');

27 */

(14)设置zabbix开启自动启动

可以使用echo -e "/usr/local/zabbix-2.2.2/sbin/zabbix_server\n/usr/local/zabbix-2.2.2/sbin/zabbix_agentd">>/etc/rc.local