Zabbix是一种开源的网络监控和管理解决方案。它提供了一套功能强大的工具,用于监测和跟踪网络设备、服务器以及其他IT基础设施的性能和可用性。通过Zabbix,您可以收集各种指标和数据,如CPU使用率、内存使用率、网络流量、硬盘空间等,以便对系统的健康状况进行实时监测和分析。
更新系统
sudo yum update -y
sudo yum -y install yum-utils
sudo yum -y install epel-release
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
关闭SELINUX
# 临时关闭
sudo setenforce 0
# 永久关闭 重启生效
sudo sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config
关闭防火墙
sudo systemctl stop firewalld
sudo systemctl disable firewalld
安装所需依赖
sudo yum -y install httpd net-snmp-devel net-snmp-utils libxml2 libxml2-devel libcurl libcurl-devel libevent libevent-devel curl-devl openssl openssl-devel gcc make
安装PHP和组件
sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php74
sudo yum install php php-mysqlnd php-fpm php-gd php-xml php-mbstring php-ldap php-pear net-snmp php-bcmath
安装MariaDB
最低所需版本是10.02
版本且不得高于10.10
版本,那就安装10.10
版本。
编辑sudo vim /etc/yum.repos.d/mariadb.repo
:
# MariaDB 10.10 CentOS repository list - created 2023-12-29 05:36 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/10.10/centos/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.10/centos/$releasever/$basearch
module_hotfixes = 1
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
进行安装:
sudo yum install MariaDB-server MariaDB-client
修改PHP参数
sudo vim /etc/php.ini
# 修改post_max_size为16M
# 修改max_execution_time为300
# 修改max_input_time为300
更新gcc
sudo yum install centos-release-scl -y
sudo yum install devtoolset-11-gcc* -y
sudo scl enable devtoolset-11 bash
安装mysql开发包
sudo yum install mysql-devel -y
find / -name mysql_config
/usr/bin/mysql_config
配置服务自启
sudo systemctl start httpd
sudo systemctl enable httpd
sudo systemctl start mariadb
sudo systemctl enable mariadb
配置数据库
# 设置mysql的root密码
sudo mariadb-secure-installation
下载zabbix源码
wget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.0.tar.gz
tar -xf zabbix-6.4.0.tar.gz
cd zabbix-6.4.0
编译安装zabbix
sudo ./configure --enable-server --enable-agent --with-mysql==/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2 --with-openssl --prefix=/usr/local/zabbix
make install
创建Zabbix数据库
使用 mariadb -u root -p
刚才设置的密码登录进去后执行:
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'zabbix_password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
FLUSH PRIVILEGES;
EXIT;
导入数据
cd database/mysql
mariadb -u zabbix -p'zabbix_password' zabbix < schema.sql
mariadb -u zabbix -p'zabbix_password' zabbix < images.sql
mariadb -u zabbix -p'zabbix_password' zabbix < data.sql
配置zabbix服务
sed -i 's/^# DBPassword=/DBPassword=zabbix_password/' /usr/local/zabbix/etc/zabbix_server.conf
配置zabbix前端
sudo cp -r ~/zabbix-6.4.0/ui/* /var/www/html
sudo chown apache:apache /var/www/html -R
启动zabbix
sudo groupadd zabbix
sudo useradd zabbix -g zabbix
cd /usr/local/zabbix/sbin/
./zabbix_server
通过http://your_server_ip/zabbix
来访问Zabbix前端。如果访问异常可以尝试重启后再访问。配置完之后,默认用户密码:Admin/zabbix
。
评论 (0)