Centos7.9系统ZABBIX5.0监控服务器部署搭建
setenforce 0
systemctl stop firewalld
# 安装依赖组建
mkdir ahah
cd ahah
yum install net-snmp-devel libevent-devel -y
# Centos7.9安装MySQL57
wget https://repo.mysql.com/RPM-GPG-KEY-mysql-2022 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm
rpm -Uvh mysql57-community-release-el7-10.noarch.rpm
yum install gcc -y
yum install -y mysql-community-server
# 启动mysqld
systemctl start mysqld
systemctl status mysqld
# 获取MySQL临时用户名密码
grep 'temporary password' /var/log/mysqld.log

set global validate_password_policy=0;
set global validate_password_length=1;
# 设置自己想要的数据库密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
# 授权其他机器远程登录
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

# 设置开机启动:
systemctl enable mysqld
systemctl daemon-reload
# 设置MySQL的字符集为UTF-8,令其支持中文
vim /etc/my.cnf
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [mysql] default-character-set=utf8 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock default-storage-engine=INNODB character_set_server=utf8 symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid

# 重启mysql另配置生效
systemctl restart mysqld
# 永久关闭selinux和防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
yum install curl-devel -y
yum install libxml2 libxml2-devel -y
yum install mysql-devel -y
# 创建zabbix用户组和用户
groupadd zabbix
useradd -r -g zabbix zabbix
#安装zabbix服务
https://cdn.zabbix.com/zabbix/sources/oldstable/7.2/

wget https://cdn.zabbix.com/zabbix/sources/oldstable/5.0/zabbix-5.0.1.tar.gz
# 执行部署zabbix服务
mkdir -p /usr/local/data/
tar -xzf zabbix-5.0.1.tar.gz -C /usr/local/data/
cd /usr/local/data/zabbix-5.0.1/
./configure --prefix=/usr/local/data/zabbix --enable-server --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2
make -j4 && make install
#
vim /etc/profile
# Zabbix Environment
export PATH=$PATH:/usr/local/data/zabbix/sbin/:/usr/local/data/zabbix/bin/
source /etc/profile

# 创建用户导入数据库
mysql -uroot -p123456
create database zabbix character set utf8 collate utf8_bin;
show variables like "%validate%";
set global validate_password_length=6;
set global validate_password_policy=0;
show variables like "%validate%";
grant all privileges on zabbix.* to zabbix@'localhost' identified by '123456';
flush privileges;
set names utf8;
mysql> use zabbix;

mysql> source /usr/local/data/zabbix-5.0.1/database/mysql/schema.sql
mysql> source /usr/local/data/zabbix-5.0.1/database/mysql/data.sql
mysql> source /usr/local/data/zabbix-5.0.1/database/mysql/images.sql
# 编辑zabbix_server的 配置文件
find / -name zabbix_server.conf
/usr/local/data/zabbix-5.0.1/conf/zabbix_server.conf
/usr/local/data/zabbix/etc/zabbix_server.conf
vim /usr/local/data/zabbix/etc/zabbix_server.conf





LogFile=/usr/local/data/zabbix/logs/zabbix_server.log
LogFileSize=0
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
Timeout=30
AlertScriptsPath=/usr/local/data/zabbix/alertscripts
ExternalScripts=/usr/local/data/zabbix/externalscripts
LogSlowQueries=3000
DBSocket=/var/lib/mysql/mysql.sock
# 授权建立相关文件夹
mkdir /usr/local/data/zabbix/logs
mkdir /usr/local/data/zabbix/pid
chown -R zabbix:zabbix /usr/local/data/zabbix/
# 安装PHP73首先安装 EPEL 源
yum install -y epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
# 安装 Yum 源管理工具
yum install yum-utils -y
# 安装remi-release-7. rpm 安装 PHP7.3:
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip php73-php-recode php73-php-snmp php73-php-soap php73-php-xml
# 设置开机自启
systemctl start php73-php-fpm
systemctl enable php73-php-fpm
vim /etc/ld.so.conf
/usr/local/lib /etc/logrotate.d/php73-php-fpm
ldconfig

# 启动zabbix
zabbix_server
# 杀死进程
ps -ef | grep zabbix_server | grep -v grep | awk '{print $2}' | xargs kill -9
# 创建服务文件
vim /usr/lib/systemd/system/zabbix-server.service

[Unit] Description=Zabbix After=network.target [Service] Environment="CONFFILE=/usr/local/data/zabbix/etc/zabbix_server.conf" Type=forking Restart=on-failure PIDFile=/tmp/zabbix_server.pid KillMode=control-group ExecStart=/usr/local/data/zabbix/sbin/zabbix_server -c $CONFFILE ExecStop=/bin/kill -SIGTERM $MAINPID RestartSec=10s [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart zabbix-server
systemctl enable zabbix-server
# 安装nginx
wget http://nginx.org/download/nginx-1.9.9.tar.gz
mkdir -p /usr/local/nginx/
tar -zxvf nginx-1.9.9.tar.gz -C /usr/local/nginx/
cd nginx-1.9.9/
./configure
make
make install
/usr/local/nginx/sbin/nginx
ps -ef | grep nginx
mkdir -p /usr/local/nginx/html/zabbix
cp -a /usr/local/data/zabbix-5.0.1/ui/* /usr/local/nginx/html/zabbix/
# zabbix_web需要php配置优化,编辑php.ini文件
find / -name php.ini
/etc/opt/remi/php73/php.ini
# 修改如下内容:
max_execution_time = 300 修改为350-(zabbix_web优化)
max_input_time = 300 修改为350-(zabbix_web优化)
post_max_size = 16M 修改为32M-(zabbix_web优化)
date.timezone = Asia/Shanghai 添加-(zabbix_web优化)
cgi.fix_pathinfo=0
systemctl restart php73-php-fpm
vim /lib/systemd/system/nginx.service

[UNIT] Deion=nginx - high performance web server Documentation=http://nginx.org/en/docs/ After=network-online.target remote-fs.target nss-lookup.target Wants=network-online.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s TERM $MAINPID [Install] WantedBy=multi-user.target
yum install lsof -y
lsof -i:80
systemctl daemon-reload
systemctl stop nginx
systemctl start nginx
systemctl enable nginx
# 配置nginx文件使PHP页面生效
vim /usr/local/nginx/conf/nginx.conf

server{
listen 80;
server_name localhost;
root /usr/local/nginx/html/zabbix;
index index.php index.html index.htm;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
# index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
# 验证nginx配置文件语法错误
sudo nginx -t
systemctl reload nginx
nginx -s reload #重新加载配置文件
systemctl restart nginx
yum install php73-php-xml -y
vi /etc/opt/remi/php73/php.ini
extension=xmlwriter
extension=xmlreader




cp zabbix.conf.php /usr/local/nginx/html/zabbix/conf/


出现这种情况解决方法:

vi /usr/local/data/zabbix/etc/zabbix_server.conf
tailf /usr/local/data/zabbix/logs/zabbix_server.log

在配置主机中添加客户端ip


使用openssl 的命令生成随机加密密钥:openssl rand -hex 32




内容参考:https://writer.blog.csdn.net/article/details/129346563
浙公网安备 33010602011771号