码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-11-05 16:14:46      阅读:378      评论:0      收藏:0      [点我收藏+]

标签:ati   ipv6   shang   www   index   gen   art   执行   l数据库   

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

[root@localhost ~]# cat /etc/redhat-release       
CentOS Linux release 7.3.1611 (Core) 
[root@localhost ~]# 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         
[root@localhost ~]# 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、解压并编译

[root@localhost tools]# tar xf zabbix-3.4.14.tar.gz 
[root@localhost tools]# cd zabbix-3.4.14/
[root@localhost 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 zabbix@127.0.0.1 identified by zabbix;     
flush privileges;
quit

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

[root@localhost zabbix-3.4.14]# cd /application/tools/zabbix-3.4.14/database/mysql/
[root@localhost 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配置,操作命令

查看:
[root@localhost 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"
修改:
[root@localhost 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
[root@localhost 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}
[root@localhost 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

标签:ati   ipv6   shang   www   index   gen   art   执行   l数据库   

原文地址:https://www.cnblogs.com/fanglingen/p/9848988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!