Zabbix部署+详解+图解+解衣欲睡

说明:本文所有的&>/dev/null操作都是为了不显示过程,让大家看起来更简洁方便(实际操作中可不加)

一、查看需要手动安装/下载的包

[root@zabbix ~]# ls
Desktop  Zabbix
[root@zabbix ~]# cd Zabbix/
[root@zabbix Zabbix]# ls
libevent-devel-2.0.21-4.el7.x86_64.rpm  nginx-1.12.2.tar.gz  zabbix-3.4.4.tar.gz

二、安装所需要的依赖包
1.搭建LNMP服务(三部曲:安包-修改配置文件-启服务)

#安装所需要的环境包
[root@zabbix Zabbix]# yum -y install gcc pcre-devel openssl-devel &>/dev/null
[root@zabbix Zabbix]# yum -y install php php-fpm php-mysql mariadb mariadb-server mariadb-devel &>/dev/null
#安装Nginx服务(对已下载好的Nginx包进行源码编译安装)
[root@zabbix Zabbix]# tar -xvPf nginx-1.12.2.tar.gz &>/dev/null
[root@zabbix Zabbix]# 
[root@zabbix Zabbix]# ls
libevent-devel-2.0.21-4.el7.x86_64.rpm  nginx-1.12.2  nginx-1.12.2.tar.gz  zabbix-3.4.4.tar.gz
[root@zabbix Zabbix]# cd nginx-1.12.2/
[root@zabbix nginx-1.12.2]# make &>/dev/null&&make install &>/dev/null
#使用-V查看所安装Nginx版本以及模块功能是否正确
[root@zabbix nginx-1.12.2]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.12.2                       #Nginx版本
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --with-http_ssl_module    #这就是原密码编译时开启的ssl加密模块
#修改Nginx配置文件
[root@zabbix nginx-1.12.2]# vim /usr/local/nginx/conf/nginx.conf
#初始模板样子
...
http {
...
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
...
}
#改完后样子
...
http {
...
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_buffers 8 16k;         #缓存php生成的页面内容,8个16k
            fastcgi_buffer_size 32k;       #缓存php生产的头部信息
            fastcgi_connect_timeout 300;   #链接php的超时时间
            fastcgi_send_timeout 300;      #发送请求的超时时间
            fastcgi_read_timeout 300;    #读取请求的超时时间
            include        fastcgi.conf;
        } 
...
}
:wq   #保存并退出
#修改php.ini配置文件
[root@zabbix nginx-1.12.2]#yum -y install php-gd php-xml php-ldap php-bcmath php-mbstring &>/dev/null
[root@zabbix nginx-1.12.2]# vim /etc/php.ini
#找到以下四行改成对应配置
...
date.timezone = Asia/Shanghai  #设置时区
max_execution_time = 300 #最大执行时间,秒
post_max_size = 32M #POST数据最大容量
max_input_time = 300 #服务器接收数据的时间限制
...
:wq
#启动LNMP服务
[root@zabbix nginx-1.12.2]# systemctl start mariadb
[root@zabbix nginx-1.12.2]# systemctl start php-fpm
[root@zabbix nginx-1.12.2]# /usr/local/nginx/sbin/nginx #如果想设置nginx开机自启,把此命令写入/etc/rc.d/rc.local即可(当然也可以用system详细步骤参考我的这篇博客:https://blog.csdn.net/qq_43417559/article/details/100775966)
[root@zabbix nginx-1.12.2]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix nginx-1.12.2]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

2.源码安装Zabbix

[root@zabbix Zabbix]# yum -y install net-snmp-devel curl-devel libevent-devel &>/dev/null
[root@zabbix Zabbix]# tar -xPvf zabbix-3.4.4.tar.gz &>/dev/null
[root@zabbix Zabbix]# ls
libevent-devel-2.0.21-4.el7.x86_64.rpm  nginx-1.12.2  nginx-1.12.2.tar.gz  zabbix-3.4.4  zabbix-3.4.4.tar.gz
[root@zabbix Zabbix]# cd zabbix-3.4.4/
[root@zabbix zabbix-3.4.4]# 
[root@zabbix zabbix-3.4.4]# ./configure  &>/dev/null \
> --enable-server --enable-proxy --enable-agent \
> --with-mysql=/usr/bin/mysql_config \
> --with-net-snmp --with-libcurl
[root@zabbix zabbix-3.4.4]# make install &>/dev/null  #不用make直接make install即可(默认会执行make)
#安装完成后使用ls 分别对/usr/local/{etc,bin,sbin}/三个目录查看是否有以下东西
[root@zabbix zabbix-3.4.4]# ls /usr/local/{etc,bin,sbin}/
/usr/local/bin/:
eip  setip  zabbix_get  zabbix_sender

/usr/local/etc/:
zabbix_agentd.conf    zabbix_proxy.conf    zabbix_server.conf
zabbix_agentd.conf.d  zabbix_proxy.conf.d  zabbix_server.conf.d

/usr/local/sbin/:
zabbix_agentd  zabbix_proxy  zabbix_server
[root@zabbix zabbix-3.4.4]#

3.初始化准备

[root@zabbix zabbix-3.4.4]# cd
[root@zabbix ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix character set utf8;  #创建一个支持中文存储的zabbix库
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'zabbix'; #授予zabbix用户所有关于zabbix库的权限登录密码为zabbix
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> quit
Bye
#导入数据(这三个表数据是zabbix自带的)
#切记导入顺序不可变,数据庞大导入时间较长
[root@zabbix ~]# cd Zabbix/zabbix-3.4.4/database/mysql/
[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql 
[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix < images.sql 
[root@zabbix mysql]# mysql -uzabbix -pzabbix zabbix < data.sql 
[root@zabbix mysql]# 
#上线Zabbix页面并授权
[root@zabbix mysql]# cd ..
[root@zabbix database]# cd ..
[root@zabbix zabbix-3.4.4]# cd frontends/php/
[root@zabbix php]# cp -a * /usr/local/nginx/html/
[root@zabbix php]# chmod -R 777 /usr/local/nginx/html/*
[root@zabbix php]# firefox 192.168.2.1/index.php   #测试访问

4.初始化
如图操作即可
Zabbix部署+详解+图解+解衣欲睡_第1张图片
Zabbix部署+详解+图解+解衣欲睡_第2张图片
Zabbix部署+详解+图解+解衣欲睡_第3张图片
Zabbix部署+详解+图解+解衣欲睡_第4张图片

你可能感兴趣的:(linux)