目錄
一、關閉防火墻和SElinux和配置安裝源
二、zabbxi服務器配置
1、安裝Zabbix server,Web前端,agent ,mysql-server
2、配置mysql數據庫
3、為Zabbix server配置數據庫
4、啟動對應服務
三、登錄zabbix
四、客戶端部署
五、解決中文亂碼問題
六、配置監控客戶端內容
1、配置監控內容
2、使用現有模板添加
一、關閉防火墻和SElinux和配置安裝源
[root@bogon ~]# systemctl disable --now firewalld.service Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service". Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service". [root@bogon ~]# setenforce 0 ?
二、zabbxi服務器配置
服務器IP為192.168.58.170
1、安裝Zabbix server,Web前端,agent ,mysql-server
[root@bogon ~]# hostnamectl set-hostname zabbix [root@bogon ~]# bash [root@zabbix ~]# rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-7.0-5.el9.noarch.rpm ? [root@zabbix yum.repos.d]# yum install zabbix-server-mysql zabbix-web-mysql zabbix-nginx-conf zabbix-sql-scripts zabbix-selinux-policy zabbix-agent ? [root@zabbix yum.repos.d]# yum install -y mysql-server ? [root@zabbix yum.repos.d]# systemctl start mysqld
2、配置mysql數據庫
[root@zabbix yum.repos.d]# mysql ? mysql> create database zabbix character set utf8mb4 collate utf8mb4_bin; Query OK, 1 row affected (0.01 sec) ? mysql> create user zabbix@localhost identified by 'zabbix'; Query OK, 0 rows affected (0.02 sec) ? mysql> grant all privileges on zabbix.* to zabbix@localhost; Query OK, 0 rows affected (0.00 sec) ? mysql> set global log_bin_trust_function_creators = 1; Query OK, 0 rows affected, 1 warning (0.00 sec) ? mysql> quit; Bye ? ##導入初始架構和數據,系統將提示您輸入新創建的密碼:zabbix [root@zabbix yum.repos.d]# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix Enter password:
3、為Zabbix server配置數據庫
[root@zabbix yum.repos.d]# vim /etc/zabbix/zabbix_server.conf ? # DBPassword=改為 ? DBPassword=zabbix ? ##更改端口號,不改也行 [root@zabbix yum.repos.d]# cd /etc/nginx/ [root@zabbix nginx]# ls conf.d ? ? ? fastcgi.conf.default ? koi-utf ? ? mime.types.default scgi_params ? ? ? ? uwsgi_params.default default.d ? ? fastcgi_params ? ? ? ? koi-win ? ? nginx.conf ? ? ? ? scgi_params.default win-utf fastcgi.conf fastcgi_params.default mime.types nginx.conf.default uwsgi_params [root@zabbix nginx]# vim nginx.conf ?# ? ? ? listen ? ? ? 80; ?# ? ? listen ? ? ? [::]:80; ? ? [root@zabbix nginx]# cd conf.d/ [root@zabbix conf.d]# ls php-fpm.conf zabbix.conf [root@zabbix conf.d]# vim zabbix.conf ?# ? ? ? listen ? ? ? ? 8080;改為 ?listen ? ? ? ? 80;
4、啟動對應服務
[root@zabbix conf.d]# systemctl enable --now zabbix-server zabbix-agent nginx php-fpm ?
三、登錄zabbix
網站訪問192.168.58.170
密碼為zabbix
密碼為zabbix
四、客戶端部署
客戶端IP為I192.168.58.171
####192.168.58.171 [root@bogon ~]# rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-7.0-5.el9.noarch.rpm ? [root@bogon ~]# yum install -y zabbix-agent ? [root@bogon ~]# vim /etc/zabbix/zabbix_agentd.conf Server=127.0.0.1改為: Server=192.168.58.170 ? Hostname=Zabbix server改為 Hostname=host1 ? [root@bogon ~]# systemctl start zabbix-agent.service
五、解決中文亂碼問題
####192.168.58.170 [root@zabbix zabbix]# cd /usr/share/zabbix/assets/fonts [root@zabbix fonts]# ls graphfont.ttf zabbix-icons.svg zabbix-icons.ttf zabbix-icons.woff zabbix-icons.woff2 [root@zabbix fonts]# ls -l 總用量 196 lrwxrwxrwx. 1 root root ? ? 33 7月 22 19:56 graphfont.ttf -> /etc/alternatives/zabbix-web-font -rw-r--r--. 1 root root 149851 6月 27 15:08 zabbix-icons.svg -rw-r--r--. 1 root root 22072 6月 27 15:08 zabbix-icons.ttf -rw-r--r--. 1 root root 11716 6月 27 15:08 zabbix-icons.woff -rw-r--r--. 1 root root ? 9756 6月 27 15:08 zabbix-icons.woff2 ?
從windows系統中:C:\Windows\Fonts路徑下(宋體常規)拷貝到zabbix server中,放到/usr/share/zabbix/assets/fonts
[root@zabbix fonts]# yum install -y lrzsz ? [root@zabbix fonts]# rz rz waiting to receive.**[root@zabbix fonts]# ls graphfont.ttf SIMSUN.TTC zabbix-icons.svg zabbix-icons.ttf zabbix-icons.woff zabbix-icons.woff2 [root@zabbix fonts]# unlink graphfont.ttf [root@zabbix fonts]# cp SIMSUN.TTC graphfont.ttf [root@zabbix fonts]# ls graphfont.ttf SIMSUN.TTC zabbix-icons.svg zabbix-icons.ttf zabbix-icons.woff zabbix-icons.woff2
六、配置監控客戶端內容
1、配置監控內容
監控磁盤使用率
監控登錄系統的用戶數量
####192.168.58.171 [root@bogon zabbix-agent]# cd /etc/zabbix/zabbix_agentd.d/ [root@bogon zabbix_agentd.d]# ls [root@bogon zabbix_agentd.d]# vim disk.conf UserParameter=disk_use[*],df | grep "$1$" | awk '{print $(NF-1)}' | cut -d% -f1 UserParameter=count_user[*],last | grep -v wtmp | grep -v "^$" | awk '{print $(NF+1-NF)}' | sort | uniq -c | grep "$1" | awk '{print $(NF+1-NF)}' ? [root@bogon zabbix_agentd.d]# systemctl restart zabbix-agent.service ?
測試添加的監控項是否能正常使用
####192.168.58.170 [root@zabbix fonts]# yum install -y zabbix-get [root@zabbix fonts]# zabbix_get -s 192.168.58.171 -p 10050 -k disk_use[/] 11 [root@zabbix fonts]# zabbix_get -s 192.168.58.171 -p 10050 -k count_user[root] 9
2、使用現有模板添加
自己創建模板監控項
同理操作,加入監控用戶登錄數量