實驗環境
網關 classroom 172.25.8.254
workstation 172.25.8.9
server a-jeth0 172.25.8.10-外網
eth1 192.168.0.x内網
eth2 192.168.1.x備用
servera:web
servere:server
--------------------------------------------
需求:監控
設計:
原理:
硬體:
系統:
軟體:zabbix
服務:
部署:
servere:作為服務端
[[email protected] ~]# mount 172.25.254.250:/content /mnt
[[email protected] ~]# cd /mnt/ula/monitor/zabbix/
[[email protected] zabbix]# ls
fping-3.10-4.el7.x86_64.rpm
iksemel-1.4-6.el7.x86_64.rpm
php-bcmath-5.4.16-23.el7_0.3.x86_64.rpm
php-mbstring-5.4.16-23.el7_0.3.x86_64.rpm
zabbix-2.4.6-1.el7.x86_64.rpm
zabbix-2.4.6.tar.gz
zabbix3
zabbix-agent-2.4.6-1.el7.x86_64.rpm
zabbix-sender-2.4.6-1.el7.x86_64.rpm
zabbix-server-2.4.6-1.el7.x86_64.rpm
zabbix-server-mysql-2.4.6-1.el7.x86_64.rpm
zabbix-server-pgsql-2.4.6-1.el7.x86_64.rpm
zabbix-web-2.4.6-1.el7.noarch.rpm
zabbix-web-mysql-2.4.6-1.el7.noarch.rpm
zabbix-web-pgsql-2.4.6-1.el7.noarch.rpm
集中化監控工具zabbix.pdf
[[email protected] zabbix]# tar xf zabbix-2.4.6.tar.gz -C /tmp#由于服務端與系統用rpm有沖突,是以使用源碼安裝
[[email protected] zabbix]# cd /tmp
[[email protected] tmp]# ls
zabbix-2.4.6
[[email protected] tmp]# setenforce 0
[[email protected] zabbix-2.4.6]# yum -y install gcc gcc-c++ mariadb-devel libxml2-devel net-snmp-devel libcurl-devel #安裝依賴包
[[email protected] zabbix]# cd /tmp/zabbix-2.4.6/
[[email protected] zabbix-2.4.6]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-libxml2 --with-net-snmp --with-libcurl#編譯指定安裝位置
[[email protected]ere zabbix-2.4.6]#make#打包
[[email protected] zabbix-2.4.6]#make install#安裝
[[email protected] etc]# cd /usr/local/zabbix/etc#配置檔案在安裝目錄
[[email protected] etc]# ls
zabbix_agent.conf zabbix_agentd.conf zabbix_server.conf
zabbix_agent.conf.d zabbix_agentd.conf.d zabbix_server.conf.d
[[email protected] etc]# vim zabbix_server.conf#修改配置檔案,指定資料庫位址,庫名,使用者名,和密碼
DBHost=172.25.8.19
DBName=zabbix
DBUser=zabbix
DBPassword=uplooking
--------------------------
serverj;資料庫伺服器
[[email protected] ~]# mount 172.25.254.250:/content /mnt
[[email protected] ~]# cd /mnt/ula/monitor/zabbix/
[[email protected] zabbix]# tar xf zabbix-2.4.6.tar.gz -C /tmp
cd /tmp/zabbix-2.4.6/database/mysql/#拷貝建表的腳本
[[email protected] mysql]# cp * /tmp
[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
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 zabbix character set utf8;#建表,并指定字元集,使支援中文
Query OK, 1 row affected (0.02 sec)
MariaDB [(none)]> grant all on zabbix.* to [email protected]'172.25.8.14' identified by 'uplooking';#對server和web授權
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on zabbix.* to [email protected]'servere.pod8.example.com' identified by 'uplooking';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on zabbix.* to [email protected]'172.25.8.10' identified by 'uplooking';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on zabbix.* to [email protected]'servera.pod8.example.com' identified by 'uplooking';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> Bye
[[email protected] ~]# mysql zabbix < /tmp/
data.sql mysql.all.sql .Test-unix/
easyjforum_mysql.sql schema.sql .X11-unix/
.font-unix/ systemd-private-8VQfSB/ .XIM-unix/
.ICE-unix/ systemd-private-MnuEnX/
images.sql systemd-private-wP9VTb/
[[email protected] ~]# mysql zabbix < /tmp/schema.sql #用腳本建表
[[email protected] ~]# mysql zabbix < /tmp/images.sql
[[email protected] ~]# mysql zabbix < /tmp/data.sql
[[email protected] ~]# timedatectl set-timezone Asia/Shanghai#更改時區
--------------------------
在servere啟動服務
[[email protected] mysql]# cd /usr/local/zabbix/sbin/
[[email protected] sbin]# ls
zabbix_agent zabbix_agentd zabbix_server
[[email protected] sbin]# ./zabbix_server #啟動不允許root身份啟動,建立一個組和使用者
zabbix_server [10463]: user zabbix does not exist
zabbix_server [10463]: cannot run as root!
[[email protected] sbin]# groupadd zabbix -g 686
[[email protected] sbin]# useradd zabbix -u 686 -g zabbix -s /sbin/nologin
[[email protected] sbin]# ./zabbix_server #啟動服務
[[email protected] sbin]# ps -ef |grep zabbix#檢視程序
[[email protected] sbin]# netstat -ntalp | grep zabbix#檢視監聽的端口号
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 10475/./zabbix_serv
tcp 0 0 172.25.8.14:38027 172.25.8.19:3306 ESTABLISHED
[[email protected] sbin]# timedatectl set-timezone Asia/Shanghai#時區保持一緻
-------------------
servera:作為web端
[[email protected] ~]# mount 172.25.254.250:/content /mnt
[[email protected] ~]# cd /mnt/ula/monitor/zabbix/
[[email protected] zabbix]# yum localinstall zabbix-web-2.4.6-1.el7.noarch.rpm zabbix-web-mysql-2.4.6-1.el7.noarch.rpm php-bcmath-5.4.16-23.el7_0.3.x86_64.rpm php-mbstring-5.4.16-23.el7_0.3.x86_64.rpm -y#安裝web端所需的軟體包
[[email protected] zabbix]# vim /etc/httpd/conf.d/zabbix.conf#修改配置檔案,時區改為目前時區,并生效
# php_value date.timezone Europe/Riga
[[email protected] zabbix]# timedatectl set-timezone Asia/Shanghai
[[email protected] zabbix]# systemctl start httpd#啟動服務
[[email protected] zabbix]# setenforce 0#關閉selinux權限
-----------------------------------------------
用戶端:
[[email protected] ~]# mount 172.25.254.250:/content /mnt
[[email protected] ~]# cd /mnt/ula/monitor/zabbix/
[[email protected] zabbix]# yum -y localinstall zabbix-agent-2.4.6-1.el7.x86_64.rpm fping-3.10-4.el7.x86_64.rpm iksemel-1.4-6.el7.x86_64.rpm zabbix-2.4.6-1.el7.x86_64.rpm
[[email protected] zabbix]# vim /etc/zabbix/zabbix_agentd.conf
Server=172.25.8.14
Hostname=serverf.pod8.example.com
[[email protected] zabbix]# systemctl start zabbix-agent
測試:
firefox
http://172.25.8.10/zabbix
設定資料庫和伺服器
初始登陸:user:admin password:zabbix
servere作用戶端打開agentd作測試
[[email protected] sbin]# pwd
/usr/local/zabbix/sbin
[[email protected] sbin]# ./zabbix_agentd
問題與解答:
轉載于:https://www.cnblogs.com/lihuaichen/p/10128498.html