如何在centos7上安裝zabbix

来源:http://www.cnblogs.com/chaochao520/archive/2016/09/22/5895618.html
-Advertisement-
Play Games

How To Install Zabbix Server On CentOS 7 By SK How To Install Zabbix Server On CentOS 7 By SK By SK Share on Facebook Tweet on Twitter Share on Facebo ...


How To Install Zabbix Server On CentOS 7

By SK Share on Facebook   Tweet on Twitter   

About Zabbix

Zabbix is an enterprise-class open source distributed monitoring solution that can be used to monitor and track performance and availability of network servers, devices and other IT resources. It supports distributed and WEB monitoring, auto-discovery, and more.

Install Zabbix Server

I tested this how-to On CentOS 7 minimal server, although it should work on other RHEL/Scientific Linux 7.x versions.

 

 

For the testing purpose, I will use two machines.

Zabbix Server System:

  • Operating system: CentOS 7 64bit server
  • IP Address: 192.168.1.150/24
  • Hostname: server1.unixmen.local

Zabbix Client System:

  • Operating system: CentOS 7 64bit server
  • IP Address: 192.168.1.152/24
  • Hostname: server2.unixmen.local

First let us start from server side.

 

Prerequisites

Before installing Zabbix, we should have install and configure LAMP stack.

To install and configure LAMP server On CentOS 7, refer the following link.

Server Side Configuration

Zabbix is not available in the default repositories of CentOS. So, we will add EPEL and Zabbix official repository in order to install Zabbix server.

To install EPEL repository, run the following command:

yum install epel-release

Configure the ZabbixZone package repository and GPG key using command:

rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
rpm -Uv  http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm

Now, Install Zabbix server and agent using command:

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway

Edit file /etc/httpd/conf.d/zabbix:

vi /etc/httpd/conf.d/zabbix.conf

Update your timezone:

php_value date.timezone Asia/Kolkata

Restart the httpd

systemctl restart httpd

Create MySQL database and user for Zabbix

Login to MariaDB prompt with command:

mysql -u root -p

Create a database called ‘zabbixdb’ and database user called ‘zabbixuser’.

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbixdb character set utf8;
Query OK, 1 row affected (0.05 sec)

MariaDB [(none)]> grant all privileges on zabbixdb.* to 'zabbixuser'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.21 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye

Import zabbix templates to Zabbix database

Let us import the following templates. It will ask you the zabbixuser’s password during importing templates.

mysql -u zabbixuser -p zabbixdb < /usr/share/doc/zabbix-server-mysql-2.4.5/create/schema.sql
mysql -u zabbixuser -p zabbixdb < /usr/share/doc/zabbix-server-mysql-2.4.5/create/images.sql
mysql -u zabbixuser -p zabbixdb < /usr/share/doc/zabbix-server-mysql-2.4.5/create/data.sql

Configure Zabbix server

Edit file /etc/zabbix/zabbix_server.conf,

vi /etc/zabbix/zabbix_server.conf

Set the database name, user and password which you’ve created earlier. If the lines are commented out, uncomment and set the correct values.

[...]
DBName=zabbixdb
[...]
DBUser=zabbixuser
[...]
DBPassword=password
[...]

Save and close the file.

Now, we have to set Zabbix server to monitor itself.

To do that, edit file /etc/zabbix/zabbix_agentd.conf,

vi /etc/zabbix/zabbix_agentd.conf

Do the following changes.

[...]

## Line 85 - Specify Zabbix server ##
Server=127.0.0.1

[...]

## Line 126 - Specify Zabbix server ##
ServerActive=127.0.0.1

[...]

## Line 137 - Specify Zabbix server Hostname or IP address ##
Hostname=server1.unixmen.local
[...]

Save and close the file.

Adjust PHP settings

We should adjust phip.ini file as per zabbix recommended settings.

Edit file php.ini,

vi /etc/php.ini

Set the values as shown below. If the lines doesn’t exist, add them.

max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Kolkata

Save and close the file.

Adjust Firewall and SELinux settings               #此處需要在防火牆開啟的狀態中操作,systemctl start firewalld.service 如果防火牆無法開啟,並提示沒有命令,so,yum install -y firewalld   然後再開啟防火牆,並使用開啟埠命令。

Adjust iptables to allow the zabbix ports 10050 and 10051.                    

firewall-cmd --permanent --add-port=10050/tcp,
firewall-cmd --permanent --add-port=10051/tcp

Restart iptables service to take effect the changes.

systemctl restart firewalld

If you use SELinux, run the following command to allow Apache to communicate with Zabbix.

setsebool -P httpd_can_connect_zabbix=1

Allow Zabbix web console for particular IP range (Optional)

Edit file /etc/httpd/conf.d/zabbix.conf,

vi /etc/httpd/conf.d/zabbix.conf

Add the ip range that you want to allow to access zabbix web interface. This is optional. If you set ‘Allow from All’, you can access zabbix’s web console from any network.

In my case, I allowed the 192.168.1.0/24 series.

Alias /zabbix /usr/share/zabbix

<Directory "/usr/share/zabbix">
 Options FollowSymLinks
 AllowOverride None
 Order allow,deny
 Allow from 192.168.1.0/24
</Directory>

Save and close the file. Start/Restart zabbix and httpd services and make them to start automatically on every reboot.

systemctl start zabbix-server
systemctl start zabbix-agent
systemctl restart httpd
systemctl restart mariadb
systemctl enable zabbix-server
systemctl enable zabbix-agent

Configure Zabbix via Web console

We have completed the installation and configuration part. Now let us configure the zabbix web console.

Navigate tohttp://ip-address/zabbix or http://domain-name/zabbix.

Click Next.

Installation - Google Chrome_001

The installer will check for necessary prerequisites. If everything seems OK, click Next to continue, else go back and install the necessary packages.

Installation - Google Chrome_002

Enter the zabbix database name, database user and password and click Test connection. If you entered the correct values, it will show a message that says: OK.

Click Next to continue.

Installation - Google Chrome_004

Enter your server name and Click Next:

Installation - Google Chrome_005

Check the pre-installation summary, if everything good, click Next to continue or click Previous to change the parameters.

Installation - Google Chrome_006

Congratulations! You’ve have successfully completed the installation. Click Finish to complete the installation.

Installation - Google Chrome_007

Now you’ll be redirected to the zabbix web console page. Enter the username and password.

The default username/password is admin/zabbix.

Zabbix - Google Chrome_008

This is how the admin dashboard looks:

Unixmen Monitoring Server: Dashboard - Google Chrome_001

Activate Zabbix server

Initially, the zabbix server is deactivated from being monitored.

To activate it, go to Configuration -> Hosts. Select the host (zabbix server) and chooseActivate selected from the drop-down box and click Go.

Unixmen Monitoring Server: Configuration of hosts - Google Chrome_010

Now, you should see your Zabbix server is being monitored.

Unixmen Monitoring Server: Configuration of hosts - Google Chrome_011

Check Zabbix server Statistics

After a few seconds, click on the Monitoring tab on the top menu bar and select “Latest data”.

You’ll see the zabbix server’s details:

Unixmen Monitoring Server: Latest data [refreshed every 30 sec.] - Google Chrome_002

To view the screens, go to Monitoring -> Screens from the Zabbix’s dashboard.

Unixmen Monitoring Server: Custom screens [refreshed every 30 sec.] - Google Chrome_003

That’s it. We’re done in the server side. Let us go to client side configuration.

Client Side Configuration

Let us install zabbix agent on our client systems.

To install zabbix agent packages on Fedora/RHEL clients, enter the following commands in Terminal:

rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
rpm -Uv  http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
yum install zabbix-agent -y

On Ubuntu/Debian clients, run:

sudo apt-get install zabbix-agent

Configure Clients

Next edit file /etc/zabbix/zabbix_agentd.conf,

sudo vi /etc/zabbix/zabbix_agentd.conf

Add the server ip address and client hostname.

[...]
## Specify Zabbix's server IP address ##
Server=192.168.1.150
[...]
##Specify Zabbix's server IP address ##
ServerActive=192.168.1.150
## Specify client system hostname ##
Hostname=server2.unixmen.local
[...]

Where,

  • 192.168.1.150 – My Zabbix server IP address
  • server2 – My Zabbix client’s hostname

Now restart zabbix-agent service with command:

In Ubuntu/Debian:

sudo service zabbix-agent start

In CentOS 7:

systemctl start zabbix-agent
systemctl enable zabbix-agent

Add Monitoring hosts

Go to your zabbix server dashboard.

To add a monitoring target, navigate to Configuration -> Hosts. Click on Create Host on the right side.

Unixmen Monitoring Server: Configuration of hosts - Google Chrome_004

Enter Hostname, select Groups and IP address in the Host section as shown below.

Unixmen Monitoring Server: Configuration of hosts - Google Chrome_006

Next, In the Templates section select your Template.

Unixmen Monitoring Server: Configuration of hosts - Google Chrome_008

In my case, I selected Linux Template and SSH template. After selecting your Template choice click Select button in the bottom.

Unixmen Monitoring Server: Templates - Google Chrome_010

In the next window, click Add and click Update buttons.

Unixmen Monitoring Server: Configuration of hosts - Google Chrome_011

Now, you will see that the new host has been added to the Monitoring list.

Unixmen Monitoring Server: Configuration of hosts - Google Chrome_001

That’s it.

If there is any problem in the Client system, you can view them in the main Dashboard of your Zabbix’s server.

Unixmen Monitoring Server: Dashboard - Google Chrome_013

Go to Monitoring -> Latest data to check the details of client.

Unixmen Monitoring Server: Latest data [refreshed every 30 sec.] - Google Chrome_002

You can view the list of all warnings and information in Monitoring -> Triggers location.

Unixmen Monitoring Server: Status of triggers [refreshed every 30 sec.] - Google Chrome_003

Conclusion

In this tutorial, we have covered only installation part and basic configuration of Zabbix. To learn more about Zabbix, explore all the options in the Zabbix’s dashboard one by one and set up a best monitoring solution that suits your requirement.

For more details about configuration and usage, refer Zabbix Official manual.

Good luck.

 

If you want to deploy Zabbix in CentOS 6.x systems, refer the following link.

Reference Links:

 

菜鳥實際測試可用,成功搭建的zabbix伺服器。原文:https://www.unixmen.com/how-to-install-zabbix-server-on-centos-7/      作者很強大!!!!贊!


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 之前是Windows 10版本1607版本14393.102升級14393.187過後,突然出現不能撥公司防火牆的L2TPVPN了。 網上眾說紛紜,原來遇到這個問題的人真不少,不過我是第一次遇到。結合網上一些分析過後,我電腦的解決方式是: 錯誤描述:當連接VPN是回傳錯誤為“ L2TP連接嘗試失敗, ...
  • GPIO 即通用輸入輸出口。凡事都要熟悉,熟能生巧。一定要掌握MDK軟體的工程操作方法。 對於GPIO的操作。 Project裡面要有以下幾個文件夾(開發之前需要包含相應的庫文件,這裡預設已經包含) STEP BY STEP(以按鍵和LED燈為例): 1.在USER文件夾里新建對應功能的C文件和H文 ...
  • 今天將mac os升級到了10.12,但是第一次關機就一直停著不動,只能強制關機(按電源鍵). 在網上查了下,這是mysql的一個bug. 進入到系統偏好設置中,點擊MySql,取消Automatically start mysql server on startup. ...
  • 1、單次轉換模式 通過配置“模式寄存器的MD2、MD1、MD0為001”,便可啟動單次轉換。 流程“上電 -》 單次轉換 -》 省電模式 ” , 片內振蕩上電需要大約1ms。 單次轉換的時序圖: 數字的含義:0x08 :表示後面的數字是用來設置mode register的; 0x280060:用來設 ...
  • linux free命令查看記憶體使用情況 導讀:linux free命令查看記憶體使用情況,free命令輸出結果的各選項的含義,以及free結果中buffer與cache的區別。 linux free命令查看記憶體使用情況free命令查看記憶體使用: 複製代碼代碼如下: [root@prdmis-db / ...
  • 修改setting.py http://www.cnblogs.com/fengri/articles/django5.html http://unun.in/python/216.html ...
  • 腳本原子化設計理念 運維的目標:運維當中重覆著大量相同相似的工作,機器規模數量一上來,則需要考慮自動化運維,儘量做到第一次人工處理,後面都依賴腳本或者工具和WEB化來完成。這樣編寫shell、python腳本變得非常重要,不僅可以替代很多重覆工作,而且提高效率和減少人工失誤率,我建議即使公司只有10 ...
  • win7下安裝個linux虛擬機,學習下非常好。 但是每次使用linux的時候,都是打開virtualBox-->啟動安裝的linux系統-->再用遠程桌面(SSH等)連接 每次手動打開比較麻煩,而且linux虛擬機也有視窗,比較冗雜。如果能開機自啟,並且後臺運行linux虛擬機(沒有可見視窗),那 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...