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

先决条件 最低要求 描述
PHP 版本 5.4.0  
PHP memory_limit 选项 128MB 位于 php.ini:
memory_limit = 128M
PHP post_max_size 选项 16MB 位于 php.ini:
post_max_size = 16M
PHP upload_max_filesize 选项 2MB 位于 php.ini:
upload_max_filesize = 2M
PHP max_execution_time 选项 300 seconds (此值允许为 0 和 -1 ) 位于 php.ini:
max_execution_time = 300
PHP max_input_time 选项 300 seconds (此值允许为 0 和 -1) 位于 php.ini:
max_input_time = 300
PHP session.auto_start 选项 必须禁用此值 In php.ini:
session.auto_start = 0
数据库支持 其中之一: MySQL,、Oracle、PostgreSQL、IBM DB2 必须安装下列模块中的一种:
mysql、oci8、pgsql、ibm_db2
bcmath   php-bcmath
mbstring   php-mbstring
PHP mbstring.func_overload 选项 必须禁用此值 位于 php.ini:
mbstring.func_overload = 0
PHP always_populate_raw_post_data option 必须禁用此值 只适用于 PHP 5.6.0 或更高的版本。
位于 php.ini:
always_populate_raw_post_data = -1
sockets   php-net-socket 用于支持用户脚本。
gd 2.0 或更高 php-gd. PHP GD 扩展必须支持 PNG 图像 (--with-png-dir),、JPEG (--with-jpeg-dir) 图像和 FreeType 2 (--with-freetype-dir).
libxml 2.6.15 php-xml or php5-dom
xmlwriter   php-xmlwriter
xmlreader   php-xmlreader
ctype   php-ctype
session   php-session
gettext   php-gettext
从 Zabbix 2.2.1 起,PHP gettext 扩展不是安装 Zabbix 的强制性要求。如果 gettext 没有安装,前端也可以照常运行,但翻译将不可用。
#backup mairiadb//备份数据库全部数据
mysqldump -u root -p --all-databases > alldb_cacti.sql
cp /etc/my.cnf /root/my.cnf.bak
#yum update mariadb//yum 升级mariadb数据库到10.4.9
#curl=http://yum.mariadb.org
systemctl stop mariadb && mv /etc/my.conf /etc/my.conf.bak && rm -rf /etc/my.conf /var/lib/mysql/
yum remove mariadb
echo '[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4.8/centos7-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1'> /etc/yum.repos.d/mariadb.repo
yum clean all && yum makecache all
yum install -y mariadb-server MariaDB-client

Centos 7 环境(LAMP)

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
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.13.tar.gz

2.创建用户账户

groupadd zabbix
useradd -g zabbix zabbix

3.创建 Zabbix 数据库类型mysql

[root@localhost zabbix-4.0.]# find . -name *.sql
./database/ibm_db2/data.sql
./database/ibm_db2/images.sql
./database/ibm_db2/schema.sql
./database/mysql/data.sql
./database/mysql/images.sql
./database/mysql/schema.sql
./database/oracle/data.sql
./database/oracle/images.sql
./database/oracle/schema.sql
./database/postgresql/data.sql
./database/postgresql/images.sql
./database/postgresql/schema.sql
./database/sqlite3/data.sql
./database/sqlite3/images.sql
./database/sqlite3/schema.sql

#初始化数据库

[root@localhost zabbix-4.0.13]# systemctl start mariadb
[root@localhost zabbix-4.0.13]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none)://初次运行直接回车
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y //是否切换到 unix_socket 身份验证
Enabled successfully!
Reloading privilege tables..
... Success!

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y//是否设置root用户密码
New password: //设置mysql的root密码
Re-enter new password://再mysql的root密码输入
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y//是否删除匿名用户,生产环境建议删除
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] N//是否禁止root远程登录
... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y//是否删除test数据库
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y//是否重新加载权限表
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

#设置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';"
#设置zabbix账号密码
mysql -uroot -p... -e "GRANT SELECT ON mysql.time_zone_name TO 'zibbix'@localhost IDENTIFIED BY 'zabbix';"
#刷新数据库
mysql -uroot -p... -e "flush privileges;"
#导入zabbix数据库类型mysql

cp -r zabbix-4.0.13 /var/www/html/zabbix
cd /var/www/html/zabbix/database/mysql/
mysql -uzabbix -pzabbix -e "use zabbix;source schema.sql;source images.sql;source data.sql;"
#mysql -uzabbix -pzabbix zabbix < schema.sql
#mysql -uzabbix -pzabbix zabbix < images.sql
#mysql -uzabbix -pzabbix zabbix < data.sql
#刷新数据库
mysql -uroot -p... -e "flush privileges;"

4.编译配置测试

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

configure: error: MySQL library not found
请安装yum install -y mysql-devel
configure: error: Not found mariadb library
请安装yum install -y mariadb-devel
[root@localhost zabbix]# which mariadb
/usr/bin/mariadb
[root@localhost zabbix-4.0.13]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

rpm -qa | grep mariadb
rpm -e --nodeps name
configure: error: Invalid Net-SNMP directory - unable to find net-snmp-config
yum install net-snmp net-snmp-devel

5.测试编译配置结果

Configuration:

  Detected OS:           linux-gnu
Install path: /usr/local
Compilation arch: linux Compiler: cc
Compiler flags: -g -O2 Library-specific flags:
database:
libXML2: -I/usr/include/libxml2
Net-SNMP: -I/usr/local/include -I/usr/lib64/perl5/CORE -I. -I/usr/include Enable server: yes
Server details:
With database: MySQL
WEB Monitoring: cURL
SSL certificates: /usr/local/share/zabbix/ssl/certs
SSL keys: /usr/local/share/zabbix/ssl/keys
Native Jabber: no
SNMP: yes
IPMI: no
SSH: no
TLS: no
ODBC: no
Linker flags: -L/usr/lib64 -rdynamic
Libraries: -lxml2 -lnetsnmp -lz -lpthread -levent -lcurl -lm -ldl -lresolv -lpcre
Configuration file: /usr/local/etc/zabbix_server.conf
External scripts: /usr/local/share/zabbix/externalscripts
Alert scripts: /usr/local/share/zabbix/alertscripts
Modules: /usr/local/lib/modules Enable proxy: no Enable agent: yes
Agent details:
TLS: no
Linker flags: -rdynamic
Libraries: -lz -lpthread -lcurl -lm -ldl -lresolv -lpcre
Configuration file: /usr/local/etc/zabbix_agentd.conf
Modules: /usr/local/lib/modules Enable Java gateway: no LDAP support: no
IPv6 support: yes ***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************

6..编译并安装

make install
db.c::: fatal error: mysql.h: No such file or directory
# include "mysql.h"
^
compilation terminated.
make[]: *** [libzbxdb_a-db.o] Error
make[]: Leaving directory `/usr/local/src/zabbix-4.0./src/libs/zbxdb'
make[]: *** [install-recursive] Error
make[]: Leaving directory `/usr/local/src/zabbix-4.0./src/libs'
make[]: *** [install-recursive] Error
make[]: Leaving directory `/usr/local/src/zabbix-4.0./src'
make: *** [install-recursive] Error
[root@localhost zabbix-4.0.]# find / -name "mysql.h"
/usr/include/mysql/mysql.h
/usr/include/mysql/server/mysql.h
make[]: Leaving directory `/var/www/html/zabbix/man'
make[]: Leaving directory `/var/www/html/zabbix/man'
Making install in misc
make[]: Entering directory `/var/www/html/zabbix/misc'
make[]: Entering directory `/var/www/html/zabbix/misc'
make[]: Nothing to be done for `install-exec-am'.
make[]: Nothing to be done for `install-data-am'.
make[]: Leaving directory `/var/www/html/zabbix/misc'
make[]: Leaving directory `/var/www/html/zabbix/misc'
make[]: Entering directory `/var/www/html/zabbix'
make[]: Entering directory `/var/www/html/zabbix'
make[]: Nothing to be done for `install-exec-am'.
make[]: Nothing to be done for `install-data-am'.
make[]: Leaving directory `/var/www/html/zabbix'
make[]: Leaving directory `/var/www/html/zabbix'

7.查看和编辑配置文件

在此编辑 Zabbix agent 的配置文件 /usr/local/etc/zabbix_agentd.conf
您需要为每台安装了 zabbix_agentd 的主机配置这个文件。

您必须在这个文件中指定 Zabbix server 的 IP 地址 。若从其他主机发起的请求会被拒绝。

在此编辑 Zabbix server 的配置文件 /usr/local/etc/zabbix_server.conf
您必须指定数据库的名称、用户和密码(如果使用的话)。

如果您进行小型环境部署(最多十个受监控主机),其余参数的默认值将适合您的环境。 如果要最大化 Zabbix server(或 proxy)的性能,则应更改默认参数。 详见性能调整。

如果您安装了 Zabbix proxy,请在此编辑 proxy 的配置文件 /usr/local/etc/zabbix_proxy.conf
您必须指定 Zabbix server 的 IP 地址和 Zabbix proxy 主机名(必须被 Zabbix server 识别),同时也要指定数据库的名称、用户和密码(如果使用的话)。

8.设置模块zabbix密码

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

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

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

10.授权zabbix目录

chcon -R -t httpd_sys_content_t /var/www/html/zabbix
chown zabbix.apache /var/www/html/zabbix/ -R

11.配置模块参数调优

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

12.firewalld | iptables (默认端口80)

-A INPUT -m state --state NEW -m tcp -p tcp --dport  -j ACCEPT
firewall-cmd --permanent --add-port=/tcp
firewall-cmd --reload
firewall-cmd --list-ports

13.启动zabbix

systemctl restart httpd
systemctl restart mariadb

14.守护进程

zabbix_server
#zabbix_agentd
#zabbix_proxy

注:zabbix_server默认日志文件位置在/tmp/zabbix_server.log

												

centos 7 源代码搭建部署 zabbix-4.0.13 LTS的更多相关文章

  1. CentOS 6.5安装部署Zabbix监控系统

    CentOS 6.5安装部署Zabbix监控系统 先说一点废话,我没有用centos7做实验,讲真,centos 7我也不常用,喜欢新版本的同学其实可以尝试下,注意一点的就是centos 6.5只支持 ...

  2. 部署zabbix 4.0 + grafana

    不完整,仅供参考 Zabbix+grafana监控部署 基本环境 系统: CentOS Linux release 7.3.1611 Zabbix—server:  Zabbix_agent:   N ...

  3. LNMP 方式部署 zabbix 5.0

    文章链接 Zabbix 5.0 LTS新增功能 新版本附带了可用性,安全性和完整性方面的重大改进列表.Zabbix团队遵循的主要策略是使Zabbix尽可能可用.Zabbix是一种开源,免费的监视解决方 ...

  4. 部署Zabbix 6.0 LTS

    Blog:博客园 个人 本部署文档适用于CentOS 8.X/RHEL 8.X/Anolis OS 8.X/AlmaLinux 8.X. Zabbix 6.0 LTS于2022年2月15日发布,本次大 ...

  5. CentOS 7 源码安装 Zabbix 6.0

    Zabbix 主要有以下几个组件组成: Zabbix Server:Zabbix 服务端,是 Zabbix 的核心组件.它负责接收监控数据并触发告警,还负责将监控数据持久化到数据库中. Zabbix ...

  6. CentOS 6.4编译安装和部署Zabbix 2.0版本监控(中文)

    [一].zabbix简介 zabbix是一个基于web界面的提供分布式系统监视以及网络监视功能的企业级开元解决方案 zabbix由2部分构成,zabbix_server和可选组件zabbix_agen ...

  7. Centos 7 最小化部署zabbix

    前言 文章内容是作者本人编写,之前一直放在word文档中,突然有闲情转移到博客上来了,欢迎后续观看者有问题找我探讨~~~ 废话不多说,先说下原理吧 概述 工作原理 通过c/s模式采集数据,基于b/s模 ...

  8. CentOS 6.9搭建CDH 5.12.0集成环境

    Cloudera Manager则是为了便于在集群中进行Hadoop等大数据处理相关的服务安装和监控管理的组件,对集群中主机.Hadoop.Hive.Spark等服务的安装配置管理做了极大简化.   ...

  9. CentOS 6.6 搭建Zabbix 3.0.3 过程

    分享CentOS 6.6下搭建Zabbix 3.0.3 的过程,希望都大家有所帮助. 环境安装 系统环境: # cat /etc/RedHat-release CentOS release 6.6 ( ...

随机推荐

  1. jenkins常用插件安装

    1.常用jenkins插件 插件相关下载地址:http://updates.jenkins-ci.org/download/plugins/ git.hpi git-client.hpi gitlab ...

  2. 安装cni网络插件-非必须

    安装cni网络插件 安装cni # 安装 cni # 百度云链接:https://pan.baidu.com/s/1-PputObLs5jouXLnuBCI6Q 密码:tzqm cd /server/ ...

  3. cmake 在mac系统的安装

    CMake是一个比make更高级的跨平台的安装.编译.配置工具,可以用简单的语句来描述所有平台的安装(编译过程).并根据不同平台.不同的编译器,生成相应的Makefile或者project文件.本文主 ...

  4. 20190925 - 在 macOS 下为 vscode 添加 code 命令行

    在 macOS 下为 vscode 添加 code 命令行最简单办法是:Ctrl + Alt + P,安装 Shell Command: Install 'code' command in PATH, ...

  5. IO模型,非阻塞IO模型,select实现多路复用

    1. IO阻塞模型 IO问题: 输入输出 我要一个用户名用来执行登陆操作,问题用户名需要用户输入,输入需要耗时, 如果输入没有完成,后续逻辑无法继续,所以默认的处理方式就是 等 将当前进程阻塞住,切换 ...

  6. C语言递归之对称二叉树

    题目描述 给定一个二叉树,检查它是否是镜像对称的. 示例 二叉树 [1,2,2,3,4,4,3] 是对称的. / \ / \ / \ [1,2,2,null,3,null,3] 则不是镜像对称的. / ...

  7. LCA -cogs2098 [SYOI 2015] Asm.Def的病毒

    题目链接:http://cogs.pro:8081/cogs/problem/problem.php?pid=vQXmxVaPU [题目描述] “这就是我们最新研制的,世界上第一种可持久化动态计算机病 ...

  8. jquery-validation JQ 表单验证

    jquery-validation是一款前端验证js插件,可以验证必填字段.邮件.URL.数字范围等,在表单中应用非常广泛. 官方网站 https://jqueryvalidation.org/ 下载 ...

  9. python下对目录&文件的操作

    Windows桌面上: 总文件夹 子文件夹01 文档01.txt-------------------------------------------------------------------- ...

  10. Apache配置同一IP使用多域名对应多个网站

    CentOS下的Apache的配置是/etc/httpd/conf/httpd.conf vi /etc/httpd/conf/httpd.conf 添加 <VirtualHost *:80&g ...