56.MySQL-Utilities工具包之-mysqldiskusage

文章展示了如何使用命令行工具检查MySQL服务器的磁盘使用情况,包括各个数据库的大小、日志文件(如错误日志和二进制日志)的大小以及InnoDB表空间的信息。通过这些信息,可以了解数据库的存储状况并进行性能优化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

--查看MYSQL磁盘使用率。
--查看每个数据库的大小。
[root@mysql1 mysql]# mysqldiskusage --server=root:rootroot@192.168.1.51:3306
WARNING: Using a password on the command line interface can be insecure.
# Source on 192.168.1.51: ... connected.
# Database totals:
+---------------------+-------------+
| db_name             |      total  |
+---------------------+-------------+
| mysql               | 12,090,404  |
| performance_schema  | 822,167     |
| sys                 | 480,322     |
| test                | 107,009     |
+---------------------+-------------+
Total database disk usage = 13,499,902 bytes or 12.87 MB
#...done.

--查看数据库和日志的大小。
1.数据库,
2.错误日志
3.binlog
4.重做日志文件
5.共享表空间大小

[root@mysql1 mysql]# mysqldiskusage --server=root:rootroot@192.168.1.51:3306 --format=g -a -vvv
WARNING: Using a password on the command line interface can be insecure.
# Source on 192.168.1.51: ... connected.
# Database totals:
+---------------------+--------------+------------+-------------+-------------+
| db_name             | db_dir_size  | data_size  | misc_files  |      total  |
+---------------------+--------------+------------+-------------+-------------+
| mysql               | 12,090,404   | 2,560,843  | 271,123     | 12,090,404  |
| performance_schema  | 822,167      | 0          | 822,167     | 822,167     |
| sys                 | 480,322      | 16,384     | 382,018     | 480,322     |
| test                | 107,009      | 16,384     | 8,705       | 107,009     |
+---------------------+--------------+------------+-------------+-------------+
Total database disk usage = 13,499,902 bytes or 12.87 MB

# Log information.
# The general_log is turned off on the server.
# The slow_query_log is turned off on the server.
+----------------+----------+
| log_name       |    size  |
+----------------+----------+
| mysql3306.log  | 651,360  |
+----------------+----------+
Total size of logs = 651,360 bytes or 636.09 KB

# Binary log information:
Current binary log file = mysql-binlog.000086
+----------------------+--------+
| log_file             | size   |
+----------------------+--------+
| mysql-binlog.000074  | 244    |
| mysql-binlog.000075  | 244    |
| mysql-binlog.000076  | 244    |
| mysql-binlog.000077  | 217    |
| mysql-binlog.000078  | 11132  |
| mysql-binlog.000079  | 244    |
| mysql-binlog.000080  | 244    |
| mysql-binlog.000081  | 244    |
| mysql-binlog.000082  | 905    |
| mysql-binlog.000083  | 244    |
| mysql-binlog.000084  | 537    |
| mysql-binlog.000085  | 217    |
| mysql-binlog.000086  | 194    |
| mysql-binlog.index   | 507    |
+----------------------+--------+
Total size of binary logs = 15,417 bytes or 15.06 KB
# Server is not an active slave - no relay log information.
# InnoDB tablespace information:
+--------------+-------------+--------------------+-------------------------+
| innodb_file  |       size  | type               | specificaton            |
+--------------+-------------+--------------------+-------------------------+
| ib_logfile0  | 50,331,648  | log file           |                         |
| ib_logfile1  | 50,331,648  | log file           |                         |
| ibdata1      | 79,691,776  | shared tablespace  | ibdata1:12M:autoextend  |
+--------------+-------------+--------------------+-------------------------+
Total size of InnoDB files = 180,355,072 bytes or 172.00 MB
#...done.

总结: 

可以看到这个工具巡检还是非常方便的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值