专属小白们的Zabbix部署详解
简介:zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
特点:
zabbix的主要特点:
[*]安装与配置简单,学习成本低
[*]支持多语言(包括中文)
[*]免费开源
[*]自动发现服务器与网络设备
[*]分布式监视以及WEB集中管理功能
[*]可以无agent监视
[*]用户安全认证和柔软的授权方式
[*]通过WEB界面设置或查看监视结果
[*]email等通知功能
功能:
[*]CPU负荷
[*]内存使用
-磁盘使用
[*]网络状况
[*]端口监视
[*]日志监视
实验环境:CentOS7(两台:监控服务器、被监控端)
编译包:链接:https://pan.baidu.com/s/19DvMqz0s01ByYBQl79ptqw
提取码:ha42
具体实验步骤:
搭建监控服务器:
#关闭防火墙##
# systemctl stop firewalld.service
# 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.
# setenforce 0
--------安装LAMP-------------------------------------------------------
# yum install -y \
httpd \
mariadb-server mariadb \
php \
php-mysql \
php-gd \
libjpeg* \
php-ldap \
php-odbc \
php-pear \
php-xml \
php-xmlrpc \
php-mhash
# vim /etc/httpd/conf/httpd.conf
ServerName www.yun.com:80 ##95行
DirectoryIndex index.html index.php ##164行
# vim /etc/php.ini
date.timezone = PRC ##878行 设置中国时区(去掉分号,添加PRC)
# systemctl start httpd.service
# systemctl start mariadb.service
# netstat -ntap | egrep '(3306|80)'
tcp 0 0 0.0.0.0:3306 0.0.0.0: LISTEN 45660/mysqld
tcp6 0 0 :::80 ::: LISTEN 45388/httpd
# mysql_secure_installation
y
abc123 (自己设置密码)
abc123
n
n
n
y
##进入数据库
# mysql -uroot -p
Enter password: ##输入密码
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT all privileges ON . TO 'zabbix'@'%' IDENTIFIED BY 'admin123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
##测试
# cd /var/www/html/
# vim index.php
##浏览器访问服务器:192.168.120.181
http://i2.运维网.com/images/blog/201810/25/c98ac096118f5fe76b07ab6c2c4ef846.jpg
##测试完成后删除原来的测试语句
# vim index.php
##修改完成后,刷新网页
http://i2.运维网.com/images/blog/201810/25/dee8fd881af6c36a4618f1d799856669.jpg
##网页是Success的可以跳过一下问题(如果是Faill,请按以下步骤操作)##
-------------解决本地无法登录问题(可忽略)---------------------------
# mysql -uzabbix -p
Enter password:
ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)
##出错##
##解决方案:
##进入root用户数据库
# mysql -uroot -p
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| | cacti |
| root | cacti |
| | localhost |
| root | localhost |
+--------+-----------+
##出现空用户,删除空用户
MariaDB [(none)]> drop user ''@localhost;
Query OK, 0 rows affected (0.02 sec)
MariaDB [(none)]> drop user ''@cacti;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> select user,host from mysql.user;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| root | cacti |
| root | localhost |
+--------+-----------+
##空用户已删除
# mysql -uzabbix -p
Enter password:
MariaDB [(none)]>
##登录成功
----------------以下开始部署zabbix Server-------
# yum install php-bcmath php-mbstring -y
##会自动生成yum源文件,保证系统可以上网
# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
##安装
# yum install zabbix-server-mysql zabbix-web-mysql -y
##生成数据库文件,注意密码不要输成root的(是之前设置的admin123)
# zcat /usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz | mysql -uzabbix -pzabbixEnter password:
# grep -n '^' /etc/zabbix/zabbix_server.conf
38:LogFile=/var/log/zabbix/zabbix_server.log
49:LogFileSize=0
72:PidFile=/var/run/zabbix/zabbix_server.pid
82:SocketDir=/var/run/zabbix
101:DBName=zabbix
117:DBUser=zabbix
357:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
475:Timeout=4
518:AlertScriptsPath=/usr/lib/zabbix/alertscripts
529:ExternalScripts=/usr/lib/zabbix/externalscripts
565:LogSlowQueries=3000
# vim /etc/zabbix/zabbix_server.conf
DBPassword=admin123 ##125行
# vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai ##20行(修改时区)
------------------修正图表中文乱码---------------------
# vim /usr/share/zabbix/include/defines.inc.php
##shift:输入
:%s /graphfont/kaiti/g
##挂载软件包
# mkdir /abc
# mount.cifs //192.168.100.10/rhel7 /abc
Password for root@//192.168.100.10/rhel7:
# cd /abc/zabbix/
# ls
php-bcmath-5.4.16-42.el7.x86_64.rpmphp-mbstring-5.4.16-42.el7.x86_64.rpmSTKAITI.TTF
# cp STKAITI.TTF /usr/share/zabbix/fonts/
##启动服务
# systemctl start zabbix-server.service
# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
# netstat -anpt | grep zabbix
tcp 0 0 0.0.0.0:10051 0.0.0.0: LISTEN 46594/zabbix_server
tcp6 0 0 :::10051 ::: LISTEN 46594/zabbix_server
# systemctl restart httpd.service
http://192.168.120.181/zabbix///安装后登录 用户名Admin 密码:zabbix
http://i2.运维网.com/images/blog/201810/25/d356f5d777445c90a4cbbf85550126d7.jpg
http://i2.运维网.com/images/blog/201810/25/855040e80c1417476fee91773459e67b.jpg
http://i2.运维网.com/images/blog/201810/25/824b6809915536ddecc0fe449ecfd9eb.jpg
http://i2.运维网.com/images/blog/201810/25/fb146b5100a7c2ee9b7768cca81a25b3.jpg
http://i2.运维网.com/images/blog/201810/25/0c635e8d5d74dcd9ce4d16f0c01d69f6.jpg
http://i2.运维网.com/images/blog/201810/25/fc38c31cd758b6d3a0f4ce57ad852f30.jpg
http://i2.运维网.com/images/blog/201810/25/cbc7584404a24cfd46148e9225f97d6f.jpg
设置中文环境
Administrator-Users-点击用户-语言中设置
http://i2.运维网.com/images/blog/201810/25/74c4b9a4056d0061d205e964782cd830.jpg
http://i2.运维网.com/images/blog/201810/25/8b7d052e4a7990ee0aa79548da5385d4.jpg
http://i2.运维网.com/images/blog/201810/25/73a162eaba1f41317b16acf8e1f50c7c.jpg
======配置代理端-就是被控服务器----如果服务器也需要被自己监控也需要安装--zabbix-agent=====
# systemctl stop firewalld.service
# 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.
# setenforce 0
##安装yum源
# rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
# yum install -y zabbix-agent
# vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.120.181 ##98行(IP为之前的监控服务器)
ServerActive=192.168.120.181 ##139行
Hostname=abc ##150行(名字自定义)
##启动服务
# systemctl start zabbix-agent.service
# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
# netstat -ntap | grep 10050
tcp 0 0 0.0.0.0:10050 0.0.0.0: LISTEN 45402/zabbix_agentd
tcp6 0 0 :::10050 ::: LISTEN 45402/zabbix_agentd
到网页设置 http://192.168.120.181/zabbix/
http://i2.运维网.com/images/blog/201810/25/2f2fb6d730e0b8e2eb070a139df83002.jpg
http://i2.运维网.com/images/blog/201810/25/8f088a0f8e5349a4c8be924f27197698.jpg
选择监控http、ssh(具体监控什么,自己定义)
http://i2.运维网.com/images/blog/201810/25/8d980405929aeb0220bec9187108b74e.jpg
http://i2.运维网.com/images/blog/201810/25/dcd1d2cf12516b1075b73f969b132706.jpg
http://i2.运维网.com/images/blog/201810/25/515960af2905f38aa5c70310df9c6643.jpg
搭建Zabbix及如何设置监控就详解到这了。
页:
[1]