附zabbixdocker鏡像地址
https://hub.docker.com/u/zabbix/
zabbix官方文檔
https://www.zabbix.com/cn/download
1、關(guān)閉防火墻和selinux
systemctl stop firewalld
vi /etc/selinux/config
SELINUX=permissive
setenforce 0
復(fù)制代碼[root@localhost ~]# systemctl is-active firewalldactive[root@localhost ~]# [root@localhost ~]# systemctl stop firewalld[root@localhost ~]# [root@localhost ~]# getenforce Enforcing[root@localhost ~]# setenforce 0[root@localhost ~]# [root@localhost ~]# vi /etc/selinux/config # This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=permissive# SELINUXTYPE= can take one of three two values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected.# mls - Multi Level Security protection.SELINUXTYPE=targeted
2、添加zabbix存儲庫
rpm -ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpm
[root@localhost ~]# rpm -ivh https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpmRetrieving https://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-1.el7.noarch.rpmwarning: /var/tmp/rpm-tmp.fHl7KV: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEYPreparing... ################################# [100%]Updating / installing... 1:zabbix-release-4.2-1.el7 ################################# [100%][root@localhost ~]# ls /etc/yum.repos.d/mylocal.repo zabbix.repo
3、安裝zabbix-server-mysql和zabbix-web-mysql
yum install -y zabbix-server-mysql zabbix-web-mysql
要在 MySQL支持下安裝Zabbix服務(wù)器
要在 MySQL支持下安裝Zabbix前端
要使用MySQL支持安裝Zabbix代理
yum install zabbix-proxy-mysql -y
[root@localhost ~]# yum install zabbix-proxy-mysql -yInstalled: zabbix-proxy-mysql.x86_64 0:4.2.0-1.el7 Complete!
對服務(wù)器進(jìn)行自身監(jiān)控
安裝zabbix-agent客戶端
yum install zabbix-agent -y
設(shè)置開機(jī)自啟動
systemctl start zabbix-agent
chkconfig zabbix-agent on
Installed: zabbix-agent.x86_64 0:4.2.0-1.el7 Complete![root@localhost ~]#[root@localhost ~]# chkconfig zabbix-agent onNote: Forwarding request to 'systemctl enable zabbix-agent.service'.Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.[root@localhost ~]#
4、安裝并且啟動mysql5.6及初始化數(shù)據(jù)庫信息
rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpm
[root@localhost ~]# rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpmRetrieving http://repo.mysql.com/yum/mysql-5.6-community/el/6/x86_64/mysql-community-release-el6-5.noarch.rpmPreparing... ################################# [100%]Updating / installing... 1:mysql-community-release-el6-5 ################################# [100%][root@localhost ~]# cd /etc/yum.repos.d/[root@localhost yum.repos.d]#[root@localhost yum.repos.d]# lsmylocal.repo mysql-community.repo mysql-community-source.repo zabbix.repo[root@localhost yum.repos.d]#
yum install -y mysql-community-server
Installed: mysql-community-libs.x86_64 0:5.6.43-2.el6 mysql-community-server.x86_64 0:5.6.43-2.el6 Dependency Installed: mysql-community-client.x86_64 0:5.6.43-2.el6 mysql-community-common.x86_64 0:5.6.43-2.el6 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Replaced: mariadb-libs.x86_64 1:5.5.60-1.el7_5 Complete!
啟動mysqld服務(wù)
systemctl start mysqld
設(shè)置開機(jī)自啟動
chkconfig mysqld on
[root@localhost ~]# systemctl start mysqld[root@localhost ~]# [root@localhost ~]# systemctl status mysqld● mysqld.service - SYSV: MySQL database server. Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled) Active: active (running) since Wed 2019-04-03 01:21:03 CST; 12s ago Docs: man:systemd-sysv-generator(8) Process: 68300 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=0/SUCCESS) Main PID: 68584 (mysqld) CGroup: /system.slice/mysqld.service ├─68380 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedi... └─68584 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.... Apr 03 01:21:02 localhost.localdomain mysqld[68300]: Note: new default config file not created.Apr 03 01:21:02 localhost.localdomain mysqld[68300]: Please make sure your config file is currentApr 03 01:21:02 localhost.localdomain mysqld[68300]: WARNING: Default config file /etc/my.cnf exists on the systemApr 03 01:21:02 localhost.localdomain mysqld[68300]: This file will be read by default by the MySQL serverApr 03 01:21:02 localhost.localdomain mysqld[68300]: If you do not want to use this, either remove it, or use theApr 03 01:21:02 localhost.localdomain mysqld[68300]: --defaults-file argument to mysqld_safe when starting the serverApr 03 01:21:02 localhost.localdomain mysqld[68300]: [ OK ]Apr 03 01:21:03 localhost.localdomain mysqld[68300]: Starting mysqld: [ OK ]Apr 03 01:21:03 localhost.localdomain systemd[1]: mysqld.service: Supervising process 68584 which is not our child. We'll most likely not notice w...t exits.Apr 03 01:21:03 localhost.localdomain systemd[1]: Started SYSV: MySQL database server..Hint: Some lines were ellipsized, use -l to show in full.[root@localhost ~]# [root@localhost ~]# chkconfig mysqld on[root@localhost ~]#
初始化數(shù)據(jù)庫信息
mysql_secure_installation
[root@localhost ~]# mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the currentpassword for the root user. If you've just installed MySQL, andyou haven't set the root password yet, the password will be blank,so you should just press enter here.Enter current password for root (enter for none): //回車OK, successfully used password, moving on...Setting the root password ensures that nobody can log into the MySQLroot user without the proper authorisation.Set root password? [Y/n] yNew password:Re-enter new password:Password updated successfully!Reloading privilege tables.. ... Success!By default, a MySQL installation has an anonymous user, allowing anyoneto log into MySQL without having to have a user account created forthem. This is intended only for testing, and to make the installationgo a bit smoother. You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n] y ... Success!Normally, root should only be allowed to connect from 'localhost'. Thisensures that someone cannot guess at the root password from the network.Disallow root login remotely? [Y/n] n ... skipping.By default, MySQL comes with a database named 'test' that anyone canaccess. This is also intended only for testing, and should be removedbefore moving into a production environment.Remove test database and access to it? [Y/n] y - Dropping test database...ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success!Reloading the privilege tables will ensure that all changes made so farwill take effect immediately.Reload privilege tables now? [Y/n] y ... Success!All done! If you've completed all of the above steps, your MySQLinstallation should now be secure. Thanks for using MySQL! Cleaning up...
5、創(chuàng)建zabbix數(shù)據(jù)庫,創(chuàng)建zabbix賬號
mysql -uroot -p
創(chuàng)建一個zabbix庫并設(shè)置為utf8的字符編碼格式
mysql> create database zabbix character set utf8 collate utf8_bin;
創(chuàng)建賬戶并且授權(quán)設(shè)置密碼
給來自loclhost的用戶zabbxi分配可對數(shù)據(jù)庫zabbix所有表進(jìn)行所有操作的權(quán)限,并且設(shè)定密碼為zabbix
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
刷新
mysql> flush privileges;
[root@localhost ~]# mysql -uroot -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 10Server version: 5.6.43 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.#mysql -uroot -p123456 -e "create database zabbix default character set utf8collate utf8_bin;"#mysql -uroot -p123456 -e "grant all on zabbix. to 'zabbix'@'%' identified by 'zabbix';"#mysql -uroot -p123456 -e "grant all on zabbix. to 'zabbix'@'localhost' identified by 'zabbix';"或如下mysql> create database zabbix character set utf8 collate utf8_bin;Query OK, 1 row affected (0.00 sec)mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> exitBye
6、導(dǎo)入默認(rèn)的zabbix數(shù)據(jù)庫信息
zcat /usr/share/doc/zabbix-server-mysql-4.2.1/create.sql.gz | mysql zabbix -uzabbix -pzabbix
[root@localhost ~]# cd /usr/share/doc/zabbix-server-mysql-4.2.0/[root@localhost zabbix-server-mysql-4.2.0]#[root@localhost zabbix-server-mysql-4.2.0]# lsAUTHORS ChangeLog COPYING create.sql.gz NEWS README[root@localhost zabbix-server-mysql-4.2.0]#[root@localhost zabbix-server-mysql-4.2.0]# zcat /usr/share/doc/zabbix-server-mysql-4.2.0/create.sql.gz | mysql zabbix -uzabbix -pzabbixWarning: Using a password on the command line interface can be insecure.[root@localhost zabbix-server-mysql-4.2.0]#
7、修改zabbix_server.conf的配置文件
grep ^DB /etc/zabbix/zabbix_server.conf
[root@localhost ~]# grep ^DB /etc/zabbix/zabbix_server.confDBHost=localhostDBName=zabbixDBUser=zabbixDBPassword=zabbix
vi /etc/php.ini
在最后一行添加一下內(nèi)容
php_value max_execution_time 300php_value memory_limit 128Mphp_value post_max_size 16Mphp_value upload_max_filesize 2Mphp_value max_input_time 300
8、修改系統(tǒng)時間
安裝ntp服務(wù)
yum install ntpdate -y
調(diào)整為亞洲上海時區(qū)
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
同步時間服務(wù)器
ntpdate us.pool.ntp.org
[root@localhost ~]# yum install ntpdate -y…………………………………………Installed: ntpdate.x86_64 0:4.2.6p5-28.el7.centos Complete![root@localhost ~]# ntpdate us.pool.ntp.org 4 Apr 10:00:11 ntpdate[11904]: step time server 4.53.160.75 offset -32351.195618 sec[root@localhost ~]# date Thu Apr 4 10:00:26 CST 2019[root@localhost ~]# [root@localhost ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime[root@localhost ~]#[root@localhost ~]# ntpdate us.pool.ntp.org 4 Apr 14:40:12 ntpdate[2807]: step time server 72.30.35.89 offset -32392.501158 sec[root@localhost ~]#[root@localhost ~]# dateThu Apr 4 14:40:32 CST 2019[root@localhost ~]#
9、修改配置文件/etc/httpd/conf.d/zabbix.conf,時區(qū)改成 Asia/Shanghai # vi /etc/httpd/conf.d/zabbix.conf
[root@localhost ~]# vi /etc/httpd/conf.d/zabbix.conf## Zabbix monitoring system php web frontend# Alias /zabbix /usr/share/zabbix <Directory "/usr/share/zabbix"> Options FollowSymLinks AllowOverride None Require all granted <IfModule mod_php5.c> php_value max_execution_time 300 php_value memory_limit 128M php_value post_max_size 16M php_value upload_max_filesize 2M php_value max_input_time 300 php_value max_input_vars 10000 php_value always_populate_raw_post_data -1 php_value date.timezone Asia/Shanghai </IfModule></Directory> <Directory "/usr/share/zabbix/conf"> Require all denied</Directory> <Directory "/usr/share/zabbix/app"> Require all denied</Directory> <Directory "/usr/share/zabbix/include"> Require all denied</Directory> <Directory "/usr/share/zabbix/local"> Require all denied</Directory>
10、啟動apache/zabbix-server服務(wù)并設(shè)置為開機(jī)啟動
啟動apache
systemctl start httpd
systemctl enable httpd
[root@localhost ~]# systemctl start httpd[root@localhost ~]# systemctl status httpd● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2019-04-03 01:41:59 CST; 19s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 68678 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─68678 /usr/sbin/httpd -DFOREGROUND ├─68679 /usr/sbin/httpd -DFOREGROUND ├─68680 /usr/sbin/httpd -DFOREGROUND ├─68681 /usr/sbin/httpd -DFOREGROUND ├─68682 /usr/sbin/httpd -DFOREGROUND └─68683 /usr/sbin/httpd -DFOREGROUND Apr 03 01:41:59 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...Apr 03 01:41:59 localhost.localdomain httpd[68678]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using l... messageApr 03 01:41:59 localhost.localdomain systemd[1]: Started The Apache HTTP Server.Hint: Some lines were ellipsized, use -l to show in full.[root@localhost ~]# systemctl enable httpdCreated symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.[root@localhost ~]#
啟動zabbix-server服務(wù)并設(shè)置為開機(jī)啟動
systemctl start zabbix-server
systemctl enable zabbix-server
[root@localhost ~]# systemctl start zabbix-server[root@localhost ~]# [root@localhost ~]# systemctl enable zabbix-serverCreated symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.[root@localhost ~]#
查看zabbix-server日志
tailf /var/log/zabbix/zabbix_server.log
[root@localhost ~]# tailf /var/log/zabbix/zabbix_server.log 4618:20190404:164956.559 server #28 started [icmp pinger #1] 4620:20190404:164956.560 server #30 started [preprocessing manager #1] 4622:20190404:164956.560 server #32 started [preprocessing worker #2] 4625:20190404:164956.561 server #35 started [lld worker #1] 4624:20190404:164956.561 server #34 started [lld manager #1] 4626:20190404:164956.561 server #36 started [lld worker #2] 4623:20190404:164956.562 server #33 started [preprocessing worker #3] 4619:20190404:164956.562 server #29 started [alert manager #1] 4621:20190404:164956.562 server #31 started [preprocessing worker #1] 4610:20190404:164958.602 enabling Zabbix agent checks on host "Zabbix server": host became available
zabbix-server的web目錄
ls /usr/share/zabbix
[root@localhost ~]# ls /usr/share/zabbixactionconf.php audio discoveryconf.php image.php map.import.php slides.phpadm.gui.php auditacts.php disc_prototypes.php images map.php srv_status.phpadm.housekeeper.php auditlogs.php favicon.ico img overview.php stylesadm.iconmapping.php browserwarning.php fonts imgstore.php profile.php sysmap.phpadm.images.php chart2.php graphs.php include queue.php sysmaps.phpadm.macros.php chart3.php history.php index_http.php report2.php templates.phpadm.other.php chart4.php host_discovery.php index.php report4.php toptriggers.phpadm.regexps.php chart5.php hostgroups.php items.php robots.txt tr_events.phpadm.triggerdisplayoptions.php chart6.php hostinventoriesoverview.php js screenconf.php trigger_prototypes.phpadm.triggerseverities.php chart7.php hostinventories.php jsLoader.php screenedit.php triggers.phpadm.valuemapping.php chart.php host_prototypes.php jsrpc.php screen.import.php usergrps.phpadm.workingtime.php charts.php host_screen.php latest.php screens.php users.phpapi_jsonrpc.php conf hosts.php local services.php zabbix.phpapp conf.import.php httpconf.php locale setup.phpapplications.php correlation.php httpdetails.php maintenance.php slideconf.php
10、訪問網(wǎng)站,例如:http://本機(jī)IP/zabbix,如下圖所示:

PHP版本

password是我們設(shè)置的數(shù)據(jù)庫密碼zabbix

輸入名字

查看zabbix基礎(chǔ)信息

finish

Zabbix·server的默認(rèn)賬號Admin 密碼zabbix,如圖所示:

基礎(chǔ)界面如下

根據(jù)提示可以看到上面圖形界面的操作都寫到一個配置文件中
more /etc/zabbix/web/zabbix.conf.php
[root@localhost ~]# more /etc/zabbix/web/zabbix.conf.php<?php// Zabbix GUI configuration file.global $DB; $DB['TYPE'] = 'MYSQL';$DB['SERVER'] = 'localhost';$DB['PORT'] = '0';$DB['DATABASE'] = 'zabbix';$DB['USER'] = 'zabbix';$DB['PASSWORD'] = 'zabbix'; // Schema name. Used for IBM DB2 and PostgreSQL.$DB['SCHEMA'] = ''; $ZBX_SERVER = 'localhost';$ZBX_SERVER_PORT = '10051';$ZBX_SERVER_NAME = 'zabbix4.2'; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;[root@localhost ~]#
移除或改名web目錄下面的setup.php文件
mv setup.php setup.php.bak
[root@localhost ~]# cd /usr/share/zabbix[root@localhost zabbix]#[root@localhost zabbix]# lsactionconf.php audio discoveryconf.php image.php map.import.php slides.phpadm.gui.php auditacts.php disc_prototypes.php images map.php srv_status.phpadm.housekeeper.php auditlogs.php favicon.ico img overview.php stylesadm.iconmapping.php browserwarning.php fonts imgstore.php profile.php sysmap.phpadm.images.php chart2.php graphs.php include queue.php sysmaps.phpadm.macros.php chart3.php history.php index_http.php report2.php templates.phpadm.other.php chart4.php host_discovery.php index.php report4.php toptriggers.phpadm.regexps.php chart5.php hostgroups.php items.php robots.txt tr_events.phpadm.triggerdisplayoptions.php chart6.php hostinventoriesoverview.php js screenconf.php trigger_prototypes.phpadm.triggerseverities.php chart7.php hostinventories.php jsLoader.php screenedit.php triggers.phpadm.valuemapping.php chart.php host_prototypes.php jsrpc.php screen.import.php usergrps.phpadm.workingtime.php charts.php host_screen.php latest.php screens.php users.phpapi_jsonrpc.php conf hosts.php local services.php zabbix.phpapp conf.import.php httpconf.php locale setup.phpapplications.php correlation.php httpdetails.php maintenance.php slideconf.php[root@localhost zabbix]#[root@localhost zabbix]# mv setup.php setup.php.bak[root@localhost zabbix]#
設(shè)置新的密碼,界面的主題、語言和登陸后顯示的默認(rèn)界面等

解決中文亂碼無法顯示的問題

Windows字體目錄地址
C:\Windows\Fonts
復(fù)制到zabbix服務(wù)器中

查找Zabbix所使用的語言包
find / -name font -print | grep zabbix
ll find / -name *font* -print | grep zabbix
[root@localhost ~]# find / -name *font* -print | grep zabbix/etc/alternatives/zabbix-web-font/var/lib/alternatives/zabbix-web-font/usr/share/zabbix/fonts/usr/share/zabbix/fonts/graphfont.ttf[root@localhost ~]#[root@localhost ~]# ll `find / -name *font* -print | grep zabbix`lrwxrwxrwx. 1 root root 38 Apr 4 14:43 /etc/alternatives/zabbix-web-font -> /usr/share/fonts/dejavu/DejaVuSans.ttflrwxrwxrwx. 1 root root 33 Apr 4 14:43 /usr/share/zabbix/fonts/graphfont.ttf -> /etc/alternatives/zabbix-web-font-rw-r--r--. 1 root root 86 Apr 4 14:43 /var/lib/alternatives/zabbix-web-font /usr/share/zabbix/fonts:total 0lrwxrwxrwx. 1 root root 33 Apr 4 14:43 graphfont.ttf -> /etc/alternatives/zabbix-web-font[root@localhost ~]#
備份本身語言包
mv /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak
替換成Windows的語言包
mv simkai.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf
[root@localhost ~]# mv /usr/share/fonts/dejavu/DejaVuSans.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf.bak[root@localhost ~]#[root@localhost ~]# lsanaconda-ks.cfg simkai.ttf[root@localhost ~]#[root@localhost ~]# mv simkai.ttf /usr/share/fonts/dejavu/DejaVuSans.ttf[root@localhost ~]#
刷新頁面已經(jīng)恢復(fù)

參考博客:
https://www.cnblogs.com/Sungeek/p/9069999.html
http://www.cnblogs.com/xiewenming/p/7732144.html
zabbix4.2學(xué)習(xí)請參考這位博主
https://www.cnblogs.com/AutoSmart/p/10505090.html