Zabbix 4.0 LTS 安装
官方手册:
https://www.zabbix.com/documentation/4.0/zh/manual/installation/install_from_packages/rhel_centos
Docker版本:
https://github.com/zabbix/zabbix-docker
https://www.zabbix.com/documentation/current/manual/installation/containers
https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/
查找 zabbix-release-4.0-1.el7.noarch.rpm
安装国内源
[root@zabbix ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
Retrieving https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.DBMI89: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing… ################################# [100%]
Updating / installing…
1:zabbix-release-4.0-1.el7 ################################# [100%]
[root@zabbix ~]# rpm -ql zabbix-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release-4.0
/usr/share/doc/zabbix-release-4.0/GPL
[root@zabbix ~]#
查看repo源
[root@zabbix ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
[root@zabbix ~]#
手动修改为国内源:
vim修改
:%s#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g
sed -i ‘s#http://repo.zabbix.com#https://mirrors.tuna.tsinghua.edu.cn/zabbix#g’ /etc/yum.repos.d/zabbix.repo
[root@zabbix ~]# vim /etc/yum.repos.d/zabbix.repo
[root@zabbix ~]# cat /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
[root@zabbix ~]#
yum install zabbix-server-mysql zabbix-web-mysql -y
安装包与依赖包:
Installed:
zabbix-server-mysql.x86_64 0:4.0.16-1.el7 zabbix-web-mysql.noarch 0:4.0.16-1.el7
Dependency Installed:
OpenIPMI.x86_64 0:2.0.27-1.el7
OpenIPMI-libs.x86_64 0:2.0.27-1.el7
OpenIPMI-modalias.x86_64 0:2.0.27-1.el7
fping.x86_64 0:3.10-1.el7
httpd.x86_64 0:2.4.6-90.el7.centos
httpd-tools.x86_64 0:2.4.6-90.el7.centos
iksemel.x86_64 0:1.4-2.el7.centos
libzip.x86_64 0:0.10.1-8.el7
mailcap.noarch 0:2.1.41-2.el7
php.x86_64 0:5.4.16-46.1.el7_7
php-bcmath.x86_64 0:5.4.16-46.1.el7_7
php-cli.x86_64 0:5.4.16-46.1.el7_7
php-common.x86_64 0:5.4.16-46.1.el7_7
php-gd.x86_64 0:5.4.16-46.1.el7_7
php-ldap.x86_64 0:5.4.16-46.1.el7_7
php-mbstring.x86_64 0:5.4.16-46.1.el7_7
php-mysql.x86_64 0:5.4.16-46.1.el7_7
php-pdo.x86_64 0:5.4.16-46.1.el7_7
php-xml.x86_64 0:5.4.16-46.1.el7_7
t1lib.x86_64 0:5.1.2-14.el7
unixODBC.x86_64 0:2.3.1-14.el7
zabbix-web.noarch 0:4.0.16-1.el7
安装数据库
官方手册:
https://www.zabbix.com/documentation/4.0/manual/appendix/install/db_scripts#mysql
yum install mariadb-server -y
启动数据库:
[root@zabbix ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbix ~]# systemctl restart mariadb.service
数据库初始化:
mysql_secure_installation
[root@zabbix ~]# 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
you 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 MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password:
Re-enter new password:
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]
… 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]
… Success!
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]
- 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]
… 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!
[root@zabbix ~]#
配置数据库
shell> mysql -uroot -p
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘password’;
mysql> quit;
[root@zabbix ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
MariaDB [(none)]>
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by ‘ ‘;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> \q
Bye
[root@zabbix ~]#
导入数据:
导入zabbix表结构数据
使用 MySQL 来导入 Zabbix server 的初始数据库 schema 和数据,
# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
[root@zabbix ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 5.5.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
MariaDB [(none)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zabbix]> show tables;
+——————————————+
| Tables_in_zabbix |
+——————————————+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| items |
| items_applications |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_remote_command |
| task_remote_command_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+——————————————+
144 rows in set (0.00 sec)
MariaDB [zabbix]> \q;
Bye
[root@zabbix ~]#
zabbix server 配置:
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=
[root@zabbix ~]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@zabbix ~]# systemctl restart zabbix-server.service
[root@zabbix ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0: LISTEN 1/systemd
tcp 0 0 192.168.122.1:53 0.0.0.0: LISTEN 1478/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 1093/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0: LISTEN 1095/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0: LISTEN 1364/master
tcp 0 0 127.0.0.1:6010 0.0.0.0: LISTEN 3207/sshd: root@pts
tcp 0 0 0.0.0.0:10051 0.0.0.0: LISTEN 6894/zabbix_server
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 6222/mysqld
tcp6 0 0 :::111 ::: LISTEN 1/systemd
tcp6 0 0 :::22 ::: LISTEN 1093/sshd
tcp6 0 0 ::1:631 ::: LISTEN 1095/cupsd
tcp6 0 0 ::1:25 ::: LISTEN 1364/master
tcp6 0 0 ::1:6010 ::: LISTEN 3207/sshd: root@pts
tcp6 0 0 :::10051 ::: LISTEN 6894/zabbix_server
[root@zabbix ~]#
前端配置:
官方手册:
https://www.zabbix.com/documentation/4.0/manual/installation/install#installing_frontend
vim /etc/httpd/conf.d/zabbix.conf
修改时区:
<IfModule mod_php5.c><br /> php_value max_execution_time 300<br /> php_value memory_limit 128M<br /> php_value post_max_size 16M<br /> php_value upload_max_filesize 2M<br /> php_value max_input_time 300<br /> php_value max_input_vars 10000<br /> php_value always_populate_raw_post_data -1<br /> php_value date.timezone Asia/Shanghai<br /> </IfModule>
sed -i ‘s@# php_value date.timezone Europe/Riga@php_value date.timezone Asia/Shanghai@g’ /etc/httpd/conf.d/zabbix.conf
nginx +fastcgi +php lnmp
http + php.so + php lamp
[root@zabbix ~]# vim /etc/httpd/conf.d/zabbix.conf
[root@zabbix ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@zabbix ~]# systemctl restart httpd.service
浏览器配置界面:
http://192.168.31.60/zabbix/setup.php
Zabbix frontend is ready! The default user name is Admin, password zabbix.
Zabbix-agent部署
Linux:
https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/
rehl6:
[root@riyimei ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/6/x86_64/zabbix-agent-4.0.9-3.el6.x86_64.rpm
Retrieving https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/6/x86_64/zabbix-agent-4.0.9-3.el6.x86_64.rpm
warning: /var/tmp/rpm-tmp.BBsWF1: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing… ########################################### [100%]
1:zabbix-agent ########################################### [100%]
[root@riyimei ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@riyimei ~]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent: [ OK ]
Starting Zabbix agent: [ OK ]
[root@riyimei ~]# chkconfig zabbix-agent on
[root@riyimei ~]# chkconfig —list |grep zabbix-agent
zabbix-agent 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@riyimei ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:10050 0.0.0.0: LISTEN 8071/zabbix_agentd
tcp 0 0 0.0.0.0:111 0.0.0.0: LISTEN 1429/rpcbind
tcp 0 0 0.0.0.0:49265 0.0.0.0: LISTEN 1451/rpc.statd
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 6089/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0: LISTEN 1507/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0: LISTEN 6170/master
tcp 0 0 :::10050 ::: LISTEN 8071/zabbix_agentd
tcp 0 0 :::54855 ::: LISTEN 1451/rpc.statd
tcp 0 0 :::111 ::: LISTEN 1429/rpcbind
tcp 0 0 :::22 ::: LISTEN 6089/sshd
tcp 0 0 ::1:631 ::: LISTEN 1507/cupsd
tcp 0 0 ::1:25 ::: LISTEN 6170/master
rehl7
[root@zabbix ~]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.9-3.el7.x86_64.rpm
[root@zabbix ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.9-3.el7.x86_64.rpm
Retrieving https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.9-3.el7.x86_64.rpm
Preparing… ################################# [100%]
Updating / installing…
1:zabbix-agent-4.0.9-3.el7 ################################# [100%]
[root@zabbix ~]#
[root@zabbix ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@zabbix ~]# 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@zabbix ~]# systemctl restart zabbix-agent.service
[root@zabbix ~]#
systemctl stop firewalld && setenforce 0 &&\
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.centos.noarch.rpm &&\
yum install zabbix-server zabbix-web zabbix-server-mysql zabbix-web-mysql mariadb-server mariadb zabbix-agent -y &&\
sed -i ‘s@# php_value date.timezone Europe/Riga@php_value date.timezone Asia/Shanghai@g‘ /etc/httpd/conf.d/zabbix.conf &&\
systemctl start mariadb &&\
mysql
create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@‘localhost‘ identified by ‘123456‘;
exit
cd /usr/share/doc/zabbix-server-mysql-3.4.7/ &&\
zcat create.sql.gz|mysql -uzabbix -p123456 zabbix &&\
sed -i ‘s@# DBHost=localhost@DBHost=localhost@g‘ /etc/zabbix/zabbix_server.conf &&\
sed -i ‘s@# DBPassword=@DBPassword=123456@g‘ /etc/zabbix/zabbix_server.conf &&\
systemctl start zabbix-server &&\
systemctl start httpd
添加配置主机:
Zabbix 介绍:
zabbix历史
Zabbix 架构:
Zabbix 概述
架构
Zabbix 由几个主要的功能组件组成,其功能介绍如下所示。
Server
Zabbix server 是 Zabbix软件的核心组件,agent 向其报告可用性、系统完整性信息和统计信息。server也是存储所有配置信息、统计信息和操作信息的核心存储库。
数据库
所有配置信息以及 Zabbix 采集到的数据都被存储在数据库中。
Web 界面
为了从任何地方和任何平台轻松访问 Zabbix ,我们提供了基于 web 的界面。该界面是 Zabbix server 的一部分,通常(但不一定)和 Zabbix server 运行在同一台物理机器上。
Proxy
Zabbix proxy 可以代替 Zabbix server采集性能和可用性数据。Zabbix proxy在Zabbix的部署是可选部分;但是proxy的部署可以很好的分担单个Zabbix server的负载。
Agent
Zabbix agents 部署在被监控目标上,用于主动监控本地资源和应用程序,并将收集的数据发送给 Zabbix server。