1. zabbix监控:
1.1 Zabbix入门简介:
Zabbix是一个基于WEB界面的提供分布式系统监控的企业级的开源解决方案,Zabbix能监视各种网络参数,系统硬件参数,保证服务器系统的安全稳定的运行,并提供灵活的通知机制以让管理员快速定位并解决存在的各种问题。
1.1.1 zabbix优点:
-
支持自动发现服务器和网络设备;
-
分布式的监控体系和集中式的WEB管理;
-
支持主动监控和被动监控模式;
-
基于WEB的管理方法,支持自由的自定义事件和邮件、短信发送;
1.1.2 zabbix工作原理:
image-202107011153542491.2 zabbix平台构建:
### 环境:
Centos 7
nginx 1.16
mariadb 5.5
php 7.2
zabbix 5.0
-----------------------------------------------
### 121与122服务器都配置zabbix 5.0仓库:
yum install https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm -y</pre>
在121服务器中执行以下步骤:
1.2.1 部署数据库:
# 安装mariadb数据库:
[root@localhost ~]# yum install mariadb mariadb-server -y
# 启动数据库服务:
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 185
Server version: 5.5.68-MariaDB MariaDB Server
# 创建数据库:
MariaDB [(none)]> create database zabbix charset utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
# 授权
MariaDB [(none)]> grant all on zabbix.* to "zabbix"@localhost identified by "123456";
Query OK, 0 rows affected (0.00 sec)
# 刷新权限
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)</pre>
1.2.2 导入zabbix初始数据:
[root@localhost ~]# yum install zabbix-server-mysql -y
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p123456 zabbix</pre>
1.2.3 启动nginx、php:
yum install centos-release-scl -y
# 开启zabbix的frontend仓库:
vim /etc/yum.repos.d/zabbix.repo
...省略号
[zabbix-frontend]
name=Zabbix Official Repository frontend - $basearch
baseurl=http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/frontend
enabled=1
gpgcheck=1
...省略号
# 安装zabbix的代码包:
[root@localhost ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
# 修改nginx配置文件:
sed -i 's/default_server//' /etc/opt/rh/rh-nginx116/nginx/nginx.conf
sed -i '2s/#//' /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf
# 修改php配置文件:
sed -i '/listen.acl_users =/c listen.acl_users = apache,nginx' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
sed -i '/date.timezone/c php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
## 启动nginx、php服务:
systemctl start rh-nginx116-nginx rh-php72-php-fpm</pre>
1.2.4 启动zabbix-server:
# 修改配置文件:
sed -i '/DBPassword/c DBPassword = 123456' /etc/zabbix/zabbix_server.conf
# 启动:
systemctl start zabbix-server</pre>
1.2.5 配置zabbix安装向导:
image-20210701114159274 image-20210701114304709 image.png image-20210701114459896 image-20210701114534799 image-20210701114607124 image-20210701114734042 image-202107011147521921.2.6 部署被监控主机:
在122服务器中执行以下步骤:
# 配置仓库:
yum install https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm -y
# 安装客户端:
yum install zabbix-agent -y
# 修改zabbix-agent配置文件:
vim /etc/zabbix/zabbix_agentd.conf
[root@localhost ~]# grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.75.121
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf
# 启动zabbix-agent服务:
[root@localhost ~]# systemctl start zabbix-agent</pre>
1.3 WEB端添加监控主机:
image-20210701124320044 image-20210701124515313 image-20210701124733342 image-20210701124801921 image-20210701125053995欢迎点赞,收藏,你的喜欢就是我原创的动力,获取最新文章更新,以及常用软件,可以关注公众号: 笨办法学linux
网友评论