目录
1 简介
2 快速安装
- 简介
Zabbix提供了All in One的解决方案,使用它我们能快速构建企业及的监控平台,让运维工作变得可知可控。在开源监控领域,还有其他的一些解决方案,比如流量监控方面的有MRTG,Cacti,Smokingping等,性能告警方面有Nagios,Zabbix,OpenTSDB等。每种软件各有自己的特点和功能。
Zabbix是一个分布式监控系统,支持多种采集方式和采集客户端,有自己的Agent,支持SNMP、IPMI、JMX、Telnet、SSH等协议,后台存储支持MySQL,Oracle,PostgreSQL。
Zabbix Agent采用c语言编写,对系统资源占用小,采集性能高。
- 快速安装
OS: CentOS 7.2
MySQL:MariaDB 5.5
Zabbix:3.0 LTS
1 安装前准备
- 安装MySQL
[root@VM_0_3_centos ~]# yum install mariadb-server
Loaded plugins: fastestmirror, langpacks
epel | 5.3 kB 00:00:00
extras | 3.4 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 3.4 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
(1/2): epel/7/x86_64/updateinfo | 977 kB 00:00:00
(2/2): epel/7/x86_64/primary_db | 6.8 MB 00:00:01
Loading mirror speeds from cached hostfile
Package 1:mariadb-server-5.5.60-1.el7_5.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]# yum install mariadb
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package 1:mariadb-5.5.60-1.el7_5.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]#
安装完成后,我们看看版本。
[root@VM_0_3_centos ~]# mysqladmin version -u root -p
Enter password:
mysqladmin Ver 9.0 Distrib 5.5.60-MariaDB, for Linux on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Server version 5.5.60-MariaDB
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 15 hours 7 min 50 sec
Threads: 8 Questions: 110128 Slow queries: 0 Opens: 570 Flush tables: 2 Open tables: 110 Queries per second avg: 2.021
- 安装其他组件
安装IPMI
[root@VM_0_3_centos ~]# yum install OpenIPMI
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package OpenIPMI-2.0.23-2.el7.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]#
安装ssh2
[root@VM_0_3_centos ~]# yum install libssh2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package libssh2-1.4.3-12.el7_6.2.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]#
安装fping
[root@VM_0_3_centos ~]# yum install fping
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package fping-3.10-4.el7.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]#
安装libcurl
[root@VM_0_3_centos ~]# yum install libcurl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package libcurl-7.29.0-51.el7.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]#
安装 iksemel
[root@VM_0_3_centos ~]# yum install iksemel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package iksemel-1.4-2.el7.centos.x86_64 already installed and latest version
Nothing to do
安装net-snmp
[root@VM_0_3_centos ~]# yum install net-snmp
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package 1:net-snmp-5.7.2-37.el7.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]#
安装 libtool-ltdl
[root@VM_0_3_centos ~]# yum install libtool-ltdl
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package libtool-ltdl-2.4.2-22.el7_3.x86_64 already installed and latest version
Nothing to do
[root@VM_0_3_centos ~]#
安装ODBC
[root@VM_0_3_centos ~]# yum install unixODBC
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package unixODBC-2.3.1-11.el7.x86_64 already installed and latest version
Nothing to do
- 安装zabbix
安装zabbix repo
[root@VM_0_3_centos ~]# rpm -Uvh https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
Preparing... ################################# [100%]
package zabbix-release-3.0-1.el7.noarch is already installed
[root@VM_0_3_centos ~]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: epel extras os updates zabbix zabbix-non-supported
Cleaning up everything
Cleaning up list of fastest mirrors
安装zabbix
[root@VM_0_3_centos ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
Loaded plugins: fastestmirror, langpacks
epel | 5.3 kB 00:00:00
extras | 3.4 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 3.4 kB 00:00:00
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 951 B 00:00:00
(1/8): epel/7/x86_64/group_gz | 88 kB 00:00:00
(2/8): os/7/x86_64/group_gz | 166 kB 00:00:00
(3/8): epel/7/x86_64/updateinfo | 977 kB 00:00:00
(4/8): extras/7/x86_64/primary_db | 205 kB 00:00:00
(5/8): os/7/x86_64/primary_db | 6.0 MB 00:00:01
(6/8): epel/7/x86_64/primary_db | 6.8 MB 00:00:01
(7/8): updates/7/x86_64/primary_db | 6.4 MB 00:00:01
(8/8): zabbix/x86_64/primary_db | 183 kB 00:00:07
zabbix-non-supported/x86_64/primary | 1.6 kB 00:00:00
Determining fastest mirrors
zabbix-non-supported 4/4
Package zabbix-server-mysql-3.0.28-1.el7.x86_64 already installed and latest version
Package zabbix-web-mysql-3.0.28-1.el7.noarch already installed and latest version
Package zabbix-agent-3.0.28-1.el7.x86_64 already installed and latest version
Nothing to do
因为我已经安装完成了。所以这里显示都是已经安装,为了读者对比命令的运行结果。
下一步创建数据库,配置zabbix用户,初始化数据表内容。
[root@VM_0_3_centos ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 1438
Server version: 5.5.60-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)]> create database zabbix character set utf8 collate utf8_bin;
ERROR 1007 (HY000): Can't create database 'zabbix'; database exists
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'newpasswd';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> quit
Bye
[root@VM_0_3_centos ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
修改配置文件,必须将配置数据库密码
[root@VM_0_3_centos ~]# egrep -v '^#|^$' /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=password
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
配置时区
[root@VM_0_3_centos ~]# egrep -v '^#|^$' /etc/httpd/conf.d/zabbix.conf
Alias /zabbix /usr/share/zabbix
Options FollowSymLinks
AllowOverride None
Require all granted
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
Require all denied
Require all denied
Require all denied
Require all denied
启动zabbix。
[root@VM_0_3_centos ~]# systemctl enable zabbix-server zabbix-agent httpd
[root@VM_0_3_centos ~]# systemctl start zabbix-server zabbix-agent httpd
[root@VM_0_3_centos ~]# systemctl status zabbix-server zabbix-agent httpd
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2019-06-29 16:57:48 CST; 6s ago
Process: 7092 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 7097 (zabbix_server)
CGroup: /system.slice/zabbix-server.service
├─7097 /usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf
├─7108 /usr/sbin/zabbix_server: configuration syncer [waiting 60 sec for processes]
├─7109 /usr/sbin/zabbix_server: db watchdog [synced alerts config in 0.029769 sec, idle 60 sec]
├─7110 /usr/sbin/zabbix_server: poller #1 [got 0 values in 0.000005 sec, idle 5 sec]
├─7111 /usr/sbin/zabbix_server: poller #2 [got 0 values in 0.000004 sec, idle 5 sec]
├─7112 /usr/sbin/zabbix_server: poller #3 [got 0 values in 0.000003 sec, idle 5 sec]
├─7113 /usr/sbin/zabbix_server: poller #4 [got 0 values in 0.000003 sec, idle 5 sec]
├─7114 /usr/sbin/zabbix_server: poller #5 [got 0 values in 0.000003 sec, idle 5 sec]
├─7115 /usr/sbin/zabbix_server: unreachable poller #1 [got 0 values in 0.000008 sec, idle 5 sec]
├─7116 /usr/sbin/zabbix_server: trapper #1 [processed data in 0.000000 sec, waiting for connection]
├─7117 /usr/sbin/zabbix_server: trapper #2 [processed data in 0.000000 sec, waiting for connection]
├─7118 /usr/sbin/zabbix_server: trapper #3 [processed data in 0.000000 sec, waiting for connection]
├─7119 /usr/sbin/zabbix_server: trapper #4 [processed data in 0.000000 sec, waiting for connection]
├─7120 /usr/sbin/zabbix_server: trapper #5 [processed data in 0.000000 sec, waiting for connection]
├─7121 /usr/sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000004 sec, idle 5 sec]
├─7122 /usr/sbin/zabbix_server: alerter [sent alerts: 0 success, 0 fail in 0.002245 sec, idle 30 sec]
├─7123 /usr/sbin/zabbix_server: housekeeper [startup idle for 30 minutes]
├─7124 /usr/sbin/zabbix_server: timer #1 [processed 0 triggers, 0 events in 0.000000 sec, 0 maintenances in 0.000000 sec,...
├─7125 /usr/sbin/zabbix_server: http poller #1 [got 0 values in 0.000468 sec, idle 5 sec]
├─7126 /usr/sbin/zabbix_server: discoverer #1 [processed 0 rules in 0.000508 sec, idle 60 sec]
├─7127 /usr/sbin/zabbix_server: history syncer #1 [synced 0 items in 0.000001 sec, idle 1 sec]
├─7128 /usr/sbin/zabbix_server: history syncer #2 [synced 0 items in 0.000002 sec, idle 1 sec]
├─7129 /usr/sbin/zabbix_server: history syncer #3 [synced 0 items in 0.000001 sec, idle 1 sec]
├─7130 /usr/sbin/zabbix_server: history syncer #4 [synced 0 items in 0.000001 sec, idle 1 sec]
├─7131 /usr/sbin/zabbix_server: escalator #1 [processed 0 escalations in 0.000583 sec, idle 3 sec]
├─7132 /usr/sbin/zabbix_server: proxy poller #1 [exchanged data with 0 proxies in 0.000002 sec, idle 5 sec]
└─7133 /usr/sbin/zabbix_server: self-monitoring [processed data in 0.000006 sec, idle 1 sec]
Jun 29 16:57:48 VM_0_3_centos systemd[1]: Starting Zabbix Server...
Jun 29 16:57:48 VM_0_3_centos systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start.
Jun 29 16:57:48 VM_0_3_centos systemd[1]: Started Zabbix Server.
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2019-06-29 16:57:48 CST; 6s ago
Process: 7093 ExecStart=/usr/sbin/zabbix_agentd -c $CONFFILE (code=exited, status=0/SUCCESS)
Main PID: 7098 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─7098 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─7100 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─7101 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─7102 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─7103 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
└─7104 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
Jun 29 16:57:48 VM_0_3_centos systemd[1]: Starting Zabbix Agent...
Jun 29 16:57:48 VM_0_3_centos systemd[1]: PID file /run/zabbix/zabbix_agentd.pid not readable (yet?) after start.
Jun 29 16:57:48 VM_0_3_centos systemd[1]: Started Zabbix Agent.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2019-06-29 16:57:49 CST; 5s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 7094 (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─7094 /usr/sbin/httpd -DFOREGROUND
├─7157 /usr/sbin/httpd -DFOREGROUND
├─7158 /usr/sbin/httpd -DFOREGROUND
├─7159 /usr/sbin/httpd -DFOREGROUND
├─7160 /usr/sbin/httpd -DFOREGROUND
└─7161 /usr/sbin/httpd -DFOREGROUND
Jun 29 16:57:48 VM_0_3_centos systemd[1]: Starting The Apache HTTP Server...
Jun 29 16:57:48 VM_0_3_centos httpd[7094]: AH00558: httpd: Could not reliably determine the server's fully qualified domain n...message
Jun 29 16:57:49 VM_0_3_centos systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@VM_0_3_centos ~]#
- 登录web管理界面
-
进入管理界面
-修改下语言成中文
OK,系统安装基本就位。