基于AIOps理念研發(fā)的新一代運維監(jiān)大屏
全盤展示運行狀態(tài)社证,減輕運維人員的重復(fù)性工作量,提高系統(tǒng)排錯速度,加速運維知識學(xué)習(xí)積累。
該課介紹
講師簡介
關(guān)于Nate老師:
1.具有18年的IT技術(shù)開發(fā)及運維經(jīng)驗元践,具備豐富的大型IT架構(gòu)設(shè)計、自動化運維開發(fā)童谒、智能化運維開發(fā)单旁、運維大數(shù)據(jù)分析、企業(yè)級軟件系統(tǒng)開發(fā)饥伊、數(shù)據(jù)中心規(guī)劃建設(shè)象浑、災(zāi)備系統(tǒng)規(guī)劃建設(shè)、ITSM規(guī)劃及軟件系統(tǒng)開發(fā)琅豆、數(shù)據(jù)可視化愉豺、機器學(xué)習(xí)、人工智能等項目實戰(zhàn)經(jīng)驗茫因。
2.組織蚪拦、規(guī)劃設(shè)計、研發(fā)過多款企業(yè)級IT監(jiān)控運維系統(tǒng)冻押、云計算資源管理平臺驰贷、IT服務(wù)管理系統(tǒng)。
3.目前任職于企業(yè)級軟件系統(tǒng)研發(fā)公司洛巢,職務(wù)CTO括袒。
該課目標(biāo)
通過本套課程的學(xué)習(xí),讓你達(dá)到的目標(biāo):
(1) 獨立完成企業(yè)生產(chǎn)級Zabbix監(jiān)控系統(tǒng)部署稿茉;
(2) Zabbix監(jiān)控MySQL锹锰、Linux的實施部署;
(3) Grafana7.1的安裝部署及基本應(yīng)用漓库;
(4) Maxserver的安裝部署以及基本應(yīng)用城须。
該課特色
(1) 分享運維經(jīng)驗、成長經(jīng)驗米苹,讓小白也能快速成長為具備市場競爭力的運維人才糕伐;
(2) 老師助教提供遠(yuǎn)程解答,保證你掌握此門課程的學(xué)習(xí)內(nèi)容蘸嘶,達(dá)到學(xué)習(xí)目標(biāo)良瞧。
適合人群
系統(tǒng)運維工程師,DevOps工程師训唱,網(wǎng)絡(luò)工程師褥蚯,以及對運維事業(yè)感興趣的工程師。
該課簡介
Zabbix是一個企業(yè)級解決方案况增,支持實時監(jiān)控數(shù)千臺服務(wù)器赞庶,虛擬機和網(wǎng)絡(luò)設(shè)備,采集百萬級監(jiān)控指標(biāo)。
(一)從任何設(shè)備(網(wǎng)絡(luò)歧强、服務(wù)器...)澜薄、系統(tǒng)、應(yīng)用程序上進行指標(biāo)采集
(二)問題檢測摊册,定義智能閥值
(三)可視化
1.單一界面管理平臺
2.Web可視化界面肤京,豐富的可視化選項,全面展示您的IT環(huán)境茅特,滿足多種展示需求
3.儀表盤小部件
4.圖表組件
5.網(wǎng)絡(luò)拓?fù)鋱D
6.幻燈片展示
(四)告警和修復(fù)
- 確保及時忘分、有效的告警
2.檢測到異常時,以多種渠道和選項告警通知到相關(guān)的管理人員:
3.發(fā)送信息
4.讓Zabbix自動修復(fù)問題
5.根據(jù)用戶自定義的服務(wù)級別白修,階梯式發(fā)送告警妒峦,靈活可控
6.根據(jù)收件人的角色自定義郵件。
7.基于運行時間和資產(chǎn)信息自定義消息兵睛。
8.使用Zabbix事件關(guān)聯(lián)機制對問題進行跟故障分析舟山,解除告警風(fēng)暴,輕松管理
軟件版本說明
操作系統(tǒng):
CentOS 8.2
Zabbix 5.0
Grafana 7.1
Maxserver5.0
- 安裝環(huán)境準(zhǔn)備
yum -y update (所有都升級和改變)
升級所有包,系統(tǒng)版本和內(nèi)核卤恳,改變軟件設(shè)置和系統(tǒng)設(shè)置
yum -y upgrade(不變內(nèi)核和設(shè)置,升級包和系統(tǒng)版本)
升級所有包和系統(tǒng)版本,不改變內(nèi)核,軟件和系統(tǒng)設(shè)置
1.1檢查操作系統(tǒng)版本
[root@huaxun ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
1.2檢查服務(wù)器主機名稱和修改主機名稱
檢查主機名稱
[root@huaxun ~]# hostnamectl
修改主機名hostname
靜態(tài)寒矿,瞬態(tài)或靈活突琳,分別對應(yīng) “--static”,“--transient”或“--pretty”選項符相、
我們永久修改主機名稱拆融,用“--static”選項
[root@huaxun ~]# hostnamectl --static set-hostname zabbixserver
[root@huaxun ~]# hostnamectl
[root@huaxun ~]# cat /etc/hostname
修改hosts文件
[root@huaxun ~]# vi /etc/hosts
[root@huaxun ~]# reboot
完成以上操作后重啟系統(tǒng)。
1.3關(guān)閉防火墻及SElinux
[root@huaxun ~]# systemctl stop firewalld.service
[root@huaxun ~]# systemctl disable firewalld.service
(1)設(shè)置開機啟用防火墻:systemctl enable firewalld.service
(2)設(shè)置開機禁用防火墻:systemctl disable firewalld.service
(3)啟動防火墻:systemctl start firewalld
(4)關(guān)閉防火墻:systemctl stop firewalld
(5)檢查防火墻狀態(tài):systemctl status firewalld
開放10050端口
開放10050端口
firewall-cmd --zone=public --add-port=10050/tcp --permanent
開放80端口
firewall-cmd --zone=public --add-port=80/tcp –permanent
配置立即生效
firewall-cmd --reload
SELinux關(guān)閉
接著將SELinux關(guān)閉啊终,運行如下命令編輯SELINUX配置文件:
并將SELINUX=enforcing改成SELINUX=disable镜豹,如下:
[root@huaxun ~]# vi /etc/selinux/config
This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=disabled
SELINUXTYPE= can take one of three values:
targeted - Targeted processes are protected,
minimum - Modification of targeted policy. Only selected processes are protected.
mls - Multi Level Security protection.
SELINUXTYPE=targeted
SELinux有三種模式:Enforcing, Permissive 和 Disable,Enforcing模式就是應(yīng)用SELinux所設(shè)定的Policy,所有違反Policy的規(guī)則(Rules)都會被SELinux拒絕蓝牲,Permissive和Enforcing的區(qū)別就在于趟脂,前者還是會遵循SELinux的Policy,但是對于違反規(guī)則的操作只會予以記錄而并不會拒絕操作,Disable 顧名思義就是完全禁用SELinux例衍;
修改完成后昔期,重啟機器,重啟后運行g(shù)etenforce命令查看已經(jīng)關(guān)閉SELinux佛玄。
[root@huaxun ~]# getenforce
Disabled
[root@huaxun ~]# /usr/sbin/sestatus -v
SELinux status: disabled
1.4安裝依賴包
[root@zabbixserver ~]# yum install -y httpd mariadb-server mariadb php php-gd
libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash
[root@zabbixserver ~]#rpm -qa httpd php mariadb
備注:可能用到的指令
安裝指令
undo yum install mariadb mariadb-server -y
查看是否安裝成功
rpm -qa | grep mariadb
常用命令:
查看 mariadb 安裝位置
rpm -ql mariadb
設(shè)置開機自動啟動
systemctl enable mariadb
開啟mariadb服務(wù)
systemctl start mariadb
關(guān)閉 mariadb 服務(wù)
systemctl stop mariadb
重啟mariadb服務(wù)
systemctl restart mariadb
1.5相關(guān)配置
[root@zabbixserver ~]# vi /etc/httpd/conf/httpd.conf
將servername設(shè)置為192.168.10.218:80硼一,在DirectoryIndex中添加index.php,如下:
ServerName gives the name and port that the server uses to identify itself.
This can often be determined automatically, but we recommend you specify
it explicitly to prevent problems during startup.
If your host doesn't have a registered DNS name, enter its IP address here.
ServerName 39.99.160.163:80
DirectoryIndex: sets the file that Apache will serve if a directory
is requested.
<IfModule dir_module>
DirectoryIndex index.htmlindex.php
</IfModule>
接著配置php.ini梦抢,如下:
[root@zabbixserver ~]# vi /etc/php.ini
將date.timezone設(shè)置為PRC:
PRC就是The People's Republic of China
[Date] ; Defines the default timezone used by the date functions ;http://php.net/date.timezonedate.timezone = PRC
1.6開始啟動http和mysql數(shù)據(jù)庫
[root@zabbixserver ~]# systemctl start httpd
[root@zabbixserver ~]# systemctl start mariadb
[root@zabbixserver ~]#
[root@zabbixserver ~]# ss -naplt | grep httpd
[root@zabbixserver ~]# ss -naplt | grep mysqld
設(shè)置開機自啟動模式:
[root@zabbixserver ~]# systemctl enable httpd
[root@zabbixserver ~]# systemctl enable mariadb
1.7開始測試PHP功能
[root@zabbixserver ~]# vi /var/www/html/index.php
輸入以下內(nèi)容:
<?php
phpinfo();
?>
打開http://192.168.10.218/)39.99.160.163般贼,顯示如下界面說明PHP運行正常。
1.8 Centos8上安裝中文語言包
[root@zabbixserver ~]# yum install langpacks-zh_CN.noarch
1.9 配置并初始化數(shù)據(jù)庫
設(shè)置mysql數(shù)據(jù)庫root密碼為zabbixroot,如下:
[root@zabbixserver ~]# **mysqladmin -urootpasswordzabbixroot
安裝好數(shù)據(jù)庫 初始化時報錯 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
解決步驟如下:
1. 首先停掉數(shù)據(jù)庫服務(wù): systemctl stop mariadb.service
2. 使用mysqld_safe來啟動mysqld服務(wù)器 :
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
顯示: 退出Ctrl+c
3 . 登錄 : mysql -u root mysql
4 . 修改root用戶密碼:
UPDATE user SET PASSWORD=PASSWORD('zabbixroot') where USER='root';
5 . 使用修改后的root用戶和新密碼zabbixroot登錄數(shù)據(jù)庫: mysql -uroot -p
The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
創(chuàng)建用戶時報錯哼蛆,執(zhí)行語句為:
GRANT ALL PRIVILEGES ON . TO helei IDENTIFIED BY 'MANAGER' WITH GRANT OPTION;
解決:mysql> flush privileges;
[root@zabbixserver ~]# mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
GRANT all privileges ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'zabbix123' with grant option;
GRANT all privileges ON zabbix.* TO 'zabbix'@'PXZB' IDENTIFIED BY 'zabbix123';
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix123';
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
MariaDB [(none)]> quit
參考:
GRANT ALL PRIVILEGES ON . TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; // %:表示從任何主機連接到mysql服務(wù)器
MariaDB [(none)]> GRANT all ON zabbix.* TO 'zabbix'@'zabbixserver' IDENTIFIED
BY 'zabbix123' ;
GRANT all privileges ON zabbix.* TO 'zabbix'@'zabbixserver' IDENTIFIED BY
'zabbix123';
GRANT all privileges ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY
'zabbix123';
查看mysql數(shù)據(jù)庫中的所有用戶
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
刪除賬戶
MariaDB [(none)]> SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
+---------------------------------+
| query |
+---------------------------------+
| User: 'root'@'127.0.0.1'; |
| User: 'zabbix'@'39.99.160.163'; |
| User: 'root'@'::1'; |
| User: 'root'@'localhost'; |
| User: 'root'@'zabbixserver'; |
+---------------------------------+
5 rows in set (0.000 sec)
MariaDB [(none)]> drop user 'zabbix'@'39.99.160.163';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
[root@zabbixserver ~]#
MariaDB [zabbix]> select host,user from mysql.user;
+--------------+--------+
| host | user |
+--------------+--------+
| % | user |
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
| zabbixserver | root |
| zabbixserver | zabbix |
+--------------+--------+
6 rows in set (0.000 sec)
1.10安裝依賴包
[root@zabbixserver ~]# yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libxml2-devel libevent-devel.x86_64
再次蕊梧,環(huán)境準(zhǔn)備工作已經(jīng)順利完成!
- 安裝并配置zabbix5.0
2.1 Zabbix包安裝
[root@zabbixserver ~]# rpm -ivh (https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm) [root@zabbixserver ~]# yum clean all
2.2組件安裝
[root@zabbixserver ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-apache-conf zabbix-agent
如果無法安裝人芽,修改yum望几,并執(zhí)行yum clean all
再安裝組件
cd /etc/yum.repos.d
zabbix.repo
root@zabbixserver yum.repos.d]# cat zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/8/$basearch/
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/8/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/8/$basearch/
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
2.3導(dǎo)入初始架構(gòu)和數(shù)據(jù)
這種方法出差概率比較高
cat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p -h 192.168.1.10zabbix
輸入zabbix用戶的密碼zabbix123,開始導(dǎo)入萤厅。
或者導(dǎo)入數(shù)據(jù)
準(zhǔn)備工作
cd /usr/share/doc/zabbix-server-mysql/
gunzip create.sql.gz
mysql -uzabbix -pzabbix123
use zabbix
source /usr/share/doc/zabbix-server-mysql/create.sql
數(shù)據(jù)導(dǎo)入完成后開始配置zabbix server的配置文件橄抹,使配置文件中引用剛才創(chuàng)建的數(shù)據(jù)庫,編輯/etc/zabbix/zabbix_server.conf文件:
[root@zabbixserver ~]# vi /etc/zabbix/zabbix_server.conf
完成如下DBHost惕味、DBName楼誓、DBUser、DBPassword配置:
Option: DBHost
Database host name.
If set to localhost, socket is used for MySQL.
If set to empty string, socket is used for PostgreSQL.
Mandatory: no
Default:
DBHost=zabbixserver
Option: DBName
Database name.
Mandatory: yes
Default:
DBName=
DBName=zabbix
Option: DBSchema
Schema name. Used for PostgreSQL.
Mandatory: no
Default:
DBSchema=
Option: DBUser
Database user.
Mandatory: no
Default:
DBUser=
DBUser=zabbix
Option: DBPassword
Database password.
Comment this line if no password is used.
Mandatory: no
Default: DBPassword=zabbix123
檢查配置
cat /etc/zabbix/zabbix_server.conf|egrep -i
"DBHost|DBName|DBUser|DBPassword"|grep -v "#"
接著配置zabbix配置文件zabbix.conf:
[root@zabbixserver ~]# **vi /etc/php-
fpm.d/zabbix.conf
將date.timezone設(shè)置成Asia/Shanghai名挥,如下:
php_value[date.timezone] = Asia/Shanghai
; php_value[date.timezone] = Asia/Shanghai
注意:要去掉這個雙引號疟羹,并且重啟服務(wù)。
啟動zabbix程序:
[root@zabbixserver ~]# **systemctl restart
zabbix-server zabbix-agent httpd php-fpm
[root@zabbixserver ~]# **systemctl enable
zabbix-server zabbix-agent httpd php-fpm
查看日志文件zabbix_server.log禀倔,沒有相關(guān)錯誤榄融,說明運行正常
[root@zabbixserver ~]# more
/var/log/zabbix/zabbix_server.log
2.4開始圖形化配置zabbix
輸入http://39.99.160.163/zabbix,如下:
默認(rèn)賬號Admin
默認(rèn)密碼為zabbix
設(shè)置為中文界面救湖,如下圖愧杯。
2.5將圖形界面中的亂碼修復(fù)為中文顯示
默認(rèn)zabbix在圖形顯示中中文顯示為亂碼,需要修復(fù)才能正常顯示鞋既,如下圖紅框所示:
操作如下:
首先將WINDOWS FONTS文件夾中的黑體字復(fù)制至本機硬盤
將本地電腦上的黑體字體文件simhei.ttf復(fù)制到/usr/share/zabbix/assets/fonts/目錄下力九,如下圖
再通過修改vi /usr/share/zabbix/include/defines.inc.php文件,將紅框位置中原graphfont修改為simhei邑闺,如下圖跌前,完成后保存退出。
刷新圖形界面陡舅,已能顯示中文抵乓,如下。
3.通過zabbix agent(yum安裝方式)實現(xiàn)CentOS8數(shù)據(jù)采集及監(jiān)控
3.1安裝包
首先關(guān)閉防火墻及SELinux靶衍,開始安裝agent:
[root@localhost~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
開始安裝:
[root@localhost ~]#** yum install zabbix-
agent
如果無法安裝臂寝,修改yum
cd /etc/yum.repos.d
zabbix.repo
root@zabbixserver yum.repos.d]# cat zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/8/$basearch/
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/8/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/8/$basearch/
baseurl=http://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
3.2配置zabbix_agentd.conf配置文件
/etc/zabbix/zabbix_agentd.conf
Server=192.168.10.218
ServerActive=192.168.10.218
Hostname=localhost.localdomain
完成后保存退出。
檢查:
cat /etc/zabbix/zabbix_agentd.conf|egrep -i
"Server|ServerActive|Hostname"|grep -v "#"
3.3配置文件修改后摊灭,開始啟動服務(wù)
啟動服務(wù):
[root@localhost ~]# systemctl start zabbix-agent.service
重新啟動服務(wù)
systemctl restart zabbix-agent.service
添加開機啟動功能:
[root@localhost ~]# systemctl enable
zabbix-agent.service
Created symlink
/etc/systemd/system/multi-
user.target.wants/zabbix-agent.service
鈫 /usr/lib/systemd/system/zabbix-
agent.service.
[root@localhost ~]#
查看agent服務(wù)是否已啟動:
ps -ef|grep zabbix_agentd
[root@localhost ~]# ss -tnl | grep 10050
LISTEN 0 128
0.0.0.0:10050 0.0.0.0:*
LISTEN 0 128
[::]:10050 [::]:*
[root@localhost ~]#
如上咆贬,已發(fā)現(xiàn)agentd進程運行,并且10050端口已啟動
開始添加至ZABBIX5.0平臺中帚呼,打開zabbix server主界面掏缎,選擇“配置‘->”主機“皱蹦,點擊右上角的”創(chuàng)建“按扭,
創(chuàng)建一臺主機眷蜈,如下圖
鏈接zabbix agent for linux模板:
完成后可以看到列表沪哺,過幾分鐘后,可用性一欄中的ZBX變綠即表示監(jiān)控正常酌儒。
4.Zabbix5.0監(jiān)控MySQL
4.1MySQL服務(wù)器配置
4.1.1創(chuàng)建數(shù)據(jù)庫監(jiān)控賬號
登錄mysql并創(chuàng)建新用戶(用于登錄MySQL獲取服務(wù)狀態(tài))
Mysql>GRANT USAGE ON . TO
'zabbix'@'localhost' IDENTIFIED BY 'passwd';
案例:
GRANT USAGE ON . TO
'zabbixmonitor'@'localhost' IDENTIFIED BY
'zabbixadmin';
Mysql>FLUSH PRIVILEGES;
(注:zabbix為數(shù)據(jù)庫用戶名辜妓,passwd為數(shù)據(jù)庫用戶密碼)
4.1.2安裝Zabbix Agent
上傳zabbix agent的rpm包到mysql服務(wù)器并安裝
rpm -ivh zabbix-agent-5.0.0-1.el7.x86_64.rpm
修改zabbix agent配置文件
vi /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1 //修改為zabbix-server的IP地址
ServerActive=127.0.0.1 //修改為zabbix-server的IP地址
Hostname=Zabbix server //自定義修改
查看sock文件路徑
find / -name *.sock
//查找到的路徑通常情況為/var/lib/mysql/mysql.sock
查找并拷貝Zabbix監(jiān)控Mysql模板文件
find / -name user*_mysql.conf //查找
cp 查找到的目錄 /etc/zabbix/zabbix_agentd.d/ //拷貝
cp -rp /usr/share/doc/zabbix-agent/userparameter_mysql.conf /etc/zabbix/zabbix_agentd.d/
新建文件夾
mkdir -p /var/lib/zabbix
修改文件
vi /var/lib/zabbix/.my.cnf
寫入內(nèi)容
[mysql]
user=zabbix //新創(chuàng)建的mysql用戶的用戶名
password=zabbix //新創(chuàng)建的mysql用戶的密碼
host=127.0.0.1
socket=/var/lib/mysql/mysql.sock
[mysqladmin]
user=zabbix //新創(chuàng)建的mysql用戶的用戶名
password=zabbix //新創(chuàng)建的mysql用戶的密碼
host=127.0.0.1
socket=/var/lib/mysql/mysql.sock
[mysql]
user=zabbixmonitor
password=zabbixadmin
host=127.0.0.1
socket=/var/lib/mysql/mysql.sock
[mysqladmin]
user=zabbixmonitor
password=zabbixadmin
host=127.0.0.1
socket=/var/lib/mysql/mysql.sock
保存退出后重啟zabbix agent
systemctl restart zabbix-agent
4.2zabbix配置
4.2.1方法一:同時添加主機監(jiān)控及MySQL監(jiān)控
登錄zabbix系統(tǒng),點擊配置——主機——創(chuàng)建主機
填寫主機名稱忌怎,選擇群組籍滴,填寫IP地址為mysql服務(wù)器IP
主機添加完成后點擊進入該主機,選擇mysql模板
4.2.2方法二:主機已經(jīng)監(jiān)控榴啸,增加MySQL監(jiān)控
登錄zabbix系統(tǒng)孽惰,點擊配置——主機
找到該主機并點擊進入主機,點擊模板
選擇mysql模板后點擊更新
5安裝Grafana7.1 并添加Zabbix數(shù)據(jù)源
Grafana 是一款采用 go 語言編寫的開源應(yīng)用鸥印,主要用于大規(guī)模指標(biāo)數(shù)據(jù)的可視化展現(xiàn)勋功,是網(wǎng)絡(luò)架構(gòu)和應(yīng)用分析中最流行的時序數(shù)據(jù)展示工具,目前已經(jīng)支持絕大部分常用的時序數(shù)據(jù)庫库说。
開始安裝Grafana
關(guān)閉防火墻及SELINUX:
[root@localhost ~]#** systemctl stop firewalld.service
[root@localhost ~]#
[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
(1)設(shè)置開機啟用防火墻:systemctl enable firewalld.service
(2)設(shè)置開機禁用防火墻:systemctl disable firewalld.service
(3)啟動防火墻:systemctl start firewalld
(4)關(guān)閉防火墻:systemctl stop firewalld
(5)檢查防火墻狀態(tài):systemctl status firewalld
完成后狂鞋,開始安裝Grafana(或者使用清華大學(xué)鏡像https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/),下載:
[root@localhost ~]# wget https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/grafana-7.1.0-1.x86_64.rpm
[root@localhost ~]#
安裝:
[root@localhost ~]# yum localinstall grafana-7.1.0-1.x86_64.rpm
[root@localhost ~]#
啟動grafana并設(shè)置為開機啟動:
[root@localhost ~]#** systemctl start grafana-server.service
[root@localhost ~]# **systemctl enable grafana-server.service
使用http://39.99.160.163:3000/login潜的,輸入用戶名密碼骚揍,都為admin:
輸入新密碼:
完成安裝后,開始添加ZABBIX數(shù)據(jù)源:
進入Grafana官網(wǎng)https://grafana.com/grafana/plugins/alexanderzobnin-zabbix-app頁面夏块,查看Installation安裝方法
在Grafana服務(wù)器上使用命令grafana-cli plugins install alexanderzobnin-zabbix-app開始安裝:
[root@localhost ~]# **grafana-cli plugins install alexanderzobnin-zabbix-app
[root@ZB ~]# grafana-cli plugins install alexanderzobnin-zabbix-app
installing alexanderzobnin-zabbix-app @ 3.12.4
from: https://grafana.com/api/plugins/alexanderzobnin-zabbix-app/versions/3.12.4/download
into: /var/lib/grafana/plugins
a?” Installed alexanderzobnin-zabbix-app successfully
Restart grafana after installing plugins . <service grafana-server restart>
[root@localhost ~]#
然后重啟動Grafana服務(wù):
[root@localhost ~]# **systemctl restart grafana-server.service
完成后進入剛安裝成功的Plugins菜單的Zabbix插件纤掸,點擊【Enable】啟動插件,如下圖
進入Configuration->Add data source
點擊【Selcet】
配置Data Sources中的Zabbix政己,輸入ZABBIX URL:http://39.99.160.163/zabbix/api_jsonrpc.php掏愁,以及輸入ZABBIX平臺的用戶名及密碼
開啟警告,完成后點擊【Save&Test】測試并添加果港,如下圖沦泌。
至此全部安裝完成并設(shè)置谢谦,后期在面板中直接調(diào)用ZABBIX數(shù)據(jù)源即可。
6 Zabbix5.0監(jiān)控cisco交換機配置
6.1開啟交換機SNMP協(xié)議
連接交換機,運行enable進入用戶模式千劈。
Switch>enable
Switch#
運行sh snmp查看SNMP協(xié)議是否開啟
Switch#sh snmp
運行config t進入全局配置模式
Switch# config terminal
Switch<config>#
設(shè)置只讀字符串, public為團體名稱,ro為只讀
Switch<config>#snmp-server community public ro
啟用snmp陷井,允許交換機將所有類型SNMP Trap發(fā)送出去
Switch<config>#snmp-server enable traps snmp
SNMP采用版本2墙牌,public作為團體名稱憔古,192.168.1.75為zabbix-server地址
Switch<config>#snmp-server host 192.168.1.75 version 2c public
指定SNMP Trap的接收者為192.168.1.75(zabbix-server地址)鸿市,發(fā)送Trap時采用public作為團體名稱
Switch<config>#snmp-server host 192.168.1.75 traps public
設(shè)置vlan1虛接口IP地址做為snmp trap信息的發(fā)布地址
Switch<config>#snmp-server trap-source vlan 1
6.2配置zabbix
登錄zabbix系統(tǒng)焰情,點擊配置——主機群組——創(chuàng)建主機群組創(chuàng)建一個snmp主機群組
點擊配置——主機——創(chuàng)建主機
填寫主機名稱内舟,選擇群組為snmp验游,移除客戶端類型瘾境,點擊添加按鈕,添加SNMP類型
要移除這個垒在。
然后蒜魄,點擊添加:
IP地址填寫為交換機的IP地址
主機添加完成后點擊進入該主機场躯,選擇模板
點擊宏按鈕添加主機宏
宏 {$SNMP_COMMUNITY} 值 public
7 Zabbix5.0觸發(fā)器配置以及拓?fù)鋱D配置介紹
7.1觸發(fā)器配置
登錄zabbix點擊左側(cè)導(dǎo)航欄的配置伞鲫,點擊主機
選擇需要添加觸發(fā)器的主機榔昔,點擊觸發(fā)器撒会,右上角創(chuàng)建觸發(fā)器
填寫觸發(fā)器相關(guān)基本內(nèi)容
點擊表達(dá)式的添加按鈕诵肛,添加觸發(fā)器的條件
選擇監(jiān)控項怔檩,在此主機的某監(jiān)控項上面添加觸發(fā)條件
點擊依賴關(guān)系薛训,可根據(jù)需要添加依賴
7.2拓?fù)鋱D配置
登錄zabbix點擊左側(cè)導(dǎo)航欄的檢測闸英,點擊拓?fù)鋱D
點擊右上角創(chuàng)建拓?fù)鋱D甫何,填寫相關(guān)信息
創(chuàng)建完成后辙喂,點擊新創(chuàng)建的拓?fù)鋱D巍耗,右上角編輯拓?fù)鋱D
點擊添加地圖元素炬太,即添加一個元素到拓?fù)鋱D中
點擊此元素娄琉,可對該元素進行修改,修改完成后點擊應(yīng)用
點擊選擇一個元素城看,按住Ctrl鍵選擇其他元素测柠,點擊鏈接后面的添加,即將兩個元素相連接
拓?fù)鋱D編輯好之后,點擊更新按鈕保存