來自公眾號:馬哥Linux運維
作者于培智
Zabbix介紹:
Zabbix是一個基于Web界面提供分布式系統(tǒng)監(jiān)視及網(wǎng)絡(luò)監(jiān)視功能的企業(yè)級開源解決方案妨猩。它能監(jiān)視各種網(wǎng)絡(luò)參數(shù),保證服務(wù)器系統(tǒng)的安全運營遭笋,并提供靈活的通知機制以讓系統(tǒng)管理員快速定位/解決存在的各種問題坝冕;借助Zabbix可很輕松地減輕運維人員們繁重的服務(wù)器管理任務(wù),實現(xiàn)業(yè)務(wù)系統(tǒng)持續(xù)運行瓦呼。Zabbix分為Agent端和Server端喂窟,Agent端:主機通過安裝agent方式采集數(shù)據(jù)。Server端:通過收集agent發(fā)送的數(shù)據(jù),寫入數(shù)據(jù)庫(MySQL磨澡,ORACLE等)碗啄,再通過php+apache在web前端展示。
實戰(zhàn)環(huán)境:
Centos8_x64
Zabbix-4.4
安裝步驟:
一钱贯、配置操作系統(tǒng)
1、重命名計算機名:
[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 時區(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)建一個名為 zabbix 的數(shù)據(jù),并為這個數(shù)據(jù)庫創(chuàng)建一個名為 zabbix 的用戶礼搁,并設(shè) 置密碼為 “Shanghai2010@”饶碘,然后為這個用戶賦予
[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存儲庫。
[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,并啟動服務(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、點擊 ”Next Step“
3歹河、輸入 zabbix 數(shù)據(jù)庫的密碼齿椅,然后點擊 ”Next Step“
4、完成
5启泣、Zabbix 默認的用戶名是 ”Admin“涣脚,密碼是 ”zabbix“。注意其中用戶名中的 ”A“ 是大 寫寥茫。
6遣蚀、進入 Zabbix 的 Dashboard