Zabbix概念基础知识:
- zabbix 是一个基于 Web 界面的分布式监视系统
- 由zabbix server 和zabbix agent两部分组成,zabbix server 监视 安装zabbix agent的服务器集群
- 能监视各种参数,迅速定位错误
一、监控对象
1.系统:对于cpu,内存,硬盘,进程等硬件进行监控,并可以用百分比和图形化显示方式展示
2.网络:对于流量,网络的使用情况
3.消息队列(Rabbit MQ等),web服务(nginx,tomcat),数据库(MYSQL)
4.应用层面:业务场景(订单,销售数量,出货量)
二、常用命令
systemctl start zabbix-server
systemctl stop zabbix-agent
free 查看内存
swapon -s 查看交换分区
df 查看磁盘使用情况
top 查看系统使用情况
uptime 查看cpu利用率
######百度一下
三、安装Zabbix (两台centos 7.9)
一台zabbix server 一台zabbix agent
安装步骤:
1.安装zabbix仓库
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
如果遇到:ssl证书凭证过期,If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).。。。。
那就使用,不检查凭证,
wget --no-check-certificate https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
不过这样得到的只是rpm包,还需要安装
命令是rpm -ivh zabbix-release-5.0-1.el7.noarch.rpm
2.安装Zabbix server ,Web前端,agent ###zabbix-agent 只需安装agent
yum install zabbix-server-mysql zabbix-agent (可以选择加上 -y)
遇到选择 全都选 y
####如果遇到了这个报错
Transaction check error:
file /etc/logrotate.d/zabbix-server from install of zabbix-server-mysql-5.0.29-1.el7.x86_64 conflicts with file from package zabbix50-server-5.0.21-1.el7.noarch
与之前的zabbix产生冲突
那就yum remove -y zabbix-server-mysql zabbix-agent
然后再运行一遍yum install zabbix-server-mysql zabbix-agent
3.安装zabbix前端,启用red-hat的软件集合
yum install -y centos-release-scl
编辑配置文件 vi /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1 ###启用 前端仓库
...
安装zabbix前端的包
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
4.创建初始数据库
yum 安装mariadb数据库
yum install -y mariadb-server.x86_64 (本来不想加x86,后来发现加上不容易报错)
启动服务mariadb
当然你也有可能启动失败数据库Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
查看日志:vi /var/log/mariadb/mariadb.log (看日志很方便)
接下看到报错,端口占用
直接搜,然后kill
netstat -apn | grep mysql (如果command not netstat ,就yum install -y net-tools)
kill -9 45698
kill -9 45735
接着重启mariadb就可以了
在数据库主机上运行以下代码。
# mysql -uroot 因为centos7自带mariadb 所以不需要密码,##mysql初始密码在日志里
mysql> create database zabbix character set utf8 collate utf8_bin; 创建数据库
mysql> create user zabbix@localhost identified by 'password'; 设置用户和密码
这里可能会报错ERROR 1396 (HY000): Operation CREATE USER failed for 'zabbix'@'localhost'
去网上找说是bug:
解决方法:
drop user zabbix@localhost;
flush privileges;
mysql> grant all privileges on zabbix.* to zabbix@localhost; 授权用户访问
mysql> quit; 退出
导入初始架构和数据,系统将提示您输入新创建的密码
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
5.
为Zabbix server配置数据库
编辑配置文件 /etc/zabbix/zabbix_server.conf
6.
为Zabbix前端配置PHP
编辑配置文件 /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/shanghai
7.
启动Zabbix server和agent进程
启动Zabbix server和agent进程,并为它们设置开机自启:
查看他们的状态status:
8.浏览器访问zabbix-server
服务都是ok
这里有时候会出现数据库连接失败 Unable to select configuration
如果检查配置没错,那就看看防火墙和selinux有没有关
一路next
################################### 默认用户名是Admin 密码:zabbix###########3
今天就到这里了,遇到了好多错误,将他记录在这里作为一份美好的回忆