Zabbix安装手记[原创]

发布于 2022-08-05 12:21:09 字数 13904 浏览 23 评论 6

一.adduser zabbix
二.passwd zabbix
testpasswd
三.下载源代码
wget http://prdownloads.sourceforge.n ... 4.6.tar.gz?download

wget http://freeware.sgi.com/source/freetype2/freetype-2.1.3.tar.gz
wget http://www.zlib.net/zlib-1.2.3.tar.gz
wget http://freeware.sgi.com/source/libjpeg/libjpeg-6b.tar.gz
wget http://prdownloads.sourceforge.n ... .30.tar.gz?download
wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz
wget http://openssl.org/source/openssl-0.9.8h.tar.gz
wget http://cn.php.net/get/php-5.2.6.tar.gz/from/this/mirror
wget http://dev.mysql.com/get/Downloa ... mysql.byungsoo.net/
wget http://downloads.sourceforge.net ... 50&big_mirror=1
wget ftp://xmlsoft.org/libxml2/libxml2-sources-2.6.32.tar.gz
wget http://www.execve.net/curl/curl-7.15.5.tar.gz
#wget http://www.execve.net/curl/curl-7.18.2.tar.gz

#确认系统是是否安装有如下软件包,如果不存在则需要安装相应的RPM软件包。
#libxml2-devel
#libxml2
#curl-devel
#curl

四.编译代码到目标执行文件

BASE=/usr/local/zabbix.146
LD_RUN_PATH=$BASE/openssl/lib:$BASE/mysql/lib/:$BASE/zlib/lib:$BASE/gd/lib:$BASE/libxml2/lib:$BASE/curl/lib
#LD_RUN_PATH=$BASE/openssl/lib:/usr/local/mysql5.1/lib:$BASE/zlib/lib:$BASE/gd/lib:$BASE/libxml2/lib:$BASE/curl/lib
export LD_RUN_PATH
1.)ZLIB
ZLIB=$BASE/zlib
tar xzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=$ZLIB
make && make install
2.)LIBICONV
LIBICONV=$BASE/gd
tar xzf libiconv-1.9.2.tar.gz
cd libiconv-1.9.2
./configure --prefix=$LIBICONV --enable-static=yes

make && make install
3.)FREETYPE
FREETYPE=$BASE/gd
tar xzf freetype-2.1.3.tar.gz
cd freetype-2.1.3
./configure --prefix=$FREETYPE
make && make install
4.)LIBJPEG
LIBJPEG=$BASE/gd
tar xzf libjpeg-6b.tar.gz
cd libjpeg-6b
./configure --prefix=$LIBJPEG --enable-shared
mkdir $BASE/gd/man/man1
make & make install
5.)LIBPNG
LIBPNG=$BASE/gd
tar xzf libpng-1.2.30.tar.gz
cd libpng-1.2.30
LDFLAGS="-L$BASE/zlib/lib -Wl,-R$BASE/zlib/lib/"
CPPFLAGS="-I$BASE/zlib/include"
export LDFLAGS CPPFLAGS
./configure --prefix=$LIBPNG
make & make install

6.)LIBXML
LIBXML=$BASE/libxml2
tar xzf libxml2-sources-2.6.32.tar.gz
cd libxml2-2.6.32
./configure --prefix=$LIBXML --with-iconv=$BASE/gd --with-zlib=$BASE/zlib
make & make install
7.)GD
GD=$BASE/gd
tar xzf gd-2.0.35RC4.tar.gz
cd gd-2.0.35RC4
./configure --prefix=$GD --with-png=$BASE/gd --with-freetype=$BASE/gd --with-jpeg=$BASE/gd

make & make install

8.)OPENSSL
OPENSSL=$BASE/openssl
./config --prefix=$OPENSSL no-threads shared -fPIC
make && make test && make install
9.)MYSQL
tar xzf mysql-5.1.25-rc.tar.gz
cd mysql-5.1.25-rc
CFLAGS="-O3 -mpentiumpro"
CXX="gcc"
CXXFLAGS="-O3 -mpentiumpro -felide-constructors"
export CFLAGS CXX CXXFLAGS
./configure --prefix=$BASE/mysql --enable-assembler
--with-charset=gbk --with-extra-charsets=gb2312,latin1,utf8,gb18030
--enable-largefile --with-big-tables --without-debug --with-max-indexes=64
--with-zlib-dir=$ZLIB_BASE
--with-mysqld-ldflags=-all-static --without-ndbcluster
make & make install
mkdir $MYSQL_BASE/var
cp $MYSQL_BASE/share/mysql/my-large.cnf $MYSQL_BASE/var/my.cnf
$MYSQL_BASE/bin/mysql_install_db

【注意】

如果提示”/usr/local/php-5.2.5/sapi/cli/php:error while loading shared libraries: /usr/local/mysql/lib/libmysqlclient.so.16:cannot restore segment prot after reloc: Permission denied”

原因:SELinux

解决方法:chcon –t texrel_shlib_t /usr/local/mysql/lib/libmysqlclient.so.16

10.)APACHE

export LDFLAGS="-L$BASE/openssl/lib -Wl,-R$BASE/openssl/lib"
       export CPPFLAGS="-I$BASE/openssl/include"
./configure --prefix=$BASE/apache --enable-ssl --with-ssl=$BASE/openssl
   --enable-so --enable-mods-shared=most
  --enable-dav --enable-maintainer-mode
make &&make install

11.)NET-SNMP
NETSNMP=$BASE/net-snmp
cd net-snmp-$SNMP_VERSION/
./configure --prefix=$NETSNMP --with-openssl=$OPENSSL
        --with-default-snmp-version=3
        --with-sys-contact=guilin.yang@ambow.com --with-sys-location=Unknown
        --with-logfile=/var/log/snmpd.log --with-persistent-directory=/var/net-snmp
make
make install
cd ..

$BASE/net-snmp/sbin/snmpd -c /etc/snmp/snmpd.conf -Lsd -Lf /dev/null -p /var/run/snmpd.pid -a
12.)PHP

./configure --prefix=$BASE/php --with-apxs2=$BASE/apache/bin/apxs
        --with-openssl=$BASE/openssl --with-mysql=$BASE/mysql
        --with-zlib-dir=$BASE/zlib --with-jpeg-dir=$BASE/gd
        --with-png-dir=$BASE/gd --with-freetype-dir=$BASE/gd
        --with-ttf --enable-gd-native-ttf --enable-mbstring=cn
        --with-gd --enable-sockets --enable-dio --enable-bcmath
        --with-iconv-dir=$BASE/gd --with-snmp=$BASE/net-snmp
        --with-libxml-dir=$BASE/libxml2

# --without-sqlite --disable-json 有待验证

make
make install

cp php.ini-dist $PHP_BASE/lib/php.ini
#修改 $APACHE_BASE/conf/httpd.conf
AddType application/x-httpd-php .php .phtml .php4 .inc
DirectoryIndex index.php

13.)CURL
tar xzf curl-7.18.2.tar.gz
LDFLAGS="-L$BASE/openssl/lib -Wl,-R$BASE/openssl/lib -L$BASE/mysql/lib -Wl,-R$BASE/mysql/lib -L$BASE/net-snmp/lib -Wl,-R$BASE/net-snmp/lib -L/usr/lib -Wl,-R/usr/lib -L$BASE/zlib/lib -Wl,-R$BASE/zlib/lib -L$BASE/curl/lib -Wl,-R$BASE/curl/lib"
##LDFLAGS="-L$BASE/openssl/lib -Wl,-R$BASE/openssl/lib -L/usr/local/mysql5.1/lib -Wl,-R/usr/local/mysql5.1/lib -L$BASE/net-snmp/lib -Wl,-R$BASE/net-snmp/lib -L/usr/lib -Wl,-R/usr/lib -L$BASE/zlib/lib -Wl,-R$BASE/zlib/lib -L$BASE/curl/lib -Wl,-R$BASE/curl/lib"
export LDFLAGS CPPFLAGS
cd curl-7.18.2
./configure --prefix=$BASE/curl  --with-ssl=$BASE/openssl --with-zlib=$BASE/zlib
make && make install

14.)ZABBIX
LDFLAGS="-L$BASE/mysql/lib -Wl,-R$BASE/mysql/lib -L$BASE/net-snmp/lib -Wl,-R$BASE/net-snmp/lib -L$BASE/zlib/lib -Wl,-R$BASE/zlib/lib -L$BASE/curl/lib -Wl,-R$BASE/curl/lib"
CPPFLAGS="-I$BASE/openssl/include/openssl -I$BASE/mysql/include/mysql -I$BASE/mysql/include/net-snmp"
export LDFLAGS CPPFLAGS

./configure --prefix=$BASE/zabbix --with-mysql=$BASE/mysql/bin/mysql_config
        --with-net-snmp=$BASE/net-snmp/bin/net-snmp-config --with-libcurl=$BASE/curl/bin/curl-config
        --enable-server --enable-agent

------------------------------
#whether libcurl is usable... no
#--enable-static don't use it.
------------------------------
#Not found z library
#LDFLAGS="--L$BASE/zlib/lib -Wl,-R$BASE/zlib/lib"  do it.

#LIBCURL_CPPFLAGS=''
#LIBCURL_LDFLAGS=' -L$BASE/zabbix/lib'
#LIBCURL_LIBS='-lcurl '
make && make install

五.初始化zabbix环境
1.)mysql
mysql -e"create database zabbix;"
mysql -e"grant all privileges on zabbix.* to zabbix@localhost identified by 'ambow99999999';"
cd path/zabbix-1.4.6
mysql -u zabbix -pambow99999999 --default-character-set=utf8 -D zabbix < create/schema/mysql.sql
mysql -u zabbix -pambow99999999 --default-character-set=utf8 -D zabbix < create/data/data.sql
mysql -u zabbix -pambow99999999 --default-character-set=utf8 -D zabbix < create/data/images_mysql.sql

vi /etc/services
zabbix_agent 10050/tcp # Zabbix ports
zabbix_trap 10051/tcp

mkdir /etc/zabbix
chown -R zabbix.zabbix /etc/zabbix/
cp misc/conf/zabbix_* /etc/zabbix/

vim /etc/zabbix/zabbix_agentd.conf

Server=127.0.0.1

vim /etc/zabbix/zabbix_server.conf

# Database user
DBUser=zabbix
# Database password
# Comment this line if no password used
DBPassword=ambow99999999

cp misc/init.d/redhat/zabbix_server_ctl  /etc/init.d/
cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/

vim /etc/init.d/zabbix-server

# zabbix-server:       Starts the Zabbix Server
#
# Version:      @(#) /etc/init.d/zabbix-server 2.0
#
# chkconfig: 2345 90 15
# description: Starts and stops the Zabbix Server at boot time and shutdown.
#              It also takes care of (re-)generating font lists.
#
# processname: zabbix-server
# config: /etc/zabbix/zabbix_server.conf
# hide: true
BASEDIR=/PATH
chkconfig --add zabbix-server

vim /etc/init.d/zabbix-agent
# zabbix-agent:       Starts the Zabbix Agent
#
# Version:      @(#) /etc/init.d/zabbix-agent 2.0
#
# chkconfig: 2345 90 19
# description: Starts and stops the Zabbix Agent at boot time and shutdown.
#              It also takes care of (re-)generating font lists.
#
# processname: zabbix-agent
# config: /etc/zabbix/zabbix_agent.conf
# hide: true

chkconfig --add zabbix-agent

/etc/init.d/zabbix-server start
/etc/init.d/zabbix-agent start

mkdir $BASE/apache/htdocs/zabbix_php

cp -Rpf frontends/php/* $BASE/apache/htdocs/zabbix_php/

vi $BASE/apache/conf/httpd.conf
Alias /zabbix $BASE/apache/htdocs/zabbix_php/
<Directory $BASE/apache/htdocs/zabbix_php>
  AllowOverride FileInfo AuthConfig Limit Indexes
  Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
  <Limit GET POST OPTIONS PROPFIND>
    Order allow,deny
    Allow from all
  </Limit>
  <LimitExcept GET POST OPTIONS PROPFIND>
    Order deny,allow
    Deny from all
  </LimitExcept>
</Directory>

vi php.ini
max_execution_time = 300 ; Maximum execution time of each script, in seconds
date.timezone = Asia/Shanghai
原文档里,date.timezone = Asia/Shanghai前面还有个分号呢,记得去掉,要不命令是无法生效的

Client Linux

./configure --prefix=/usr/local/zabbix --enable-agent
make && make install

cp misc/init.d/redhat/zabbix_agentd_ctl /etc/init.d/

useradd zabbix
passwd zabbix
mkdir /etc/zabbix
cp misc/conf/zabbix_* /etc/zabbix/
chown -R zabbix:zabbix /etc/zabbix
vi /etc/zabbix/zabbix_agentd.conf
vi /etc/init.d/zabbix_agentd_ctl
/etc/init.d/zabbix_agentd_ctl start
vi /etc/rc.local

Client Windows

pathzabbix_agentd.exe -c pathzabbix_agentd.conf -i        #将程序添加为windows系统服务

登陆

http://IP/zabbix
用户名admin,初始密码为空.

OS Setup

iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 10050 -j ACCEPT
iptables -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 10051 -j ACCEPT

[ 本帖最后由 ygl23 于 2008-12-13 18:31 编辑 ]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

二手情话 2022-08-16 23:06:14

很好,很强大,让我不解的问题,在这里找到了答案
楼主有联系方式不?请加我QQ啊

从﹋此江山别 2022-08-16 14:53:15

关注 学习一下

祁梦 2022-08-16 05:56:25

我走过,我顶过 哈哈

阿楠 2022-08-11 20:06:05

情绪失控 2022-08-11 06:40:38

谢谢分享   

舟遥客 2022-08-09 03:53:02

好文,强大

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文