操作系统准备

生产环境部署,优选LTS长期支持版本,最近在某客户现场做Zabbix实施服务,顺便记录分享部署过程:)

[root@swordmaster ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

[root@swordmaster ~]# hwclock --systohc

[root@swordmaster ~]# getenforce
Disabled

[root@swordmaster ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.9M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root 1015G  1.3G 1014G   1% /
/dev/sda1               1014M  150M  865M  15% /boot
tmpfs                    783M     0  783M   0% /run/user/0

[root@swordmaster ~]# fdisk -l

Disk /dev/sda: 1099.5 GB, 1099511627776 bytes, 2147483648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000dc7b8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200  2147483647  1072692224   8e  Linux LVM

Disk /dev/mapper/centos-root: 1090.0 GB, 1089973780480 bytes, 2128855040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-swap: 8455 MB, 8455716864 bytes, 16515072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

关注要点:时间同步、分区、selinux、firewall-cmd

基础组件安装

[root@swordmaster ~]# yum -y update
[root@swordmaster ~]# yum -y install wget vim

[root@swordmaster ~]# php -v
PHP 7.2.34 (cli) (built: Jul  2 2021 11:51:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

[root@swordmaster ~]# mysql -V
mysql  Ver 14.14 Distrib 5.7.34, for Linux (x86_64) using  EditLine wrapper

[root@swordmaster ~]# nginx -v
nginx version: nginx/1.20.0

关注要点:系统更新、Nginx、PHP、MySQL环境

Zabbix-Server安装

groupadd zabbix
useradd -g zabbix -s /sbin/nologin zabbix
yum -y install net-snmp net-snmp-devel curl curl-devel perl-DBI net-snmp-utils
mysql -uroot -proot -e "create database zabbix character set utf8 collate utf8_bin;"

wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.13.tar.gz
tar -zxf zabbix-5.0.13.tar.gz
cd zabbix-5.0.13
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/usr/local/mysql/bin/mysql_config --enable-ipv6 --with-net-snmp --with-libcurl --with-openssl --with-libxml2
#编译参数新增--with-libxml2,为了监控VMware vSphere主机做准备

make install

vim /etc/services

#添加下面的字段
zabbix-agent    10050/tcp               #Zabbix Agent
zabbix-agent    10050/udp               #Zabbix Agent
zabbix-trapper  10051/tcp               #Zabbix Trapper
zabbix-trapper  10051/udp               #Zabbix Trapper

vim /usr/local/zabbix/etc/zabbix_server.conf
#修改 zabbix server 配置文件
#注意:DBUser和DBPassword请自行根据实际情况填写数据库用户名及密码
DBUser=zabbix
DBPassword=zabbix
DBSocket=/tmp/mysql.sock

cp /root/zabbix-5.0.13/misc/init.d/fedora/core/zabbix_* /etc/init.d/
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_server
sed -i 's/BASEDIR=\/usr\/local/BASEDIR=\/usr\/local\/zabbix/g' /etc/init.d/zabbix_agentd
chmod +x /etc/init.d/zabbix_server
chmod +x /etc/init.d/zabbix_agentd

vim /etc/ld.so.conf

#添加mysql client库到系统默认库中:
/usr/local/mysql/lib

cp -r -a ui/* /home/wwwroot/default/zabbix/
#根据实际环境情况,将WEB UI拷贝到Nginx根目录

chown -R www:www /home/wwwroot/default/zabbix/

以下配置fping用于Zabbix简单检查
yum install epel-release.noarch
yum install fping
chown root:zabbix /usr/sbin/fping
chmod 710 /usr/sbin/fping
chmod ug+s /usr/sbin/fping
#修改/usr/local/zabbix/etc/zabbix_server.conf,删除FpingLocation=/usr/sbin/fping前的注释。

mysql -uroot -proot
#导入数据库

use zabbix;
source /root/zabbix-5.0.13/database/mysql/schema.sql
source /root/zabbix-5.0.13/database/mysql/images.sql
source /root/zabbix-5.0.13/database/mysql/data.sql

/etc/init.d/zabbix_server start
[root@swordmaster ~]# /etc/init.d/zabbix_server status
● zabbix_server.service - SYSV: Starts and stops Zabbix Server using chkconfig
   Loaded: loaded (/etc/rc.d/init.d/zabbix_server; bad; vendor preset: disabled)
   Active: active (exited) since Fri 2021-07-02 12:30:18 CST; 8s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 5325 ExecStart=/etc/rc.d/init.d/zabbix_server start (code=exited, status=0/SUCCESS)

Jul 02 12:30:18 swordmaster.sdfyy.cn systemd[1]: Starting SYSV: Starts and stops Zabbix Server using chkconfig...
Jul 02 12:30:18 swordmaster.sdfyy.cn zabbix_server[5325]: Starting zabbix_server:  [  OK  ]
Jul 02 12:30:18 swordmaster.sdfyy.cn systemd[1]: Started SYSV: Starts and stops Zabbix Server using chkconfig.

Zabbix-web安装

需要先将php.ini的max_input_time改成300,默认是60,修改后重启php-fpm,接着web访问一路安装向导安装即可。

CentOS 7安装Zabbix 5.0 LTS版

相关新闻

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

联系我们

联系我们

400-0512-768

邮件:support@sworditsys.com

工作时间:周一至周五 8:00 - 21:00

分享本页
返回顶部