Zabbix 官网 >:https://www.zabbix.com/download

源代码地址>:https://www.zabbix.com/cn/download_sources#tab:40LTS

zabbix-4.0.13.tar.gz> :https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.13/zabbix-4.0.13.tar.gz

Git拉取>: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse

说明手册>:https://www.zabbix.com/documentation/4.0/manual/installation/install

Centos 7 环境

1 YUM更新源     #--exclude=kernel*,centos-release*,httpd,nginx,php,mysql,mairadb,python-psutil,python2-psutil,cacti (不会升级下载参数--exclude=)

yum install -y --exclude=kernel*,centos-release*,httpd,nginx,php,mysql,mairadb,python-psutil,python2-psutil,cacti yum-fastestmirror redhat-lsb compat* logrotate lsof net-tools lrzsz cmake wget gcc c++ gcc-c++ make zlib-devel readline-devel automake ncurses-devel epel-release bash-completion sysstat mlocate kernel kernel-headers kernel-devel iptables-services apr* autoconf bison bzip2 bzip2* bzip2-devel cpp curl curl-devel fontconfig fontconfig-devel freetype* freetype-devel gd gettext gettext-libs gettext-devel gettext-common-devel glibc glibc-devel glibc-headers keyutils keyutils-libs-devel krb5-devel libcom_err-devel libpng-devel libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool libtool* libgomp libxml2 libxml2-devel libXpm* libxml* libXaw-devel libXmu-devel libtiff libtiff* mpfr ncurses* ntp ntpdate* openssl-devel patch pcre-devel php-common php-gd policycoreutils telnet t1lib t1lib* nasm nasm* libwebp libwebp-devel libjpeg-devel db4-devel libXpm-devel libc-client-devel openldap-devel mysql-devel libicu-devel libcurl libcurl-devel libzip cpan tcp_wrappers psmisc tree cyrus-sasl-md5 vim chrony rsync xinetd crontabs iptables-utils git dos2unix boost-devel boost-doc libxslt libxslt-devel libdb4* qpid* gnutls boost-system avahi-libs boost-thread dwz dyninst emacs-filesystem fipscheck fipscheck-lib gdb libdwarf libedit libgfortran unzip zip trousers pakchois nettle neon m4 mokutil libproxy libstdc++-devel libquadmath libquadmath-devel libmpc libmodman libgnome-keyring subversion-libs systemtap-devel systemtap-runtime openssh openssh-clients systemtap-client perl perl-Carp perl-Data-Dumper perl-Encode perl-Error perl-Exporter perl-File-Path perl-File-Temp perl-Filter perl-Getopt-Long perl-Git perl-HTTP-Tiny perl-PathTools perl-Pod-Escapes perl-Pod-Perldoc perl-Pod-Simple perl-Pod-Usage perl-Scalar-List-Utils perl-Socket perl-Storable perl-TermReadKey perl-Test-Harness perl-Text-ParseWords perl-Thread-Queue perl-Time-HiRes perl-Time-Local perl-XML-Parser perl-constant perl-libs perl-macros perl-parent perl-podlators perl-srpm-macros perl-threads perl-threads-shared screen tcpdump nc mtr nmap tcl policycoreutils-python policycoreutils-python.x86_64 httpd libjpeg gd php-mysql php-odbc php-pear php-xmlrpc php-mhash php-bcmath php-mbstring php-process  php-snmp php-ldap php-xml net-snmp net-snmp-utils rrdtool rrdtool-devel rrdtool-php help2man net-snmp-devel binutils perl-devel --skip-broken && yum clean all

2 NTP时间设置

systemctl start ntpd
timedatectl set-timezone "Asia/Shanghai"
systemctl enable ntpd
ntpdate cn.pool.ntp.org
sudo systemctl restart ntpd
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
clock --systohc
hwclock -w
date '+%Y/%m/%d %T %Z'

3 关闭Selinux,firewalld | iptables防火墙使用其一

setenforce 0
sed -i '7,12s/^/#&/g;7,12s/##/#/g;13cSELINUX=disabled' /etc/selinux/config

4 安装确保Apache、Mariadb正常启动

systemctl start httpd.service
systemctl enable httpd.service
systemctl start mariadb.service
systemctl enable mariadb.service

1. 解压缩源代码

tar -zxvf zabbix-4.0.0.tar.gz

 2.创建用户账户

groupadd zabbix
useradd -g zabbix zabbix

3.创建 Zabbix 数据库

#初始化数据库
mysql_secure_installation
#设置mysqlroot密码...
mysqladmin -uroot password ...
#登录mysql-root
mysql -uroot -p...
#建立zabbix数据库
mysql -uroot -p... -e "create database zabbix character set utf8 collate utf8_bin;"
#设置zabbix数据库本地登录
mysql -uroot -p... -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
#刷新数据库
mysql -uroot -p... -e "flush privileges;"
#导入zabbix数据库
cd zabbix-4.2.1
mysql -uzabbix -pzabbix -e "use zabbix;source schema.sql;source images.sql;source data.sql;"

4.编译配置测试

./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

5.安装

make install

6.设置模块zabbix密码

sed -i s/'# DBPassword='/'DBPassword=zabbix'/g  /usr/local/etc/zabbix_server.conf

7.复制zaabix到/var/html/www

cp -r  frontends/php/ /var/www/html/zabbix

8.配置模块参数调优

sed -i s/'^max_execution_time.*'/'max_execution_time = 300'/g /etc/php.ini
sed -i s/'^max_input_time.*'/'max_input_time = 300'/g /etc/php.ini
sed -i s/'^post_max_size.*'/'post_max_size = 16M'/g /etc/php.ini
sed -i s/'^;date.timezone.*'/'date.timezone = Asia\/Shanghai'/g /etc/php.ini

9.启动zabbix

systemctl restart httpd
systemctl restart mariadb
zabbix_server
01-21 10:46