zabbix服务器运维命令

查看磁盘大小

复制代码
df -h
看挂载点是/的项目

看内存使用大小

bash 复制代码
free -h

查看cpu的大小和负载

bash 复制代码
top -c

查看库大小

bash 复制代码
mysql -u root -p
select table_schema as '数据库', sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)' from information_schema.tables where table_schema='zabbix';

查看表大小,删除视情况而定

bash 复制代码
use zaabix;
select table_schema as '数据库', table_name as '表名', table_rows as '记录数',truncate(data_length/1024/1024, 2) as '数据容量(MB)', truncate(index_length/1024/1024, 2) as '索引容量(MB)' from information_schema.tables order by data_length desc, index_length desc;

数据库备份

下面是一个创建shell脚本,目录,定时任务,可自行修改

powershell 复制代码
mkdir /root/mysqldump
vim /root/mysqldump/mysqldump.sh
将下面的脚本复制进去
powershell 复制代码
#!/bin/bash

# 设置数据库连接信息
DB_USER="root"
DB_PASSWORD="zabbix"
DB_NAME="zabbix"

# 设置备份目录和文件名格式
BACKUP_DIR="/root/mysqldump"
DATE=$(date +%Y%m%d)
FILENAME="$DB_NAME-$DATE.sql"

# 使用mysqldump备份数据库
mysqldump -u $DB_USER -p$DB_PASSWORD $DB_NAME > "$BACKUP_DIR/$FILENAME"

# 删除15天前的备份文件
find "$BACKUP_DIR" -type f -name "*.sql" -mtime +15 -exec rm {} \;
powershell 复制代码
crontab -e
0 1 * * * /root/mysqldump/mysqldump.sh >> /root/mysqldump/logfile.log 2>&1
#上面的意思是每天凌晨1点执行

一些网站

https://tool.lu/timestamp/ #查看时间戳
https://tool.lu/crontab/ #定时任务编辑器

相关推荐
Avan_菜菜8 小时前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
SelectDB1 天前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
zzzzzz3103 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode3 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
大树886 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠6 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质6 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
小宇宙Zz6 天前
Maven依赖冲突
java·服务器·maven
Inhand陈工6 天前
基于台达PLC与映翰通IG502的智慧水产养殖精准投喂与远程运维解决方案
运维·人工智能·物联网·阿里云·信息与通信