Debian10安装Zabbix教程

本文提供了在Debian10系统上安装Zabbix服务器和Agent的详细步骤,包括安装Apache、PHP、MariaDB,配置数据库及导入数据,以及设置Zabbix-agent与服务器通信。此外,还介绍了如何修改配置文件以适应不同需求,并给出了更换apt源的建议。

Debian10安装Zabbix教程

​ zabbix分为server端和agent端,本文分为两个部分分别讨论其安装方法。对于zabbix的agent端的不同环境也做了详细阐述。

Zabbix-server端

1、安装Apache httpd服务器

apt update
apt install -y apache2

安装成功后修改配置文件

sed -i "s/^ServerTokens OS$/ServerTokens Prod/" /etc/apache2/conf-enabled/security.conf

sed -i "s/^ServerSignature On$/ServerSignature Off/" /etc/apache2/conf-enabled/security.conf

重启apache2 服务

systemctl restart apache2

注:Apache2默认的端口为80,如果端口号被占用导致没有重启成功,则通过下面的方法修改端口号后重新启动

 vim /etc/apache2/ports.conf
 修改 Listen 9000

2、为Apache2安装php

apt-get -y install php php-pear php-cgi php-common libapache2-mod-php

为Apache2配置php**(root用户也要加sudo)**

sudo a2enconf php7.3-cgi 
systemctl reload apache2

修改Apache2的时区配置文件

vim /etc/php/7.3/apache2/php.ini 

将时区修改为

http://php.net/date.timezone

date.timezone = "Asia/Shanghai"

修改成功后重启Apache2

systemctl restart apache2

3、安装MariaDB数据库

执行命令

apt -y install mariadb-server

4、安装zabbix服务器

wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1%2Bbuster_all.deb

dpkg -i zabbix-release_5.0-1+buster_all.deb

apt update

安装zabbix-server(zabbix-server依赖MySQL、PHP,故同样会安装其他相关组件依赖)

apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf

安装成功以后进入mysql执行对应的sql创建zabbix的mysql用户

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by '123456';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;

然后把zabbix的数据导入到mysql**(这里会要求输入密码,注意是上一步创建用户输入的密码,时间略长耐心等待)**

 zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

为zabbix服务器配置数据库,编辑文件

vim /etc/zabbix/zabbix_server.conf

取消注释并添加密码**(这个密码是mysql创建zabbix用户的密码)**

DBPassword=123456

编辑 /etc/zabbix/apache.conf 文件取消php_value date.timezone注释选择正确的时区

修改为:php_value date.timezone Asia/Shanghai

启动服务**(该操作会设置系统启动时自动启动该服务)**

systemctl restart zabbix-server apache2
systemctl enable zabbix-server apache2

Zabbix-agent端

​ zabbix端分为Linux和Windows

Linux

1、添加apt库

wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1%2Bbuster_all.deb

dpkg -i zabbix-release_5.0-1+buster_all.deb

apt update

2、安装zabbix-agent

apt install zabbix-agent

3、修改配置文件使得指向zabbix-sever

vim /etc/zabbix/zabbix_agentd.conf

将server指向zabbix的server端

Server=172.21.1.42
ServerActive=172.21.1.42
Hostname=172.21.1.42(根据需要自行修改)

4、重新启动(机器启动就会启动该程序)

systemctl start zabbix-agent
systemctl enable zabbix-agent

Windows

//todo

附录

如果apt速度慢请自行换apt源

修改**/etc/apt/sources.list** 文件替换为下面网易源**(该源为Debian10)**

deb http://mirrors.163.com/debian/ buster main non-free contrib
deb http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ buster main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ buster-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ buster/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ buster/updates main non-free contrib
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值