zabbix 安装(离线源码安装)
Posted wufj
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix 安装(离线源码安装)相关的知识,希望对你有一定的参考价值。
1、LAMP 环境搭建
1.1 、安装 apache
- 安装 pcre
tar -zxvf pcre-8.41.tar.gz cd pcre-8.41 ./configure --prefix=/home/pcre make make install
- 安装 apr
tar -zxvf apr-1.6.5.tar.gz cd apr-1.6.5 ./configure --prefix=/home/apr make make install
- 安装 expat
tar -zxvf expat-2.1.0.tar.gz cd expat-2.1.0 ./configure --prefix=/home/expat make make install
- 安装 apr-util
tar -zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/home/apr-util --with-apr=/home/apr/--with-expat=/home/expat/ make make install
- 安装 httpd
tar -zxvf httpd-2.4.34.tar.gz cd httpd-2.4.34 ./configure --prefix=/home/httpd --with-pcre=/home/pcre/--with-apr=/home/apr --with-apr-util=/home/apr-util/--enable-so make make install
- 配置 httpd
vi /home/httpd/conf/httpd.conf 修改 Server Name,去掉注释 # ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup. # # If your host doesn‘t have a registered DNS name, enter its IP address here. # #ServerName www.example.com:80 ServerName localhost:80
- 复制启动脚本到 etc/init.d 下,并添加开机自启
cp /home/httpd/bin/apachectl /etc/init.d/httpd chkconfig httpd on # centos7 用systemctl enable httpd
- 启动
service httpd start
1.2、安装 mysql
- 安装 MySQL
tar -zxvf mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.23-linux-glibc2.12-x86_64 /home/mysql mkdir /home/mysql/data groupadd mysql useradd mysql -g mysql
- 初始化数据及配置配置文件
/home/mysql/bin/mysql_install_db --user=mysql --basedir=/home/mysql/--datadir=/home/mysql/data/ 删除原配置文件 rm -rf /etc/my.cnf 修改配置文件 vi /home/mysql/support-files/mysql.server # Set some defaults mysqld_pid_file_path= if test -z "$basedir" then basedir=/usr/local/mysql bindir=/usr/local/mysql/bin if test -z "$datadir" then datadir=/usr/local/mysql/data fi sbindir=/usr/local/mysql/bin libexecdir=/usr/local/mysql/bin 修改为: then basedir=/home/mysql bindir=/home/mysql/bin if test -z "$datadir" then datadir=/home/mysql/data fi sbindir=/home/mysql/bin libexecdir=/home/mysql/bin 复制启动脚本: cp /home/mysql/support-files/mysql.server /etc/init.d/mysql
- 启动 MySQL
chkconfig mysql on
service mysql start
- 登陆并初始化 MySQL 密码
ln -s /home/mysql/bin/mysql /usr/bin/ 查看原始密码 cat /root/.mysql_secret 登录并修改密码 mysql -uroot -p set password for‘root‘@localhost=password(‘123456‘);
1.3、安装 php
- 安装 perl
tar -zxvf perl-5.28.0.tar.gz cd perl-5.28.0 ./configure.gnu -des -Dprefix=/home/perl -Dusethreads -Uversiononly make make install 修改apxs vi /home/httpd/bin/apxs /replace/with/path/to/perl/interpreter修改为-->/home/perl/bin/perl
- 安装 python-devel
- 安装 libxml2
tar -zxvf libxml2-2.9.6.tar.gz cd libxml2-2.9.6 ./configure --prefix=/home/libxml2 make make install
- 安装 zlib
tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make make install
- 安装 bzip2
tar -zxvf bzip2-1.0.6.tar.gz cd bzip2-1.0.6 make -f Makefile-libbz2_so make make install
- 安装 curl
tar -xvf curl-7.61.1.tar.gz cd curl-7.61.1 ./configure --prefix=/home/curl make make install
- 安装 Berkeley DB
tar -zxvf db-4.7.25.tar.gz cd db-4.7.25/build_unix ../dist/configure --prefix=/home/berkeleyDB make make install
- 安装 jpeg
tar -zxvf jpegsrc.v9c.tar.gz cd jpeg-9c/ ./configure --prefix=/home/jpeg --enable-shared --enable-static make make install
- 安装 png
tar -zxvf libpng-1.6.35.tar.gz cd libpng-1.6.35 cp scripts/makefile.linux makefile vi makefile 修改: prefix=/home/png ZLIBLIB=/home/zlib/lib ZLIBINC=/home/zlib/include 保存 make make install
- 安装 freetype
tar -xvf freetype-2.5.3.tar.gz cd freetype-2.5.3 ./configure --prefix=/home/freetype make make install
- 安装 openldap
exportCPPFLAGS="-I/home/berkeleyDB/include -D_GNU_SOURCE" exportLDFLAGS="-L/home/berkeleyDB/lib" exportLD_LIBRARY_PATH="/home/berkeleyDB/lib" tar -zxvf openldap-2.4.46.tgz cd openldap-2.4.46 ./configure --prefix=/home/openldap make depend make make install
- 安装 PHP
tar -zxvf php-7.1.22.tar.gz cd php-7.1.22 ./configure --prefix=/home/php --enable-fpm --with-config-file-path=/home/php/etc/--with-pdo_mysql --with-bz2 --with-iconv-dir --with-zlib-dir --enable-soap --enable-mbstring --enable-exif --enable-sockets --enable-pcntl --disable-debug --with-db4=/home/berkeleyDB/--with-gd --with-curl=/home/curl/--enable-gd-native-ttf --enable-zip --enable-bcmath --with-gettext --with-apxs2=/home/httpd/bin/apxs --with-png-dir=/home/png/--with-jpeg-dir=/home/jpeg/--with-freetype-dir=/home/freetype/--enable-shared --with-ldap=/home/openldap/--with-mysqli --enable-static--with-libxml-dir=/home/libxml2/ make make install
- 配置 PHP 相关配置文件
cp sapi/fpm/php-fpm.conf /home/php/etc/ cp php.ini-production /home/php/etc/php.ini cp /home/php/etc/php-fpm.d/www.conf.default/home/php/etc/php-fpm.d/www.conf cp sapi/fpm/init.d.php-fpm /etc/init.d/php 设置启动脚本并启动 chmod +x /etc/init.d/php chkconfig php on service php start
- 配置 apache 支持解析 PHP
vi /home/httpd/conf/httpd.conf 在 AddType application/x-compress .Z AddType application/x-gzip .gz .tgz 后面添加 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 在 DirectoryIndex index.html Indexphp 重启apache service httpd restart
- 安装 m4
tar -zxvf m4-1.4.18.tar.gz cd m4-1.4.18 ./configure make make install
- 安装 autoconf
tar -zxvf autoconf-2.65.tar.gz cd autoconf-2.65 ./configure make make install
- 安装 automake
tar -xvf automake-1.15.tar.xz cd automake-1.15 ./configure make make install
2、zabbix 安装
2.1、zabbix-server 安装
- 安装 unixODBC
tar -zxvf unixODBC-2.3.7.tar.gz cd unixODBC-2.3.7 ./configure --prefix=/home/unixODBC make make install
- 安装 libevent
tar -zxvf libevent-2.1.8-stable.tar.gz cd libevent-2.1.8-stable ./configure --prefix=/home/libevent make make install
- 安装 zabbix
tar -zxvf zabbix-3.4.14.tar.gz cd zabbix-3.4.14 ./configure --prefix=/home/zabbix --enable-server --enable-agent --with-mysql=/home/mysql/bin/mysql_config --with-libcurl=/home/curl/bin/curl-config --with-libxml2=/home/libxml2/bin/xml2-config --with-unixodbc=/home/unixODBC/bin/odbc_config --with-libevent=/home/libevent/--with-libpcre=/home/pcre/ make make install
- 建立zabbix组与zabbix用户
groupadd zabbix
useradd -g zabbix zabbix -s /sbin/nologin
- 创建zabbix数据库及zabbix帐号
mysql -uroot -p create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to zabbix@‘%‘ identified by ‘zabbix‘; grant all privileges on zabbix.* to zabbix@‘%‘ identified by ‘zabbix‘; grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix‘; grant all privileges on zabbix.* to zabbix@localhost.localdomain identified by ‘zabbix‘; flush privileges;
- 导入 zabbix 初始数据
cd /home/install/zabbix-3.4.14/database/mysql/ mysql -uzabbix -pzabbix zabbix < schema.sql mysql -uzabbix -pzabbix zabbix < images.sql mysql -uzabbix -pzabbix zabbix < data.sql
- 修改配置文件
vi /home/zabbix/etc/zabbix_server.conf 修改: DBHost=127.0.0.1 DBName=zabbix DBUser=zabbix DBPassword=zabbix LogFile=/home/zabbix/logs/zabbix_server.log
- 配置zabbix启动脚本并启动
cp /home/install/zabbix-3.4.14/misc/init.d/tru64/zabbix_server /etc/init.d/ chmod +x /etc/init.d/zabbix_server vi /etc/init.d/zabbix_server 修改: DAEMON=/home/zabbix/sbin/zabbix_server chkconfig zabbix_server on ln -s /home/mysql/lib/libmysqlclient.so.20/usr/lib64/ ln -s /home/unixODBC/lib/libodbc.so.2/usr/lib64/ ln -s /home/libevent/lib/libevent-2.1.so.6/usr/lib64/ chown -R zabbix /home/zabbix/logs/ chmod +x /home/zabbix/logs/ service zabbix_server start
- 把 zabbix 页面移到 httpd 目录中
cp -r /home/install/zabbix-3.4.14/frontends/php//home/httpd/htdocs/zabbix chown -R zabbix.zabbix /home/httpd/htdocs/ cp /home/httpd/htdocs/zabbix/conf/zabbix.conf.php.example /home/httpd/htdocs/zabbix/conf/zabbix.conf.php vi /home/httpd/htdocs/zabbix/conf/zabbix.conf.php 修改 // Zabbix GUI configuration file. global $DB, $HISTORY; $DB[‘TYPE‘]=‘MYSQL‘; $DB[‘SERVER‘]=‘localhost‘; $DB[‘PORT‘]=‘0‘; $DB[‘DATABASE‘]=‘zabbix‘; $DB[‘USER‘]=‘zabbix‘; $DB[‘PASSWORD‘]=‘zabbix‘;
- 修改 PHP 参数配置
vi /home/php/etc/php.ini 修改: date.timezone= Asia/Shanghai max_execution_time =300 post_max_size =32M memory_limit =128M mbstring.func_overload =1 max_input_time =300 重启PHP和apache
2.2、客户端安装
- 安装 gcc
unzip gcc4.8.5.zip cd gcc4.8.5 7.2/ rpm -Uvh *.rpm --nodeps --force
- 安装 pcre
tar -zxvf pcre-8.41.tar.gz cd pcre-8.41 ./configure --prefix=/home/pcre make make install
- 安装 zabbix-agentd
tar -zxvf zabbix-3.4.14.tar.gz cd zabbix-3.4.14/ ./configure --prefix=/home/zabbix --enable-agent --with-libpcre=/home/pcre/ make make install
- 配置 zabbix_agentd 启动文件
cp misc/init.d/tru64/zabbix_agentd /etc/init.d/ chmod +x /etc/init.d/zabbix_agentd vi /etc/init.d/zabbix_agentd 修改下面这项 DAEMON=/home/zabbix/sbin/zabbix_agentd
- 配置 zabbix_agentd 配置文件
vi /home/zabbix/etc/zabbix_agentd.conf LogFile=/home/zabbix/logs/zabbix_agentd.log Server=192.168.x.x #服务端ip ServerActive=192.168.x.x #服务端ip Hostname=fwqxx EnableRemoteCommands=1 UnsafeUserParameters=1 Include=/home/zabbix/etc/zabbix_agentd.conf.d/*.conf Timeout=10
- 启动
service zabbix_agentd start
以上是关于zabbix 安装(离线源码安装)的主要内容,如果未能解决你的问题,请参考以下文章