zabbix源码包安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix源码包安装相关的知识,希望对你有一定的参考价值。

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装到系统里

Libgd:   [[email protected] 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

[[email protected] apr-1.5.2]# ./configure --prefix=/usr/local/apr

[[email protected] apr-1.5.2]# make && make install

Apr-util

[[email protected] apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/

 

安装Apache

[[email protected] 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                    //建立一个静态链接版本的支持

[[email protected] httpd-2.4.17]#iptables -I INPUT -p tcp --dport 80 -j ACCEPT

[[email protected] httpd-2.4.17]#service iptables save

[[email protected] httpd-2.4.17]#service iptables restart

安装mysql

[[email protected] mysql-5.5.32]# groupadd mysql

[[email protected] mysql-5.5.32]# useradd -r -g mysql mysql

[[email protected] 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

[[email protected] mysql-5.5.32]# make && make install

[[email protected] mysql-5.5.32]# cp -f /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

[[email protected] mysql-5.5.32]# cp -f /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld

[[email protected] mysql-5.5.32]# chown -R mysql:mysql /usr/local/mysql/*

[[email protected] mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb

[[email protected] mysql]# vi /etc/profile | PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH

[[email protected] mysql]# export PATH

[[email protected] mysql]# source /etc/profile

[[email protected] mysql]# chmod o=rwx /usr/local/mysql/

[[email protected] mysql]# service mysqld restart

[[email protected] mysql]# echo "/usr/local/apache2/bin/apachectl" >> /etc/rc.local

[[email protected] mysql]# echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &"  >> /etc/rc.local

安装php

[[email protected] 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 \                                                              变量激活soapservices支持

> --enable-mbstring=all \                                      多字节字符串支持

> --enable-sockets                                                           变量激活socket通讯特性

[[email protected] php-5.5.14]# make

[[email protected] php-5.5.14]# make install

[[email protected] php-5.5.14]# cp php.ini-development /usr/local/php/etc/php.ini

[[email protected] 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

请按照顺序导入,否则会出错

[[email protected] ~]# groupadd zabbix;

[[email protected] ~]# useradd zabbix -g zabbix -s /bin/false

[[email protected] ~]# yum install net-snmp net-snmp-devel curl curl-devel mysql-devel

[[email protected] ~]# cd /usr/local/src/zabbix-2.4.7/

[[email protected] 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

[[email protected] zabbix-2.4.7]# make install

[[email protected] zabbix-2.4.7]# cp -r /usr/local/src/zabbix-2.4.7/frontends/php/ /usr/local/apache2/htdocs/zabbix

[[email protected] zabbix-2.4.7]# chown   zabbix.zabbix -R /usr/local/apache2/htdocs/zabbix/

[[email protected] zabbix-2.4.7]# ln -s /usr/local/zabbix/bin/* /usr/local/bin/

[[email protected] zabbix-2.4.7]# ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/

[[email protected] zabbix-2.4.7]# vi /etc/services  查看1005010051端口

[[email protected] 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运行脚本存放目录

[[email protected] zabbix-2.4.7]# vi /usr/local/zabbix/etc/zabbix_agent.conf

Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/

UnsafeUserParameters=1 #启用自定义key

[[email protected] ~]# cp /usr/local/src/zabbix-2.4.7/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server

[[email protected] ~]# cp /usr/local/src/zabbix-2.4.7/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

[[email protected] ~]# chmod +x /etc/init.d/zabbix_server

[[email protected] ~]# chmod +x /etc/init.d/zabbix_agentd

[[email protected] ~]# vi /etc/init.d/zabbix_server

BASEDIR=/usr/local/zabbix/ #zabbix安装目录

[[email protected] ~]# vi /etc/init.d/zabbix_agentd

BASEDIR=/usr/local/zabbix/ #zabbix安装目录


[[email protected] ~]# chkconfig zabbix_server on

[[email protected] ~]# chkconfig zabbix_agentd on

启动zabbix_server时出现报错

[[email protected] ~]# /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

解决

[[email protected] ~]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

[[email protected] ~]# /etc/init.d/zabbix_server start                            

Starting zabbix_server:                                    [确定]

                                                                              

[[email protected] ~]# vi /usr/local/php/etc/php.ini

post_max_size =16M

max_execution_time =300

max_input_time =300

date.timezone = PRC

缺少bcmath模块

[[email protected] bcmath]# cd /usr/local/src/php-5.5.14/ext/bcmath/

[[email protected] bcmath]# /usr/local/php/bin/phpize               生成./configure配置文件

[[email protected] bcmath]#./configure   --with-php-config=/usr/local/php/bin/php-config

打开网页测试

172.29.151.125/zabbix



 

Zabbix客户端安装

Zabbix客户端和服务端未一个安装包

[[email protected]_AdminDb1 src]# groupadd zabbix

[[email protected]_AdminDb1 src]# useradd -g zabbix zabbix

[[email protected]_AdminDb1 src]# tar xvf zabbix-2.4.7.tar.gz

[[email protected]_AdminDb1 zabbix-2.4.7]# ./configure --prefix=/usr/local/zabbix_agent/ --enable-agent

[[email protected]_AdminDb1 zabbix-2.4.7]# make && make  install

[[email protected]_AdminDb1 zabbix-2.4.7]# vi /etc/services

 

技术分享

[[email protected]_AdminDb1 zabbix-2.4.7]# vim /usr/local/zabbix_agent/etc/zabbix_agentd.conf

技术分享

[[email protected]_AdminDb1 zabbix-2.4.7]# cp misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd

[[email protected]_AdminDb1 zabbix-2.4.7]# chmod +x /etc/init.d/zabbix_agentd

[[email protected]_AdminDb1 zabbix-2.4.7]# vi /etc/init.d/zabbix_agentd

技术分享

[[email protected]_AdminDb1 zabbix-2.4.7]# /etc/init.d/zabbix_agentd restart

Shutting down zabbix_agentd:                               [  OK  ]

Starting zabbix_agentd:                                    [  OK  ]

[[email protected]_AdminDb1 zabbix-2.4.7]# chkconfig zabbix_agentd on

[[email protected]_AdminDb1 zabbix-2.4.7]# chkconfig --list | grep zabbix_agentd

zabbix_agentd       0:off1:off2:on3:on4:on5:on6:off

技术分享

在这里看到6个进程就可以了

测试键值

[[email protected]_AdminDb1 ~]# /usr/local/zabbix_agent/bin/zabbix_get -s 172.29.151.125 -p10050 -k"net.if.in[eth0,bytes]"

本文出自 “Mr.Liang” 博客,请务必保留此出处http://liangml.blog.51cto.com/10852271/1855784

以上是关于zabbix源码包安装的主要内容,如果未能解决你的问题,请参考以下文章

zabbix4.4.4源码编译安装

Zabbix源码安装与yum安装

zabbix源码安装

zabbix3.4服务端安装

zabbix-3.4.14源码安装

zabbix的源码安装