配置zabbix遇到的问题

本文档记录了配置Zabbix server和agent的详细过程,包括在Redhat 7.x和8.3上配置yum、dnf源,安装Zabbix server和MySQL,遇到的MySQL服务未启动问题,以及安装Zabbix agent时的libpcre依赖问题。在安装过程中,还涉及了SELinux设置、数据库连接和Zabbix frontend的配置。

环境:

zabbix server:redhat8.3

zabbix agent:redhat7.x 、redhat8.3

1. 配置yum、dnf源

cat /etc/redhat-release

8.3
cd /etc/yum.repos.d/

删除旧的.repo
wget -O /etc/yum.repos.d/redhat.repo http://mirrors.aliyun.com/repo/Centos-8.repo

dnf clean all;
dnf makecache;
dnf repolist;

7.x
cd /etc/yum.repos.d/ 

删除旧的.repo
wget http://mirrors.aliyun.com/repo/Centos-7.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/Centos-7.repo


yum clean all;
yum makecache;
yum repolist;

2. install zabbix server

https://www.zabbix.com/download?zabbix=5.0&os_distribution=red_hat_enterprise_linux&os_version=8&db=mysql

rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
 
dnf clean all;
dnf install zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent;

cat /etc/services |grep zabbix 

Configure Zabbix frontend

Connect to your newly installed Zabbix frontend: http://server_ip_or_name/zabbix

 https://www.zabbix.com/documentation/5.0/manual/quickstart/login

遇到的问题 

mysql service没启动,ui上报错接不上

3. install mysql

  dnf -y install mysql mysql-server mysql-devel

  chown mysql:mysql -R /var/lib/mysql
  mysqld --initialize
  systemctl start mysqld
  
  systemctl status mysqld
 
  mysql -uroot -pxxxx (password)

创建zabbix db、user,权限

mysql> create database zabbix character set utf8;
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> create user 'zabbix'@'server_ip' identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL ON *.* TO 'zabbix'@'server_ip';
Query OK, 0 rows affected (0.00 sec)

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

\q

vi /etc/zabbix/zabbix_server.conf
DBPassword=zabbix

vi /etc/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

启动 zabbix

systemctl restart zabbix-server zabbix-agent httpd php-fpm

systemctl status zabbix-server.service

遇到错误:

SELinux is preventing /usr/sbin/zabbix_server_mysql from using the dac_override capability
>>getenforce
Enforcing

解决:关闭selinux

setenforce 0

vi /etc/selinux/config
SELINUX=disabled

connect mysql error no such file: mysql 没启动

4. install zabbix agent

参考 zabbix.com/documentation/5.0/manual/installation/install

下载安装tar
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.1.tar.gz

tar -zxvf zabbix-5.0.1.tar.gz

create user:
groupadd --system zabbix;
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix;
mkdir -m u=rwx,g=rwx,o= -p /usr/lib/zabbix;
chown zabbix:zabbix /usr/lib/zabbix;

安装
cd zabbix-5.0.1/
./configure --enable-agent

遇到错误:

configure: error: Unable to use libpcre (libpcre check failed)

解决方法:安装依赖包

redhat8:
yum -y install pcre*

redhat7:
yum -y install net-snmp-devel libxml2-devel libcurl-deve libevent libevent-devel
yum -y install mysql-dev gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xm

再次执行 ./configure --enable-agent

看到提示信息说明成功


***********************************************************
*            Now run 'make install'                               *
*                                                                              *
*            Thank you for using Zabbix!                      *
*              <http://www.zabbix.com>                        *
***********************************************************

make install
vi /usr/local/etc/zabbix_agentd.conf
    Server=xx.xx.xx.xx (zabbix server ip)

launch zabbix agent
shell> zabbix_agentd

加入service

cp /root/zabbix-5.0.1/misc/init.d/tru64/zabbix_agentd /etc/init.d/
chmod +x /etc/init.d/zabbix_agentd

service zabbix_agentd restart

-- 遇到 received empty response from zabbix agent

agent的server=XXXX ip没配对

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值