zabbix_LAMP源码安装
Zabbix源码包安装
Cenos5.3
Basic server
安装顺序
Libxml2
Libmcrypt
Zlib
Libpng
Jpeg:需要创建目录jpeg /bin /lib /include /man/man1
./configure --prefix=/usr/local/jpeg8/ --enable-shared
Freetype字体库
Libxpm安装、libXpm-devel安装
Autoconf 直接./configure装到系统里
[root@ZbbixSrv libgd-2.1.0]# ./configure \
> --prefix=/usr/local/gd2 \
> --with-zlib=/usr/local/zlib/ \
> --with-jpeg=/usr/local/jpeg8/ \
> --with-png=/usr/local/libpng/ \
> --with-freetype=/usr/local/freetype/ \
>--with-xpm-dir=/usr/local/libxpm
安装Apr
[root@ZbbixSrv apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@ZbbixSrv apr-1.5.2]# make && make install
Apr-util
[root@ZbbixSrv apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
安装Apache
[root@ZbbixSrv httpd-2.4.17]# ./configure \
>--prefix=/usr/local/apache2 \ //指定Apache软件安装的位置
>--sysconfdir=/etc/httpd \ //指定Apache服务器的配置文件存放位置
>--with-z=/usr/local/zlib/ \ //指定zlib库文件的位置
>--with-apr=/usr/local/apr //使用捆绑Apr的副本
>--with-apr-util=/usr/local/apr-util//使用捆绑Apr-util的副本
>--enable-so \ //以动态共享对象(DSO)编译
>--enable-deflate=shared \ //缩小传输码的支持
>--enable-expires=shared \ //期满头控制
>--enable-rewrite=shared \ //基于规则的URL操控
>--enable-static-support //建立一个静态链接版本的支持
[root@ZbbixSrv httpd-2.4.17]#iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@ZbbixSrv httpd-2.4.17]#service iptables save
[root@ZbbixSrv httpd-2.4.17]#service iptables restart
安装MySQL
[root@ZbbixSrv mysql-5.5.32]# groupadd mysql
[root@ZbbixSrv mysql-5.5.32]# useradd -r -g mysql mysql
[root@ZbbixSrv mysql-5.5.32]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/mysqldb -DMYSQL_TCP_PORT=3306
[root@ZbbixSrv mysql-5.5.32]# make && make install
[root@ZbbixSrv mysql-5.5.32]# cp -f /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
[root@ZbbixSrv mysql-5.5.32]# cp -f /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@ZbbixSrv mysql-5.5.32]# chown -R mysql:mysql /usr/local/mysql/*
[root@ZbbixSrv mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb
[root@ZbbixSrv mysql]# vi /etc/profile | PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
[root@ZbbixSrv mysql]# export PATH
[root@ZbbixSrv mysql]# source /etc/profile
[root@ZbbixSrv mysql]# chmod o=rwx /usr/local/mysql/
[root@ZbbixSrv mysql]# service mysqld restart
[root@ZbbixSrv mysql]# echo "/usr/local/apache2/bin/apachectl" >> /etc/rc.local
[root@ZbbixSrv mysql]# echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &" >> /etc/rc.local
安装PHP
[root@ZbbixSrv php-5.5.14]# ./configure \ 执行当前目录下软甲自带的配置命令
> --prefix=/usr/local/php \ 设置PHP安装目录
> --with-config-file-path=/usr/local/php/etc \设置PHP配置文件存放路径
> --with-apxs2=/usr/local/apache2/bin/apxs \ 关联Apache
> --with-mysql=/usr/local/mysql/ \ 关联MySQL
> --with-libxml-dir=/usr/local/libxml2/ \ 关联libxml2
> --with-png-dir=/usr/local/libpng/ \ 关联libpng
> --with-jpeg-dir=/usr/local/jpeg8/ \ 关联jpeg8
> --with-freetype-dir=/usr/local/freetype/ \ 关联freetype库
> --with-gd=/usr/local/gd2/ \ 关联gd库
> --with-mcrypt=/usr/local/libmcrypt/ \ 关联libmcrypt
>--with-xpm-dir=/usr/local/libxpm 关联libxpm
> --with-mysqli=/usr/local/mysql/bin/mysql_config \关联激活新增的MySQLi功能
> --enable-soap \ 变量激活soap和services支持
> --enable-mbstring=all \ 多字节字符串支持
> --enable-sockets 变量激活socket通讯特性
[root@ZbbixSrv php-5.5.14]# make
[root@ZbbixSrv php-5.5.14]# make install
[root@ZbbixSrv php-5.5.14]# cp php.ini-development /usr/local/php/etc/php.ini
[root@ZbbixSrv php-5.5.14]# vi /etc/httpd/httpd.conf
AddType application/x-httpd-php .php .phtml
测试PHP功能
Index.php <?php phpinfo();?>
Zabbix安装
mysql> create database zabbix character set utf8;
mysql> insert into mysql.user(Host,User,Password) values('localhost','zabbix',password('zabbix'));
mysql> flush privileges;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix' WITH GRANT OPTION;
mysql> flush privileges;
mysql> use zabbix;
mysql> source /usr/local/src/zabbix-2.4.7/database/mysql/schema.sql
mysql> source /usr/local/src/zabbix-2.4.7/database/mysql/images.sql
mysql> source /usr/local/src/zabbix-2.4.7/database/mysql/data.sql
请按照顺序导入,否则会出错
[root@ZbbixSrv ~]# groupadd zabbix;
[root@ZbbixSrv ~]# useradd zabbix -g zabbix -s /bin/false
[root@ZbbixSrv ~]# yum install net-snmp net-snmp-devel curl curl-devel mysql-devel
[root@ZbbixSrv ~]# cd /usr/local/src/zabbix-2.4.7/
[root@ZbbixSrv zabbix-2.4.7]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-net-snmp --with-libcurl --enable-proxy --with-mysql=/usr/local/mysql/bin/mysql_config
[root@ZbbixSrv zabbix-2.4.7]# make install
[root@ZbbixSrv zabbix-2.4.7]# cp -r /usr/local/src/zabbix-2.4.7/frontends/php/ /usr/local/apache2/htdocs/zabbix
[root@ZbbixSrv zabbix-2.4.7]# chown zabbix.zabbix -R /usr/local/apache2/htdocs/zabbix/
[root@ZbbixSrv zabbix-2.4.7]# ln -s /usr/local/zabbix/bin/* /usr/local/bin/
[root@ZbbixSrv zabbix-2.4.7]# ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
[root@ZbbixSrv zabbix-2.4.7]# vi /etc/services 查看10050、10051端口
[root@ZbbixSrv zabbix-2.4.7]# vi /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix #数据库名称
DBUser=zabbix #数据库用户名
DBPassword=123456 #数据库密码
ListenIP=127.0.0.1 #数据库ip地址
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts #zabbix运行脚本存放目录
[root@ZbbixSrv zabbix-2.4.7]# vi /usr/local/zabbix/etc/zabbix_agent.conf
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
UnsafeUserParameters=1 #启用自定义key
[root@ZbbixSrv ~]# cp /usr/local/src/zabbix-2.4.7/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[root@ZbbixSrv ~]# cp /usr/local/src/zabbix-2.4.7/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
[root@ZbbixSrv ~]# chmod +x /etc/init.d/zabbix_server
[root@ZbbixSrv ~]# chmod +x /etc/init.d/zabbix_agentd
[root@ZbbixSrv ~]# vi /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix/ #zabbix安装目录
[root@ZbbixSrv ~]# vi /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix/ #zabbix安装目录
[root@ZbbixSrv ~]# chkconfig zabbix_server on
[root@ZbbixSrv ~]# chkconfig zabbix_agentd on
启动zabbix_server时出现报错
[root@ZbbixSrv ~]# /etc/init.d/zabbix_server start
Starting 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@ZbbixSrv ~]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[root@ZbbixSrv ~]# /etc/init.d/zabbix_server start
Starting zabbix_server: [确定]
[root@ZbbixSrv ~]# vi /usr/local/php/etc/php.ini
post_max_size =16M
max_execution_time =300
max_input_time =300
date.timezone = PRC
缺少bcmath模块
[root@ZbbixSrv bcmath]# cd /usr/local/src/php-5.5.14/ext/bcmath/
[root@ZbbixSrv bcmath]# /usr/local/php/bin/phpize 生成./configure配置文件
[root@ZbbixSrv bcmath]#./configure --with-php-config=/usr/local/php/bin/php-config
打开网页测试
172.29.151.125/zabbix
Zabbix客户端安装
Zabbix客户端和服务端未一个安装包
[root@SkyForm_AdminDb1 src]# groupadd zabbix
[root@SkyForm_AdminDb1 src]# useradd -g zabbix zabbix
[root@SkyForm_AdminDb1 src]# tar xvf zabbix-2.4.7.tar.gz
[root@SkyForm_AdminDb1 zabbix-2.4.7]# ./configure --prefix=/usr/local/zabbix_agent/ --enable-agent
[root@SkyForm_AdminDb1 zabbix-2.4.7]# make && make install
[root@SkyForm_AdminDb1 zabbix-2.4.7]# vi /etc/services
[root@SkyForm_AdminDb1 zabbix-2.4.7]# vim /usr/local/zabbix_agent/etc/zabbix_agentd.conf
[root@SkyForm_AdminDb1 zabbix-2.4.7]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
[root@SkyForm_AdminDb1 zabbix-2.4.7]# chmod +x /etc/init.d/zabbix_agentd
[root@SkyForm_AdminDb1 zabbix-2.4.7]# vi /etc/init.d/zabbix_agentd
[root@SkyForm_AdminDb1 zabbix-2.4.7]# /etc/init.d/zabbix_agentd restart
Shutting down zabbix_agentd: [ OK ]
Starting zabbix_agentd: [ OK ]
[root@SkyForm_AdminDb1 zabbix-2.4.7]# chkconfig zabbix_agentd on
[root@SkyForm_AdminDb1 zabbix-2.4.7]# chkconfig --list | grep zabbix_agentd
zabbix_agentd 0:off1:off2:on3:on4:on5:on6:off
在这里看到6个进程就可以了
测试键值
[root@SkyForm_AdminDb1 ~]# /usr/local/zabbix_agent/bin/zabbix_get -s 172.29.151.125 -p10050 -k"net.if.in[eth0,bytes]"