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

												

最新文章

  1. CountDownLatch和CyclicBarrier 举例详解
  2. ubuntu 跟xshell的问题
  3. git忽略以点开头的文件夹
  4. ASP.NET页面中去除VIEWSTATE视
  5. 抽象类和接口 static final finalize
  6. PowerShell定时抓取屏幕图像
  7. Hbase rest方式获取指定key范围内的值
  8. MySql中的事件
  9. 【转】traits技术及模板偏特化
  10. 领域驱动设计和实践(转:http://kb.cnblogs.com/page/112298/)
  11. SharePoint solution and feature management with PowerShell
  12. JAVA GUI学习 - 窗口【x】按钮关闭事件触发器:重写processWindowEvent(WindowEvent e)方法
  13. RAID6三块硬盘离线导致的数据丢失恢复过程
  14. 判断HTML中的checkbox是否被选中
  15. webpack学习笔记--配置module
  16. Python向上取整,向下取整以及四舍五入函数
  17. Cmd管理员运行
  18. 在Windows 2008上安装Windows Mobile设备中心
  19. laravel记住登录、设置时间
  20. 洛咕P3250 [HNOI2016]网络 整体二分

热门文章

  1. vue父组件如何向子组件中传递数据?
  2. PJzhang:CVE-2019-14287 sudo权限绕过漏洞复现
  3. 【FFMPEG】使用FFMPEG+H264实现RTP传输数据
  4. C++学习笔记-继承中的构造与析构
  5. 《ThinkPHP 5.0快速入门》 基础和路由
  6. 第五周课程总结&amp;试验报告(三)
  7. ubuntu 16.04主题美化
  8. 腾讯云服务器的CPU ---发现大厂都很那啥
  9. web应用安全
  10. Synchronize和ReentrantLock区别