0


Zabbix6.4+Centos7搭建流程踩坑

    由于最近公司需要针对部分服务器搭建Zabbix监控,活落到自己身上,特此开专栏记录以后Zabbix踩坑过程和学习历程。

    刚开始就遇到很多坑,Zabbix各大版本差异还是比较大的,语法功能以及依赖环境的版本支持都是有比较严苛的限制,不兼容的情况下无法搭建成功,老板说要搭就搭最新的,截止目前最新版为6.4,网上6.4版本甚至6.0相关内容都比较少,写此文章也算是分享踩坑经验,希望对读者有所帮助。

    查阅官网相关环境说明,主要环境为Mysql8和PHP7.25以上,确认环境后开始安装![](https://img-blog.csdnimg.cn/46778852a39149b6a414ce787ee9c0ce.png)

1.安装Mysql8.0

​
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
yum -y install yum-utils
rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
yum-config-manager --enable mysql80-community
yum -y install mysql-community-server
systemctl start mysqld
//查看临时密码
grep 'temporary password' /var/log/mysqld.log
​#创建zabbix库
create database zabbix character set utf8 collate utf8_bin;
#创建zabbix用户
create user zabbix@localhost identified by ' xxx';
#授权
grant all privileges on zabbix.* to zabbix@localhost;

2.安装PHP8.0

安装依赖包

# yum install -y gcc gcc-c++ make gd-devel libxml2-devel \
libcurl-devel libjpeg-devel libpng-devel openssl-devel \
libxslt-devel  sqlite-devel bzip2-devel libicu-devel

//安装oniguruma(因为yum源没有所以需要下载)
tar -xvf oniguruma-6.9.4.tar.gz
./configure --prefix=/usr --libdir=/lib64
make && make install

//安装libzip(因为yum下载有版本不兼容问题所以需要下载)
tar -zxvf libzip-1.3.2.tar.gz
./configure
make && make install
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
whereis libzip

配置PHP环境
./configure --prefix=/usr/local/soft/php8 --with-config-file-path=/usr/local/soft/php8/etc --with-curl --with-freetype --enable-gd --with-jpeg  --with-gettext --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql  --with-pdo-sqlite --with-pear --enable-sockets --with-mhash --with-ldap-sasl --with-xsl --with-zlib --with-zip -with-bz2 --with-iconv  --enable-fpm --enable-pdo  --enable-bcmath  --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl  --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-sysvsem --enable-cli --enable-opcache --enable-intl --enable-calendar --enable-static --enable-mysqlnd

//出现如下表示依赖环境没有问题
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+
# make -j 8 && make install
//测试安装结果
/usr/local/soft/php8/bin/php –version

//拷贝配置文件
cp php.ini-production /usr/local/soft/php8/etc/php.ini
cd /usr/local/soft/php8/etc/php-fpm.d/
cp www.conf.default www.conf
cd /usr/local/soft/php8/etc/
cp php-fpm.conf.default php-fpm.conf
mkdir /usr/local/soft/php8/daemon
cp /usr/local/source/php-8.0.0/sapi/fpm/init.d.php-fpm /usr/local/soft/php8/daemon/php-fpm
chmod 740 /usr/local/soft/php8/daemon/php-fpm
/usr/local/soft/php8/daemon/php-fpm start

3.安装Zabbix_Server

前置环境(解决make时c99错误)

yum install centos-release-scl
yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash

安装前置依赖环境

yum -y install mysql-devel  net-snmp-devel  libevent-devel java-1.8.0-openjdk-devel
#创建zabbix组
groupadd zabbix
#创建zabbix用户
useradd -g zabbix -M -s /sbin/nologin zabbix

#移动到zabbix目录
cd /usr/local/zabbix/zabbix-6.0.1/
#编译
./configure --prefix=/usr/local/zabbix/ --enable-server --enable-agent --with-net-snmp --with-mysql --with-libcurl
提示如下可以make install
***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************
修改php配置文件
vi /usr/local/soft/php8/etc/php.ini
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai
修改zabbix_server配置文件
vi /usr/local/zabbix/etc/zabbix_server.conf
DBHost=119.3.109.118
DBName=zabbix
DBUser=zabbix
DBPassword= Raymon@418

4.运行Zabbix_agent(用于监控Server端状态)

/usr/local/zabbix/sbin/zabbix_agentd

5.部署Zabbix Web界面

cp zabbix-6.4.1/ui/* /usr/local/nginx/html/ -rf
vi /usr/local/php/etc/php.ini
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai

配置nginx
server {
        listen       80;
        server_name  localhost;

        access_log  logs/zabbix.access.log  main;

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

        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}
启动服务
systemctl start zabbix-server

6.安装Zabbix_agent(需要监控的服务器才要安装agent)

yum -y install  https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.4/rhel/7/x86_64/zabbix-agent2-6.4.1-release1.el7.x86_64.rpm

修改配置文件IP为Server端IP

vi /etc/zabbix/zabbix_agent2.conf
Server='ServerIp'
systemctl enable zabbix-agent2
systemctl start zabbix-agent2

结束,Nginx安装省略

标签: centos 运维 linux

本文转载自: https://blog.csdn.net/ChaseDream18/article/details/130427864
版权归原作者 PeasantCoding 所有, 如有侵权,请联系我们删除。

“Zabbix6.4+Centos7搭建流程踩坑”的评论:

还没有评论