CentOS7下快速安裝Zabbix

目錄

1 簡介

2 快速安裝

- 簡介

Zabbix提供了All in One的解決方案,使用它我們能快速構建企業(yè)及的監(jiān)控平臺,讓運維工作變得可知可控。在開源監(jiān)控領域,還有其他的一些解決方案,比如流量監(jiān)控方面的有MRTG,Cacti,Smokingping等,性能告警方面有Nagios,Zabbix,OpenTSDB等。每種軟件各有自己的特點和功能。
Zabbix是一個分布式監(jiān)控系統(tǒng),支持多種采集方式和采集客戶端,有自己的Agent,支持SNMP、IPMI、JMX、Telnet、SSH等協(xié)議,后臺存儲支持MySQL,Oracle,PostgreSQL。
Zabbix Agent采用c語言編寫,對系統(tǒng)資源占用小,采集性能高。

- 快速安裝

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

因為我已經安裝完成了。所以這里顯示都是已經安裝,為了讀者對比命令的運行結果。

下一步創(chuàng)建數據庫,配置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

配置時區(qū)

[root@VM_0_3_centos ~]# egrep -v '^#|^$'   /etc/httpd/conf.d/zabbix.conf
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>

啟動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管理界面
image.png
  • 進入管理界面


    image.png

-修改下語言成中文


image.png

OK,系統(tǒng)安裝基本就位。

?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

  • Zabbix簡介 Zabbix官方網站Zabbix中文文檔 本文系統(tǒng)環(huán)境是CentOS7x86_64, Zabbi...
    Zhang21閱讀 8,331評論 0 37
  • 1.寫在前面 本文主要介紹的是zabbix的編譯安裝過程,包含它的基礎環(huán)境LNMP,雖然zabbix官方一般推薦的...
    天之藍色閱讀 2,663評論 0 16
  • 監(jiān)控的意義 監(jiān)控是整個運維乃至整個產品生命周期中最重要的一環(huán),事前及時預警發(fā)現故障,事后提供詳實的數據用于追查定位...
    像飛翔一樣去飛翔閱讀 902評論 0 2
  • 本文為冰與火之歌第八季網傳泄露版英文劇本,個人認為比上線版本好多了,原文在pastebin.com,由于排版原因,...
    張知卓見閱讀 714評論 0 1
  • “那個袁曉華,”李華說,“我聽說他比完賽突然就離開了長風,可他比賽不是拿了第一名么,按理說他在長風大有前途啊,他為...
    梅綻雪閱讀 1,333評論 37 53

友情鏈接更多精彩內容