來自公眾號(hào):馬哥Linux運(yùn)維
作者于培智
Zabbix介紹:
Zabbix是一個(gè)基于Web界面提供分布式系統(tǒng)監(jiān)視及網(wǎng)絡(luò)監(jiān)視功能的企業(yè)級(jí)開源解決方案。它能監(jiān)視各種網(wǎng)絡(luò)參數(shù),保證服務(wù)器系統(tǒng)的安全運(yùn)營,并提供靈活的通知機(jī)制以讓系統(tǒng)管理員快速定位/解決存在的各種問題;借助Zabbix可很輕松地減輕運(yùn)維人員們繁重的服務(wù)器管理任務(wù),實(shí)現(xiàn)業(yè)務(wù)系統(tǒng)持續(xù)運(yùn)行。Zabbix分為Agent端和Server端,Agent端:主機(jī)通過安裝agent方式采集數(shù)據(jù)。Server端:通過收集agent發(fā)送的數(shù)據(jù),寫入數(shù)據(jù)庫(MySQL,ORACLE等),再通過php+apache在web前端展示。
實(shí)戰(zhàn)環(huán)境:
Centos8_x64
Zabbix-4.4
安裝步驟:
一、配置操作系統(tǒng)
1、重命名計(jì)算機(jī)名:
[root@localhost ~]# vim /etc/hostname
2、配置 SELinux:
[root@localhost ~]# vim /etc/selinux/config
更改:
SELINUX=disabled
3、配置防火墻:為了方便,我這里選擇直接關(guān)閉防火墻;
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
4、配置網(wǎng)絡(luò):設(shè)置固定 IP 地址;
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens192
更改:
BOOTPROTO="static"
添加:
IPADDR=10.10.10.50
NETMASK=255.255.255.0
GATEWAY=10.10.10.1
DNS1=10.10.10.5
重啟網(wǎng)絡(luò):
[root@localhost ~]# systemctl restart network
**二、安裝 Zabbix **
1、更新系統(tǒng):
[root@zabbix ~]# yum update -y
2、安裝必要組件:
[root@zabbix ~]# dnf install -y httpd mysql-server \
php php-mysqlnd php-mbstring php-pdo php-gd
3、開啟必要組件的服務(wù):
[root@zabbix ~]# systemctl enable --now httpd.service
[root@zabbix ~]# systemctl enable --now mysqld.service
4、更改 HTTP 時(shí)區(qū)
[root@zabbix ~]# vim /etc/php.ini
# 設(shè)置:
date.timezone = Asia/Shanghai
5、初始化數(shù)據(jù):配置數(shù)據(jù)庫密碼(MySQL 的密碼)
[root@zabbix ~]# mysql_secure_installation Securing the MySQL server deployment. Connecting to MySQL using a blank password.
# 中間全部y
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success.
All done!
6、創(chuàng)建并配置數(shù)據(jù)庫:創(chuàng)建一個(gè)名為 zabbix 的數(shù)據(jù),并為這個(gè)數(shù)據(jù)庫創(chuàng)建一個(gè)名為 zabbix 的用戶,并設(shè) 置密碼為 “Shanghai2010@”,然后為這個(gè)用戶賦予
[root@zabbix tmp]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10
Server version: 8.0.17 Source distribution
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> create database zabbix character set UTF8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.19 sec)
mysql> create user 'zabbix'@'localhost' identified by 'Shanghai2010@';
Query OK, 0 rows affected (0.08 sec)
mysql> grant ALL on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected (0.17 sec) mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
7、安裝 Zabbix yum 庫:
[root@zabbix ~]# wget https://repo.zabbix.com/zabbix/4.4/rhel/8/x86_64/zabbix-release-4.4-1.el8.noarch.rpm
[root@zabbix ~]# dnf install -y zabbix-release-4.4-1.el8.noarch.rpm
[root@zabbix ~]# dnf makecache
8、安裝 Zabbix 服務(wù)器組件
[root@zabbix ~]# dnf install -y zabbix-server-mysql zabbix-web-mysql zabbix- apache-conf
9、使用Zabbix服務(wù)器安裝文件中提供的腳本創(chuàng)建Zabbix存儲(chǔ)庫。
[root@zabbix ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -D zabbix -pShanghai2010@
10、配置 Zabbix 服務(wù)器
[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=Shanghai2010@
11、安裝 Zabbix Agent,并啟動(dòng)服務(wù)
[root@zabbix ~]# dnf install -y zabbix-agent
[root@zabbix ~]# systemctl enable --now zabbix-server
[root@zabbix ~]# systemctl enable --now zabbix-agent
三、配置 Zabbix 完成安裝
1、在瀏覽器中輸入 “http://服務(wù)IP”
2、點(diǎn)擊 ”Next Step“
3、輸入 zabbix 數(shù)據(jù)庫的密碼,然后點(diǎn)擊 ”Next Step“
4、完成
5、Zabbix 默認(rèn)的用戶名是 ”Admin“,密碼是 ”zabbix“。注意其中用戶名中的 ”A“ 是大 寫。
6、進(jìn)入 Zabbix 的 Dashboard