Zabbix【部署 01】Zabbix企业级分布式监控系统部署配置使用实例(在线安装及问题处理)程序安装+数据库初始+前端配置+服务启动+Web登录

安装说明: 本次安装为在线安装,使用数据库为PostgreSQL。

1.下载

由于是在线安装,这次不涉及离线安装包的下载,仅做参考用,点击跳转【下载页面】,下载说明:

  • 版本选择

在这里插入图片描述

  • 如果组件里没有Server说明此版本只能部署代理组件

在这里插入图片描述

在这里插入图片描述

推荐使用国内的镜像站:

在这里插入图片描述

2.安装

# 服务器系统版本
[root@tcloud ~]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

CentOS7能够部署的最新Server版本为5.1,可以在【官网下载】也可以在其他【镜像站下载】,在线安装仅能安装5.0版本。

记住Zabbix日志文件路径/var/log/zabbix/

  • zabbix_agentd.log 代理日志文件
  • zabbix_server.log 服务日志文件

启动出现问题时可用查看这两个文件。

2.1 程序安装

# 1.安装存储库
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
# 2.安装Server及Agent
yum install -y zabbix-server-pgsql zabbix-agent
# 3.启用软件集并安装Web及
yum install -y centos-release-scl
# Edit file /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.
vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
enabled=1
# Install Zabbix frontend package
yum install -y zabbix-web-pgsql-scl zabbix-nginx-conf-scl
# 安装完成后
[root@tcloud ~]# rpm -qa | grep zabbix
zabbix-agent-5.0.32-1.el7.x86_64
zabbix-web-5.0.32-1.el7.noarch
zabbix-web-deps-scl-5.0.32-1.el7.noarch
zabbix-release-5.0-1.el7.noarch
zabbix-server-pgsql-5.0.32-1.el7.x86_64
zabbix-web-pgsql-scl-5.0.32-1.el7.noarch
zabbix-nginx-conf-scl-5.0.32-1.el7.noarch

2.2 数据库初始化

官方文档会根据不同的数据库给出不同的初始化脚本:

在这里插入图片描述
在这里插入图片描述

以下过程为PostgreSQL数据库:

# 1.(官网指导)创建用户和数据库
sudo -u postgres createuser --pwprompt zabbix
sudo -u postgres createdb -O zabbix zabbix

#(真实操作)这个过程可以在 Navicat 上进行

在这里插入图片描述
在这里插入图片描述

# 2.(官网指导)初始化数据库
zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix
 
#(真实操作)解压 create.sql.gz
gzip -d create.sql.gz
# 在 Navicat 里执行 create.sql

在这里插入图片描述
在这里插入图片描述

# 3.(官网指导)Edit file /etc/zabbix/zabbix_server.conf
DBPassword=password

# (真实操作)修改配置文件(主要是数据库相关)使用的是非localhost的库
vim /etc/zabbix/zabbix_server.conf
DBHost=xxx.xx.x.x[云服务器的内网IP]
DBName=zabbix[根据初始化的数据库名称设置]
DBUser=zabbix[根据实际情况设置]
DBPassword=zabbix[根据设置的密码设置]
DBPort=5432[根据数据库的端口填写]

2.3 前端配置

由于项目使用的是 Nginx,这里展示的是使用 Nginx 的配置:

# 1.(官网指导)
Edit file /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf uncomment and set 'listen' and 'server_name' directives.
# listen 80;
# server_name example.com;

# (真实操作)
cat /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf

复制/etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf的内容并进行修改,添加到Nginx的配置/usr/local/nginx/conf/nginx.conf内:

# 修改内容为 listen 和 server_name 和 fastcgi_pass
server {
    
    
        listen          8081;
        server_name     localhost;

        root    /usr/share/zabbix;

        index   index.php;

        location = /favicon.ico {
    
    
                log_not_found   off;
        }

        location / {
    
    
                try_files       $uri $uri/ =404;
        }

        location /assets {
    
    
                access_log      off;
                expires         10d;
        }

        location ~ /\.ht {
    
    
                deny            all;
        }

        location ~ /(api\/|conf[^\.]|include|locale|vendor) {
    
    
                deny            all;
                return          404;
        }

        location ~ [^/]\.php(/|$) {
    
    
                fastcgi_pass    localhost:9000;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_index   index.php;

                fastcgi_param   DOCUMENT_ROOT   /usr/share/zabbix;
                fastcgi_param   SCRIPT_FILENAME /usr/share/zabbix$fastcgi_script_name;
                fastcgi_param   PATH_TRANSLATED /usr/share/zabbix$fastcgi_script_name;

                include fastcgi_params;
                fastcgi_param   QUERY_STRING    $query_string;
                fastcgi_param   REQUEST_METHOD  $request_method;
                fastcgi_param   CONTENT_TYPE    $content_type;
                fastcgi_param   CONTENT_LENGTH  $content_length;

                fastcgi_intercept_errors        on;
                fastcgi_ignore_client_abort     off;
                fastcgi_connect_timeout         60;
                fastcgi_send_timeout            180;
                fastcgi_read_timeout            180;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 256k;
                fastcgi_busy_buffers_size       256k;
                fastcgi_temp_file_write_size    256k;
        }
}

# 将内容复制出来修改后复制到 /usr/local/nginx/conf/nginx.conf 内
vim /usr/local/nginx/conf/nginx.conf

修改 /etc/opt/rh/rh-php72/php.ini 否则会出现,Check of pre-requisites:

在这里插入图片描述

  • Minimum required size of PHP post is 16M (configuration option “post_max_size”).
  • Minimum required limit on execution time of PHP scripts is 300 (configuration option “max_execution_time”).
  • Minimum required limit on input parse time for PHP scripts is 300 (configuration option “max_input_time”).
  • Time zone for PHP is not set (configuration parameter “date.timezone”).

在这里插入图片描述

# 修改 /etc/opt/rh/rh-php72/php.ini
vim /etc/opt/rh/rh-php72/php.ini
# 默认值8M
post_max_size=16M
# 默认值30
max_execution_time=300
# 默认值60
max_input_time=300
# 默认未设置 ;date.timezone =
date.timezone = Asia/Shanghai
# 2.(官网指导)
Edit file /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf add nginx to listen.acl_users directive.
listen.acl_users = apache,nginx
# Then uncomment and set the right timezone for you.
; php_value[date.timezone] = Europe/Riga

# (真实操作)
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
# 修改user和group
user = nginx
group = nginx
# 修改listen.acl_users
listen.acl_users = nginx
# 修改listen.allowed_clients
listen.allowed_clients = xxx.xx.x.x[云服务器内网IP]
# 时区调整
; php_value[date.timezone] = Asia/Shanghai

2.4 服务启动

#(官网指导)启动
systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm

#(真实操作)启动【由于使用了 Nginx 这里不再启动 rh-nginx116-nginx】
systemctl restart zabbix-server zabbix-agent rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-php72-php-fpm

3.Web登录

  • 检查先决条件【问题已处理】

在这里插入图片描述

  • 配置数据库连接

在这里插入图片描述

  • 配置服务详情

在这里插入图片描述

  • 配置总览

在这里插入图片描述

  • 登录【默认用户名为:Admin 密码为:zabbix】

在这里插入图片描述

  • 登录成功

在这里插入图片描述

4.总结

官网的说明不够详细,过程中遇到不少坑,不同版本的安装可能有所不同。

猜你喜欢

转载自blog.csdn.net/weixin_39168541/article/details/129744210