源码安装zabbix部署

需求说明

源码安装zabbix并配置监控流量

环境说明

服务器类型 ip地址 需要安装的应用
服务器 172.16.11.11 lamp架构 ,zabbix server ,zabbix agent
客户端 172.16.11.12 zabbix agent

①.关闭防火墙

[root@lizihan ~]# systemctl stop firewalld.service

②.关闭selinux

[root@lizihan ~]# setenforce 0
[root@lizihan ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config 

操作步骤

  • 服务端

需要搭建好lamp架构,如何搭建,可以看这里 →lamp服务器搭建

①.安装依赖包

[root@lizihan ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
[root@lizihan ~]# sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
[root@lizihan ~]# yum -y install net-snmp-devel libevent-devel

②.下载zabbix 的源码包并解压,创建zabbix用户
zabbix下载

[root@lizihan ~]# tar -xf zabbix-3.4.12.tar.gz 
[root@lizihan ~]# groupadd -r zabbix
[root@lizihan ~]# useradd -r -M -s /sbin/nologin -g zabbix zabbix

③.配置zabbix数据库

[root@lizihan ~]# mysql -uroot -p
Enter password: 
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.07 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.13 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.09 sec)

[root@lizihan ~]# cd zabbix-3.4.12/database/mysql/
[root@lizihan mysql]# ls
data.sql  images.sql  schema.sql
[root@lizihan mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure

[root@lizihan mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql 
mysql: [Warning] Using a password on the command line interface can be insecure.

[root@lizihan mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql 
mysql: [Warning] Using a password on the command line interface can be insecure

④.编译安装zabbix

[root@lizihan zabbix-3.4.12]# ./configure --enable-server \
> --enable-agent \
> --with-mysql \
> --with-net-snmp \
> --with-libcurl \
> --with-libxml2

[root@lizihan zabbix-3.4.12]# make install

⑤.修改服务端配置文件,添加如下内容,并启动服务

[root@lizihan ~]# vim /usr/local/etc/zabbix_server.conf
DBPassword=zabbix123!
[root@lizihan ~]# zabbix_server 
[root@lizihan ~]# zabbix_agentd 
[root@lizihan ~]# ss -antl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      128          *:22                       *:*                  
LISTEN     0      100    127.0.0.1:25                       *:*                  
LISTEN     0      128          *:10050                    *:*                  
LISTEN     0      128          *:10051                    *:*                  
LISTEN     0      128    127.0.0.1:9000                     *:*                  
LISTEN     0      128         :::80                      :::*                  
LISTEN     0      128         :::22                      :::*                  
LISTEN     0      100        ::1:25                      :::*                  
LISTEN     0      80          :::3306                    :::*  

⑥.配置php并重启服务

[root@lizihan ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@lizihan ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@lizihan ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@lizihan ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@lizihan ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done

⑦.创建zabbix网页

[root@lizihan ~]# mkdir /usr/local/apache/htdocs/zabbix
[root@lizihan ~]# cp -a /root/zabbix-3.4.12/frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@lizihan ~]# chown -R apache.apache /usr/local/apache/htdocs/

⑧.配置zabbix虚拟主机

[root@lizihan ~]# vim /etc/httpd123/httpd.conf
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix"
    ServerName zabbix.haha.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdo cs/zabbix/$1
      <Directory "/usr/local/apache/htdocs/zabbix">
          Options none
          AllowOverride none
          Require all granted
      </Directory>
</VirtualHost>

⑨.修改zabbix/conf的权限,重启apache

[root@lizihan ~]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@lizihan conf]# apachectl restart

⑩.安装zabbix的web界面,修改window的hosts文件

Windows(C):/windows/system32/drrvers/etc/hosts
172.16.11.11 zabbix.haha.com

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43154788/article/details/82972927