搜索结果

×

搜索结果将在这里显示。

🌻 Centos 7.9 2202安装部署Zabbix 6.4.20

【已审核】【部署】Centos 7.9 2202安装部署Zabbix 6.4.20

一、系统环境准备

  • 部署信息

    操作系统版本:Centos7.9_Release 2202

    VMware Hostname:75.142_Centos7_Zabbix6

    ip address:172.16.75.142
    ssh port:60022
    账号:root/admin
    密码:Zabbix@2024.12.#

  • 环境说明

    mysql版本 8.0.X
    gcc版本 大于4.8
    php版本 大于7.2.5

  • 准备工作

    #关闭防火墙和安全机制

    systemctl stop firewalld
    systemctl disable firewalld
    setenforce 0
    sed -i "s/^SELINUX=.*$/SELINUX=disabled/" /etc/selinux/config
  • 更换阿里云yum源

    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    yum clean all & yum makecache

二、安装mysql

  • 配置Mysql 8.0安装源

    rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm
  • 安装Mysql 8.0

    不安装mysql-devel ,后面编译zabbix会报错:configure: error: MySQL library not found

    yum -y --enablerepo=mysql80-community install mysql-community-server mysql-devel --nogpgcheck
  • 启动数据库服务

    systemctl start mysqld
    systemctl enable mysqld
  • 创建mysql账户

    cat /var/log/mysqld.log | grep password
    mysql -uroot -p
    ALTER USER 'root'@'localhost' IDENTIFIED BY 'Jzx@2024#';
    create database zabbix character set utf8 collate utf8_bin;
    create user zabbix@localhost identified by 'Zbx@2024#';
    grant all privileges on zabbix.* to zabbix@localhost;
  • MySQL数据库配置过程:

    [root@zabbix6 ~]# mysql -uroot -p
    Enter password:
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 8
    Server version: 8.0.40Copyright (c) 2000, 2024, Oracle and/or its affiliates.
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. 
    Other names may be trademarks of their respective
    owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Jzx@2024#';
    Query OK, 0 rows affected (0.35 sec)
    
    mysql> create database zabbix character set utf8 collate utf8_bin;
    Query OK, 1 row affected, 2 warnings (0.03 sec)
    
    mysql> create user zabbix@localhost identified by 'Jzx_2024#';
    Query OK, 0 rows affected (0.02 sec)
    
    mysql> grant all privileges on zabbix.* to zabbix@localhost;
    Query OK, 0 rows affected (0.16 sec)
    
    mysql> quit
    Bye

三、安装centos-release-scl

  • 执行命令安装

    yum install -y centos-release-scl net-snmp-devel libevent-devel
    • 重要提示 :安装完centos-release-scl后,由于SCL源 http://mirrorlist.centos.org 在2024年6月30日已经停止服务,scl源里面默认使用了centos官方的地址,因此我们需要更改scl源的baseUrl,替换为阿里云。
    cd /etc/yum.repos.d/
    vim CentOS-SCLo-scl.repo
    vim CentOS-SCLo-scl-rh.repo

    找到 CentOS-SCLo-scl.repo​ 和 CentOS-SCLo-scl-rh.repo​,将mirrorlist= ​行注释掉,将baseurl= ​ 行取消注释,域名地址改为阿里云 https://mirrors.aliyun.com

    • 不安装net-snmp-devel libevent-devel后面编译会报错:
    configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
    configure: error: Unable to use libevent (libevent check failed)q

四、离线安装gcc

  • 下载下面的rpm包

    image

  • 上传至服务器

    [root@zabbix6 gcc-g++-4.8.5-rpm]# ll
    总用量 39324
    -rw-r--r--. 1 root root  6234536 12月  5 10:14 cpp-4.8.5-28.el7.x86_64.rpm
    -rw-r--r--. 1 root root 16967040 12月  5 10:14 gcc-4.8.5-28.el7.x86_64.rpm
    -rw-r--r--. 1 root root  7534972 12月  5 10:14 gcc-c++-4.8.5-36.el7.x86_64.rpm
    -rw-r--r--. 1 root root  1116252 12月  5 10:14 glibc-devel-2.17-222.el7.x86_64.rpm
    -rw-r--r--. 1 root root   694524 12月  5 10:14 glibc-headers-2.17-222.el7.x86_64.rpm
    -rw-r--r--. 1 root root  7442492 12月  5 10:14 kernel-headers-3.10.0-862.el7.x86_64.rpm
    -rw-r--r--. 1 root root    51732 12月  5 10:14 libmpc-1.0.1-3.el7.x86_64.rpm
    -rw-r--r--. 1 root root   208316 12月  5 10:14 mpfr-3.1.1-4.el7.x86_64.rpm
  • 安装rpm包

    进入目录,执行​*​`rpm -ivh .rpm --nodeps --force`​命令安装所有rpm包及相关依赖**

    [root@zabbix6 gcc-g++-4.8.5-rpm]# rpm  -ivh  *.rpm --nodeps --force
    警告:cpp-4.8.5-28.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
    准备中...                          ################################# [100%]
    正在升级/安装...
     1:mpfr-3.1.1-4.el7                 ################################# [ 13%]
     2:libmpc-1.0.1-3.el7               ################################# [ 25%]
     3:cpp-4.8.5-28.el7                 ################################# [ 38%]
     4:kernel-headers-3.10.0-862.el7    ################################# [ 50%]
     5:glibc-headers-2.17-222.el7       ################################# [ 63%]
     6:glibc-devel-2.17-222.el7         ################################# [ 75%]
     7:gcc-4.8.5-28.el7                 ################################# [ 88%]
     8:gcc-c++-4.8.5-36.el7             ################################# [100%]
  • gcc -v检查

    [root@zabbix6 gcc-g++-4.8.5-rpm]# gcc -v
    使用内建 specs。
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
    目标:x86_64-redhat-linux
    配置为:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
    线程模型:posix
    gcc 版本 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)

五、安装Zabbix6.4.20

  • 下载zabbix-6.4.20.tar.gz包并上传至服务器

    登录官网找到版本下载:https://cdn.zabbix.com/zabbix/sources/stable/6.4/
    或直接下载:https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.20.tar.gz

  • 上传至服务器

    [root@zabbix6 ~]# ll
    -rw-r--r--. 1 root root 47050234 12月  5 10:22 zabbix-6.4.20.tar.gz
  • 创建目录并解压

    mkdir /usr/local/zabbix
    tar -zxvf zabbix-6.4.3.tar.gz -C /usr/local/zabbix/

    [root@zabbix6 ~]# ll /usr/local/zabbix/
    总用量 4
    drwxr-xr-x. 13 admin admin 4096 11月 19 22:59 zabbix-6.4.20
  • 创建Zabbix用户及用户组

    groupadd zabbix
    useradd -g zabbix -M -s /sbin/nologin zabbix
  • 编译安装Zabbix6.4

    cd /usr/local/zabbix/zabbix-6.4.3/
    ./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-net-snmp --with-mysql
  • 编译配置成功

    ***********************************************************
    *                                      Now run 'make install'                                           *
    *                                                                                                                         *
    *                                   Thank you for using Zabbix!                                     *
    *                                    <http://www.zabbix.com>                                       *
    ***********************************************************
  • 执行 make install进行编译

    make install

    无报错完成即可

六、安装PHP

  • 安装remi库

    由于CentOS7自带PHP版本为5.6,所以需要安装额外的库,也是remi的库:

    yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
    yum -y install yum-utils epel-release
    yum-config-manager --disable 'remi-php*'
    yum-config-manager --enable   remi-php74
    yum -y install php php-bcmath php-gd php-xml php-mbstring php-mysqlnd php-ldap
    yum -y install libxml2 libxml2-devel

    检查版本

    [root@localhost ~]# php -v
    PHP 7.4.33 (cli) (built: Jun  6 2023 16:33:05) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies

    vim /etc/php.ini ,修改以下值

    max_execution_time = 300
    post_max_size = 16M
    max_input_time = 300

七、配置httpd,导入zabbix数据,启动zabbix服务

  • 配置httpd

    移动前端文件至web服务的根目录并授权

    cp -r /usr/local/zabbix/zabbix-6.4.3/ui/* /var/www/html/
    chown apache:apache /var/www/html -R
  • 导入数据库架构及数据

    第一行需要使用root账户,否则会报错:

    ERROR 1419 (HY000) at line 2255: You do not have the SUPER privilege and binary logging is enabled (you might want to use the less safe log_bin_trust_function_creators variable)

    mysql -uroot -pJzx_2024# zabbix < /usr/local/zabbix/zabbix-6.4.20/database/mysql/schema.sql
    mysql -uzabbix -pZabbix@123 zabbix < /usr/local/zabbix/zabbix-6.4.20/database/mysql/images.sql
    mysql -uzabbix -pZabbix@123 zabbix < /usr/local/zabbix/zabbix-6.4.20/database/mysql/data.sql
  • 修改配置zabbixserver文件数据库密码

    vim /usr/local/zabbix/etc/zabbix_server.conf
    DBPassword=Jzx_2024#
  • 开启httpd,zabbix_server,zabbix_agent

    service httpd start
    systemctl enable httpd.service
    cd /usr/local/zabbix/sbin/
    ./zabbix_server
    ./zabbix_agent

八、访问zabbix web页面

image

image

  • 填写用户名/密码

    zabbix/Jzx_2024#

image

image

image

默认用户名密码:Admin / zabbix

image

image

  • 显示中文乱码解决方法

    在zabbix-server服务器上安装如下文件符集

    yum install -y wqy-microhei-fonts

    然后替换zabbix上默认的字符集

    cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /var/www/html/assets/fonts/DejaVuSans.ttf
  • 重启zabbix-server

image

其他服务器安装zabbix_agent

  • 安装zabbix_agent,使用清华镜像源
yum install -y https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.4/rhel/7/x86_64/zabbix-agent-6.4.3-release1.el7.x86_64.rpm
  • 编辑配置文件,修改以下参数
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.2.5             (server端主机ip)
ServerActive=192.168.2.5       (server端主机ip)
Hostname=192.168.2.4           (此主机名与web添加主机名一致)
UnsafeUserParameters=1         (运行自定义参数)
  • 启动&&开机自启动
systemctl start zabbix-agent
systemctl enable zabbix-agent
  • 去zabbix_server添加主机 !
阅读:1883
发布时间: