zabbix 6.2.0部署
阅读原文时间:2023年07月08日阅读:3

zabbix 6.2官方部署文档
https://www.zabbix.com/documentation/6.2/en/manual/installation/install
下载zabbix6.2安装包
https://www.zabbix.com/download_sources

一、准备zabbix_server

1、解压安装包
tar -zxvf zabbix-6.2.0.tar.gz
2、安装编译安装条件
yum groupinstall "Development Tools" -y
yum install mysql-devel libevent-devel libevent libxml* net-snmp-devel OpenIPMI-devel curl-devel -y
3、创建zabbix用户
groupadd --system zabbix
useradd --system -g zabbix -d /usr/lib/zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
4、创建zabbix编译安装目录
mkdir /usr/local/zabbix
5、编译安装
cd到zabbix解压目录下
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi
5、加权限
chown -R zabbix:zabbix /usr/local/zabbix

二、准备数据库

数据库选择mysql5.7.37版本;如果选用5.7.25,zabbix 6.2在启动的时候会提示数据库版本过低;
下载链接:https://downloads.mysql.com/archives/community/
1、解压安装包
tar xvf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
2、创建数据库用户并为mysql工作目录授予权限
useradd -s /sbin/nologin mysql
mkdir /usr/local/mysql-5.7.37/data
chown mysql:mysql -R /usr/local/mysql-5.7.37
3、初始化
[root@localhost bin]# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql-5.7.37 --datadir=/usr/local/mysql-5.7.37/data
2022-07-21T03:47:24.756008Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-21T03:47:26.657144Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-21T03:47:26.983935Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-21T03:47:27.088184Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: d69325d7-08a7-11ed-880d-000c29e2fc7c.
2022-07-21T03:47:27.115081Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-21T03:47:28.128228Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-21T03:47:28.128241Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-21T03:47:28.128729Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-21T03:47:28.363694Z 1 [Note] A temporary password is generated for root@localhost: ktjbcp#q/1GQ #初始密码,第一次登录要用到
4、修改mysql配置文件
[mysqld]
character-set-server=utf8mb4
max_allowed_packet = 20M
basedir=/usr/local/mysql-5.7.37/
datadir=/usr/local/mysql-5.7.37/data
5、启动
5.1、前台启动
[root@zabbix-server bin]# pwd
/usr/local/mysql-5.7.37/bin
[root@zabbix-server bin]# ./mysqld -u mysql
5.2、后台启动
[root@zabbix-server support-files]# pwd
/usr/local/mysql-5.7.37/support-files
[root@zabbix-server support-files]# ./mysql.server start
6、登录数据库创建zabbix库和zabbix用户并导入zabbix模板文件
create database zabbix;
use zabbix;

导入顺序不能乱,否则会报错

source /root/zabbix-6.2.0/database/mysql/schema.sql
source /root/zabbix-6.2.0/database/mysql/images.sql
source /root/zabbix-6.2.0/database/mysql/data.sql

创建zabbix用户并授权zabbix库所有权限;

create user 'zabbix'@'%' identified by 'zabbix.com';
grant all on zabbix.* to 'zabbix'@'%';

三、配置zabbix_server

[root@zabbix-server etc]# pwd
/usr/local/zabbix/etc
[root@zabbix-server etc]# egrep -v "^$|^#" zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
PidFile=/usr/local/zabbix/zabbix_server.pid
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix.com
AllowUnsupportedDBVersions=1
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1

四、启动zabbix_server服务

[root@zabbix-server sbin]# pwd
/usr/local/zabbix/sbin
[root@zabbix-server sbin]# ./zabbix_server
监听10051端口

五、部署zabbix UI

1、编译安装php-7.4.28
./configure --prefix=/usr/local/php --with-curl --with-freetype --enable-gd --with-gettext --with-iconv-dir --with-jpeg --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql --with-pdo-sqlite --without-pear --with-xmlrpc --with-xsl --with-zlib --enable-fpm --enable-bcmath --with-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --with-zip --with-ldap
2、配置nginx
将zabbix-6.2.0原始目录下的ui目录下的内容复制一份放到/var/www/zabbix-ui目录下
server {
listen 80;
server_name zabbix.com;

    location / {  
        index index.php;  
        root /var/www/zabbix-ui;

    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
    location ~ \\.php$ {  
        root /var/www/zabbix-ui;  
        fastcgi\_pass   127.0.0.1:9000;  
        fastcgi\_index  index.php;  
        fastcgi\_param  SCRIPT\_FILENAME /var/www/zabbix-ui/$fastcgi\_script\_name;  
        include        fastcgi\_params;  
    }

   error\_page   500 502 503 504  /50x.html;  
    location = /50x.html {  
        root   html;  
    }  
access\_log /var/log/nginx/access.log main;  
error\_log /var/log/nginx/error.log;  
}  

3、启动nginx
访问zabbix.com,则出现zabbix-6.2.0的安装界面,根据提示安装即可;