1.进入zabbix官网,选择zabbix 5.0源码下载​​https://www.zabbix.com​

Centos 7.9下源码编译安装zabbix 5.0_linux

2.源码安装mysql 8.0,详见​

3.zabbix 5.0新特性
Zabbix 5.0 LTS新特性:
(1) 5.0 LTS的发布时间为 2020年 4月
(2)Zabbix Agent 使用 golang 语言编写,可方便编写各种插件,灵活配置监控。(当然4.4 也是Golang编写,4.4之前是C编写)
(3)PHP的版本需要7.2.x或者以上
(4)Mysql需要5.6或者以上

安装方法
Linux的Zabbix的包安装方法大致可以有如下几种:
(1)服务端和客户端都是通过源码包编译安装(官网有说明)
(2)服务端和客户端都是通过yum进行安装(官网有说明)
(3)服务器用源码包编译安装,客户端通过yum的RPM包进行安装。(官网虽然没有说明,但是这种方案是可行,我每次都是这样装的,不会存在性能问题)

4.zabbix 5.0安装
4.1 创建mysql相关用户

mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.20 sec)

mysql> create user zabbix@localhost identified by 'wwwwww';
Query OK, 0 rows affected (0.05 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.01 sec)

4.2安装Linux依赖包

[root@zabbix-server ~]# yum install mysql-devel libcurl libevent libevent-devel fping curl-devel libxml2  libxml2-devel gcc net-snmp-devel -y
[root@zabbix-server ~]# groupadd --system zabbix
[root@zabbix-server ~]# useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitor" zabbix
[root@zabbix-server ~]# cd /home && tar xvf zabbix-5.0.14.tar.gz
[root@zabbix-server ~]# cd /home/zabbix-5.0.14
[root@zabbix-server zabbix-5.0.14]# ./configure --prefix=/zabbix --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2 --with-net-snmp
[root@zabbix-server zabbix-5.0.14]# make && make install
[root@zabbix-server zabbix-5.0.14]# cp /home/zabbix-5.0.14/misc/init.d/fedora/core/zabbix_* /etc/init.d/

修改脚本的 BASEDIR为BASEDIR=/zabbix

4.3 修改服务端配置文件

vi /zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=wwwwww
Timeout=10
LogSlowQueries=3000
CacheSize=256M
TrendCacheSize=256M
ValueCacheSize=256M
StartTrappers=30
StartPollers=10

4.4 导入数据库的表结构

mysql> use zabbix;
mysql> source /home/zabbix-5.0.14/database/mysql/schema.sql
mysql> source /home/zabbix-5.0.14/database/mysql/images.sql
mysql> source /home/zabbix-5.0.14/database/mysql/data.sql

4.5 服务端管理界面安装

[root@zabbix-server home]# yum install nginx -y
[root@zabbix-server home]# mkdir -p /usr/local/nginx/html
[root@zabbix-server home]# cp -r /home/zabbix-5.0.14/ui/* /usr/local/nginx/html/
[root@zabbix-server home]# chown -Rf nginx:nginx /usr/local/nginx/html/
[root@zabbix-server home]# chmod -Rf 777 /usr/local/nginx/html/
[root@zabbix-server conf.d]# cd /etc/nginx/conf.d
[root@zabbix-server nginx]# cat nginx.conf

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root /usr/local/nginx/html;
index index.html index.htm;
}

location ~ /.php$ {
root /usr/local/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}

#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;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ /.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ /.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ //.ht {
# deny all;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}
[root@zabbix-server ~]# cp /usr/sbin/nginx /etc/init.d/
[root@zabbix-server ~]# systemctl enable nginx

4.6 安装配置PHP7.3

yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y php73-php-fpm php73-php-cli php73-php-bcmath php73-php-gd php73-php-json
yum install -y php73-php-mbstring php73-php-mcrypt php73-php-mysqlnd php73-php-opcache
yum install -y php73-php-pdo php73-php-pecl-crypto php73-php-pecl-mcrypt php73-php-pecl-geoip
yum install -y php73-php-recode php73-php-snmp php73-php-soap php73-php-xml php73-php-ldap


##php相关参数
sed -i 's/^post_max_size = 8M$/post_max_size = 16M/' /etc/opt/remi/php73/php.ini
sed -i 's/^max_execution_time = 30$/max_execution_time = 300/' /etc/opt/remi/php73/php.ini
sed -i 's/^max_input_time = 60$/max_input_time = 300/' /etc/opt/remi/php73/php.ini
sed -i 's/^;date.timezone =$/date.timezone = Asia//Shanghai/' /etc/opt/remi/php73/php.ini
[root@zabbix-server tmp]# cat /etc/opt/remi/php73/php.ini | grep -i mysqli.default_socket
mysqli.default_socket = /tmp/mysql.sock
[root@zabbix-server tmp]# cat /etc/opt/remi/php73/php.ini | grep -i pdo_mysql.default_socket
pdo_mysql.default_socket= /tmp/mysql.sock

[root@zabbix-server ~]# php -v
PHP 7.3.33 (cli) (built: Nov 16 2021 11:18:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.33, Copyright (c) 1999-2018, by Zend Technologies

systemctl start php73-php-fpm
systemctl start nginx
systemctl enable php73-php-fpm
systemctl enable nginx

配置zabbix​​http://192.168.56.110/setup.php​

Centos 7.9下源码编译安装zabbix 5.0_数据库_02

Centos 7.9下源码编译安装zabbix 5.0_linux_03

Centos 7.9下源码编译安装zabbix 5.0_nginx_04

版权声明:本文为博主原创文章,未经博主允许不得转载。

zabbix