一键编译安装zabbix3.2.5server

Posted

tags:

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

公司计划使用zabbix监控所有产品服务器,现需要对zabbix进行测试!

系统采用最小化安装,选包如下:

Base
Compatibility libraries
Debugging Tools
Development tools

系统信息如下:

# cat /etc/redhat-release 
CentOS release 6.8 (Final)
# uname -r
2.6.32-642.el6.x86_64
# uname -m
x86_64

公司产品基本是tomcat环境,zabbix server编译安装需要--with-java参数,jdk环境搭建如下:

mkdir /server/tools
mkdir /application
#download link  
tar xf jdk-8u131-linux-x64.tar.gz
mv jdk1.8.0_131 /application/
ln -s /application/jdk1.8.0_131/ /application/jdk
chown -R root.root /application/jdk
vim /etc/profile
export JAVA_HOME=/application/jdk
export JRE_HOME=/application/jdk/jre
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
source /etc/profile

基本安装脚本如下:(注:脚本缺少一些判断语句)

#!/bin/bash
#修改yum源,采用阿里云源
function mod_yum(){
  if [ -e /etc/yum.repos.d/CentOS-Base.repo ]
     then
     mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup&&     wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/CentOS-6.repo
     wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
  fi
}
#mysql采用5.6.36(zabbix3.2.5需要mysql5.4以上版本)
function install_mysql(){
    useradd -s /sbin/nologin -M mysql
    wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz
    tar xf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz 
    mv mysql-5.6.36-linux-glibc2.5-x86_64 /application/mysql-5.6.36
    ln -s /application/mysql-5.6.36/ /application/mysql
    chown -R mysql.mysql /application/mysql/
    cd /application/mysql/
    rm -f /etc/my.cnf
    cp support-files/my-default.cnf /etc/my.cnf
    ./scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
    sed -i ‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe
    /application/mysql/bin/mysqld_safe &
    echo ‘PATH=/application/mysql/bin:$PATH‘>> /etc/profile
    source /etc/profile
    cd /server/tools/
    mysqladmin -uroot password 123456
}
#安装apache,版本2.2.32
function install_httpd(){
    cd /server/tools
    useradd -s /sbin/nologin -M www
    wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.2.32.tar.gz
    tar xf httpd-2.2.32.tar.gz 
    cd httpd-2.2.32
    yum install zlib zlib-devel -y
    ./configure --prefix=/application/apache2.2.32 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite
    make
    make install
    ln -s /application/apache2.2.32/ /application/apache
    sed -i ‘s#User daemon#User www#g‘ /application/apache/conf/httpd.conf
    sed -i ‘s#Group daemon#Group www#g‘ /application/apache/conf/httpd.conf
    cd /server/tools
}
#安装php依赖包
function pre_install_php(){
    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
    tar xf libiconv-1.14.tar.gz
    cd libiconv-1.14
    ./configure --prefix=/usr/loca/libiconv
    make
    make install
    yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
    yum -y install  freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
    yum -y install libmcrypt-devel
    yum -y install mhash
    yum -y install mcrypt
    yum -y install openssl openssl-devel
    ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
    ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/libmysqlclient.so.18
    chmod 755 /usr/lib64/libmysqlclient.so.18
    chmod 755 /usr/lib/libmysqlclient.so.18
    ldconfig
}
#安装php,版本5.5.32
function install_php(){
    cd /server/tools
    wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
    tar xf php-5.5.32.tar.gz 
    cd php-5.5.32
./configure --prefix=/application/php5.5.32 --with-mysql=/application/mysql --with-mysqli=/application/mysql/bin/mysql_config --with-apxs2=/application/apache/bin/apxs --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --with-gettext --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no 
    make
    make install
    ln -s /application/php5.5.32 /application/php
    cp php.ini-production /application/php/lib/php.ini
}
#修改apache的httpd.conf文件,使apache支持php,采用php模块方式
function after_php(){
    sed -i ‘320i AddType application/x-httpd-php .php .phtml\nAddType application/x-httpd-php-source .phps‘ /application/apache/conf/httpd.conf
    sed -i ‘s#DirectoryIndex index.html#DirectoryIndex index.php index.html#g‘ /application/apache/conf/httpd.conf
    sed -i ‘s/#ServerName www.example.com:80/ServerName *:80/g‘ /application/apache/conf/httpd.conf
    /application/apache/bin/apachectl start
}
#安装zabbix依赖包
#如果不要安装agent,可以去掉--enable-agent
#如果不需要监控设备硬件,可以去掉--with-openipmi
function pre_install_zabbix_server(){
    cd /server/tools
    wget https://fossies.org/linux/misc/zabbix-3.2.5.tar.gz
    tar -xf zabbix-3.2.5.tar.gz
    cd zabbix-3.2.5
    yum -y install curl libcurl-devel net-snmp net-snmp-devel perl-DBI libdbi-dbd-mysql mysql-devel gcc gcc++ make libxml2 libxml2-devel
    yum -y install libssh2-devel.x86_64
    yum -y install OpenIPMI
    yum -y install OpenIPMI-devel
    useradd -s /sbin/nologin -M zabbix
    mysql -uroot -p123456 -e "create database zabbix DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;"
    mysql -uroot -p123456 -e "grant all on zabbix.* to [email protected]‘localhost‘ identified by ‘zabbix‘;"
    mysql -uroot -p123456 -e "flush privileges;"
    mysql -uzabbix -pzabbix zabbix < database/mysql/schema.sql
    mysql -uzabbix -pzabbix zabbix < database/mysql/images.sql 
    mysql -uzabbix -pzabbix zabbix < database/mysql/data.sql 
}
#安装zabbix
function install_zabbix(){
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql --with-libxml2 --with-net-snmp --with-ssh2 --with-openipmi --with-libcurl 
make
make install
cp -R frontends/php /application/apache/htdocs/
chown -R www.www /application/apache/htdocs/php
cp -a misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
sed -i ‘s#/usr/local#/usr/local/zabbix#g‘ /etc/init.d/zabbix_server 
mkdir /var/log/zabbix
chown -R zabbix.zabbix /var/log/zabbix
sed -i ‘s#LogFile=/tmp/zabbix_server.log#LogFile=/var/log/zabbix/zabbix_server.log#g‘
sed -i ‘s/# DBHost=localhost/DBHost=localhost/g‘ /usr/local/zabbix/etc/zabbix_server.conf
sed -i ‘s/# DBPassword=/DBPassword=zabbix/g‘ /usr/local/zabbix/etc/zabbix_server.conf
/etc/init.d/zabbix_server start 
sed -i ‘s#max_execution_time = 30#max_execution_time = 300#g‘ /application/php/lib/php.ini 
sed -i ‘s#max_input_time = 60#max_input_time = 300#g‘ /application/php/lib/php.ini          
sed -i ‘s#post_max_size = 8M#post_max_size = 16M#g‘ /application/php/lib/php.ini            
sed -i ‘s#;date.timezone =#date.timezone = Asia/Shanghai#g‘ /application/php/lib/php.ini    
cat >> /application/apache/conf/httpd.conf <<EOF
Alias /zabbix /application/apache/htdocs/php 
<Directory "/application/apache/htdocs/php">
    Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all
</Directory>
EOF
/application/apache/bin/apachectl graceful 
}
function main(){
    mod_yum
    install_mysql
    install_httpd
    pre_install_php
    install_php
    after_php
    pre_install_zabbix_server
    install_zabbix
}
main


本文出自 “迷失在Linux” 博客,请务必保留此出处http://zihang.blog.51cto.com/158746/1920448

以上是关于一键编译安装zabbix3.2.5server的主要内容,如果未能解决你的问题,请参考以下文章

一键安装MySQL5.6.43脚本

Web环境搭建Nginx+Tomcat流行动态-一键完成

一键安装lamp环境 centos

go语言学习笔记 — 基础 — go工具:一键获取源代码,编译并安装 —— go get

zabbix-server一键安装脚本

lnmp+zabbix一键部署脚本