zabbix-2.2.1 下载位置
http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.1/zabbix-2.2.1.tar.gz
目标: 创建 zabbix server 端 RPM 软件包, 方便进行软件分发
安装位置:
应用程序: /apps/svr/zabbix 配置文件: /apps/conf 库文件: /apps/lib 头文件: /apps/include
编译测试
安装需要的库文件
[root@localhost zabbix-2.2.1]# yum install -y net-snmp* curl-devel mysql-devel Dependency Installed: beecrypt.x86_64 0:4.1.2-10.1.1 beecrypt-devel.x86_64 0:4.1.2-10.1.1 curl.i386 0:7.15.5-15.el5 elfutils-devel.x86_64 0:0.137-3.el5 elfutils-devel-static.x86_64 0:0.137-3.el5 elfutils-libelf-devel.x86_64 0:0.137-3.el5 elfutils-libelf-devel-static.x86_64 0:0.137-3.el5 libidn.i386 0:0.6.5-1.1 libidn-devel.x86_64 0:0.6.5-1.1 lm_sensors.x86_64 0:2.10.7-9.el5 lm_sensors-devel.x86_64 0:2.10.7-9.el5 nspr-devel.x86_64 0:4.8.8-2.el5 nss-devel.x86_64 0:3.12.10-8.el5 rpm-devel.x86_64 0:4.4.2.3-27.el5 Complete!
解压 zabbix 服务端
[root@localhost src]# tar xf /root/zabbix-2.2.1.tar.gz -C /usr/src [root@localhost src]# cd /usr/src/zabbix-2.2.1/
测试
./configure --enable-server --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2=/apps/lib/libxml2-2.7.8/bin/xml2-config --with-iconv=/apps/lib/libiconv-1.14 Enable server: yes Server details: With database: MySQL WEB Monitoring: yes Native Jabber: no SNMP: yes IPMI: no SSH: no ODBC: no Linker flags: -rdynamic -L//apps/lib/libiconv-1.14/lib -L/apps/svr/mysql5/lib -L/apps/lib/libxml2-2.7.8/lib -L/usr/kerberos/lib64 -L/usr/lib64 -L/usr/lib64 -L/usr/lib64/lib Libraries: -lm -ldl -lrt -lresolv -liconv -lmysqlclient -lxml2 -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lidn -lssl -lcrypto -lz -lnetsnmp -lcrypto -lm -lwrap -lcrypto Enable proxy: no Enable agent: no Enable Java gateway: no LDAP support: no IPv6 support: no *********************************************************** * Now run ‘make install‘ * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * ***********************************************************
make 成功不报错后退出编译
开始创建 RPM 软件包, 当前使用 rhel5.8
文件说明
spec 文件用于定义编译及 RPM 创建信息, 默认需要存放至 /usr/src/redhat/SPECS/zabbix-2.2.1.spec source 文件用于编译并生成 RPM 文件, 默认需要存放至 /usr/src/redhat/SOURCES/zabbix-2.2.1.tar.gz
默认 spec 模板及简单说明
Name: 软件包名称 Version: 版本 Release: 1%{?dist} 分发版本号 Summary: 摘要 Group: rpm组定义, 可参考 /usr/share/doc/rpm-4.4.2.3/GROUPS 文件获取相关信息 License: 许可 URL: 软件相关 URL Source0: 源码位置 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 编译时的位置 BuildRequires: 编译时需要的软件包依赖 Requires: 安装时需要的软件包依赖 %description 相关软件包描述 %prep 编译前执行的脚本 %setup -q %build %configure 重点, 软件包编译参数 make %{?_smp_mflags} 编译 %install rm -rf %{buildroot} 删除编译后的垃圾文件 make install DESTDIR=%{buildroot} 安装位置定义 %clean rm -rf %{buildroot} 创建 RPM 软件包后, 删除编译安装的软件 %files %defattr(-,root,root,-) 定义 RPM 安装时的文件属性 %doc 文档说明 %changelog 当前 RPM 的简单信息说明
下面是编辑后的 zabbix-2.2.1.spec
Name: zabbix Version: 2.2.1 Release: 20140121.vipclound.el5 Summary: use for monitor openstack VM. Group: Applications/System License: PSF URL: http://www.zabbix.com/download.php Source0: http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.2.1/zabbix-2.2.1.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: autoconf BuildRequires: bzip2 BuildRequires: bzip2-devel BuildRequires: db4-devel BuildRequires: expat-devel BuildRequires: findutils BuildRequires: gcc-c++ BuildRequires: glibc-devel BuildRequires: make BuildRequires: openssl-devel BuildRequires: pkgconfig BuildRequires: readline-devel BuildRequires: sqlite-devel BuildRequires: tar BuildRequires: zlib-devel Requires: curl Requires: curl-devel Requires: nss-devel Requires: nspr-devel Requires: elfutils-devel Requires: beecrypt-devel Requires: net-snmp-devel Requires: mysql-devel ####### # DEFINE LOCATION ####### %define _prefix /apps %define _exec-prefix /apps %define _bindir /apps/svr/zabbix/bin %define _sbindir /apps/svr/zabbix/sbin %define _sysconfdir /apps/conf %define _includedir /apps/include %define _libexecdir /apps/lib %define _infodir /apps/info %define _oldincludedir /apps/include %define _libdir /apps/lib %define _defaultdocdir /apps/man %define _mandir /apps/man %description Zabbix is the ultimate enterprise-level software designed for monitoring availability and performance of IT infrastructure components. Zabbix is open source and comes at no cost. %prep %setup -q %build %configure --enable-server --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2=/apps/lib/libxml2-2.7.8/bin/xml2-config --with-iconv=/apps/lib/libiconv-1.14 make %{?_smp_mflags} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) %{_sysconfdir}/zabbix_server.conf %{_mandir}/man8/zabbix_server.8 %{_sbindir}/zabbix_server %doc %changelog * Wed Jan 22 2014 terrytsang <signmem@hotmail.com> -- example
注, 当前库依赖关系使用到自定义的 libxml2-devel 及 iconv-devel, 各位可自行重新进行定义
编译方法
[root@localhost SPECS]# rpmbuild -bb zabbix-2.2.1.spec
留意编译最后的信息
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/zabbix-2.2.1-20140121.vipclound.el5-A16601 Wrote: /usr/src/redhat/RPMS/x86_64/zabbix-2.2.1-20140121.vipclound.el5.x86_64.rpm Wrote: /usr/src/redhat/RPMS/x86_64/zabbix-debuginfo-2.2.1-20140121.vipclound.el5.x86_64.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.94541 + umask 022 + cd /usr/src/redhat/BUILD + cd zabbix-2.2.1 + rm -rf /var/tmp/zabbix-2.2.1-20140121.vipclound.el5-A16601 + exit 0
软件编译成功后, 默认在 /usr/src/redhat/RPMS 目录中生成, 留意
Wrote: /usr/src/redhat/RPMS/x86_64/zabbix-2.2.1-20140121.vipclound.el5.x86_64.rpm Wrote: /usr/src/redhat/RPMS/x86_64/zabbix-debuginfo-2.2.1-20140121.vipclound.el5.x86_64.rpm
测试软件安装
[root@localhost SPECS]# rpm -ivh /usr/src/redhat/RPMS/x86_64/zabbix-2.2.1-20140121.vipclound.el5.x86_64.rpm Preparing... ########################################### [100%] 1:zabbix ########################################### [100%]