centos 7 lnmp环境编译安装zabbix-3.4.14

Posted fanglingen

tags:

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

一、安装环境(zabbix3.0需要php在5.5版本以上

[[email protected] ~]# cat /etc/redhat-release       
CentOS Linux release 7.3.1611 (Core) 
[[email protected] ~]# netstat -lntup|egrep nginx|mysql
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1268/nginx: master  
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      1268/nginx: master  
tcp        0      0 0.0.0.0:8668            0.0.0.0:*               LISTEN      1268/nginx: master  
tcp        0      0 0.0.0.0:8898            0.0.0.0:*               LISTEN      1268/nginx: master  
tcp        0      0 0.0.0.0:8899            0.0.0.0:*               LISTEN      1268/nginx: master  
tcp6       0      0 :::3306                 :::*                    LISTEN      1186/mysqld         
[[email protected] ~]# ps -ef|grep php|head -1         
root       742     1  0 10月22 ?      00:00:08 php-fpm: master process (/usr/local/php-5.6.30/etc/php-fpm.conf)

二、安装zabbix-server端

1、下载安装源码包

更换阿里源:
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak
wget -O CentOS-Base.repo http://mirrors.aliyuncs.com/repo/Centos-7.repo
清理缓存 yum clean all
重新生成缓存 yum makecache

下载安装包
cd /application/tools/
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/3.4.14/zabbix-3.4.14.tar.gz

2、安装依赖

yum -y install fping net-snmp-devel unixODBC-devel openssl-devel  OpenIPMI-devel java-devel

3、解压并编译

[[email protected] tools]# tar xf zabbix-3.4.14.tar.gz 
[[email protected] tools]# cd zabbix-3.4.14/
[[email protected] zabbix-3.4.14]# ./configure --prefix=/application/zabbix-3.4.14 --enable-server --enable-agent --enable-java --enable-ipv6 --with-mysql  --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-unixodbc --with-openssl
make
make install
ln -s /application/zabbix-3.4.14/ /application/zabbix
useradd zabbix -s /sbin/nologin -M
chown -R zabbix.zabbix /application/zabbix

4、在mysql数据库创建zabbix库和zabbix用户,及授权zabbix用户管理zabbix库

mysql -uroot -p1q2w3e
create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to [email protected]127.0.0.1 identified by zabbix;     
flush privileges;
quit

5、找到解压zabbix软件的目录,导入数据到数据库:

[[email protected] zabbix-3.4.14]# cd /application/tools/zabbix-3.4.14/database/mysql/
[[email protected] mysql]# ll
总用量 4876
-rw-r--r-- 1 mysql mysql 2877497 9月  14 16:05 data.sql
-rw-r--r-- 1 mysql mysql 1978341 9月  14 16:04 images.sql
-rw-r--r-- 1 mysql mysql  134791 9月  14 16:05 schema.sql

6、注意导入的顺序

mysql -uroot -p1q2w3e
use zabbix
source /application/tools/zabbix-3.4.14/database/mysql/schema.sql
source /application/tools/zabbix-3.4.14/database/mysql/images.sql
source /application/tools/zabbix-3.4.14/database/mysql/data.sql;
show tables;
quit

7、创建zabbix web站点目录

mkdir /www/zabbix -p
cp -a /application/tools/zabbix-3.4.14/frontends/php/* /www/zabbix/
chown -R www.www /www/zabbix

8、配置zabbix

1)、php配置,操作命令

查看:
[[email protected] mysql]# egrep -n "^post_max_size|^max_execution_time|^max_input_time|^date.timezone" /usr/local/php/etc/php.ini
373:max_execution_time = 30
383:max_input_time = 60
662:post_max_size = 8M
951:date.timezone = "Asia/Shanghai"
修改:
[[email protected] mysql]# sed -i s#max_execution_time = 30#max_execution_time = 300#;s#max_input_time = 60#max_input_time = 300#;s#post_max_size = 8M#post_max_size = 16M#;910a date.timezone = Asia/Shanghai /usr/local/php/etc/php.ini
[[email protected] mysql]# egrep -n "^post_max_size|^max_execution_time|^max_input_time|^date.timezone" /usr/local/php/etc/php.ini
373:max_execution_time = 300
383:max_input_time = 300
662:post_max_size = 16M
911:date.timezone = Asia/Shanghai    #已经添加了删除
952:date.timezone = "Asia/Shanghai"  


  pkill php

  ps -ef|grep php

  /usr/local/php/sbin/php-fpm

  ps -ef|grep php

2)、配置nginx

# 执行命令前注意备份Nginx配置文件!!
cp  /usr/local/nginx/conf/nginx.conf{,ori}
[[email protected] vhosts]# cat  >/usr/local/nginx/conf/vhosts/zabbix.com <<EOF
server
        {
                listen       80;
                server_name zabbix.lvcard.cn;
                index index.html index.htm index.php index.shtml;
                root  /www/zabbix;
                location / {
                   ssi on;
                   ssi_silent_errors on;
                   ssi_types text/shtml;
        }

        location ~ .*.(php|php5)?* {
        root    /www/zabbix;
        access_log off;
        fastcgi_pass unix:/dev/shm/php-fcgi.sock;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME       /www/zabbix$fastcgi_script_name;
    }
        access_log  /www/zabbix/logs/zabbix-access.log;
        error_log   /www/zabbix/logs/zabbix-error.log crit;
        }
<<EOF

/usr/local/nginx/sbin/nginx -s reload

 3)、配置zabbix

sed -i -e 86a DBHost=127.0.0.1 -e 116a DBPassword=zabbix /application/zabbix/etc/zabbix_server.conf

4)、启动脚本

cp /application/tools/zabbix-3.4.14/misc/init.d/fedora/core/zabbix_{server,agentd} /etc/init.d/

5)、修改启动脚本

sed -i s#BASEDIR=/usr/local#BASEDIR=/application/zabbix# /etc/init.d/zabbix_{server,agentd}

6)、启动脚本并加入开机自动启动

chkconfig --add zabbix_agentd
chkconfig --add zabbix_server
chkconfig --list 
LANG=en_US.UTF-8
chkconfig zabbix_server on 
chkconfig zabbix_agentd on
LANG=zh_CN.UTF-8

/etc/init.d/zabbix_server start

 

以上是关于centos 7 lnmp环境编译安装zabbix-3.4.14的主要内容,如果未能解决你的问题,请参考以下文章

centos7源码编译安装LNMP+ZABBIX4.0LTS——php

CentOS 7安装zabbix-2.4.8监控

centos7源码编译安装LNMP+ZABBIX4.0LTS——zabbix server+zabbix agent

centos6.5lnmp环境 zabbix监控平台搭建

CentOS7.2 LNMP安装部署zabbix3.2

源码编译LNMP+最新版zabbix4.0