AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / server / Perguntas / 1171144
Accepted
Dmitriano
Dmitriano
Asked: 2025-01-20 07:52:45 +0800 CST2025-01-20 07:52:45 +0800 CST 2025-01-20 07:52:45 +0800 CST

O MySQL8 usa uma grande quantidade de espaço em disco

  • 772

Migrei 3 dos meus 11 bancos de dados do MySQL 5.7.44 no Ubuntu 16.04 para o MySQL 8.0.40 no Ubuntu 24.04.

O espaço usado na minha máquina antiga:

root@localhost:/var/lib/mysql# du -ha --max-depth=1
19M     ./bot
4.0K    ./private_key.pem
1.1M    ./performance_schema
48K     ./game
79M     ./master
4.0K    ./public_key.pem
4.0K    ./client-key.pem
4.0K    ./auto.cnf
5.0G    ./beauty
0       ./debian-5.7.flag
201M    ./devnote
11M     ./mysql
4.0K    ./ca.pem
8.0K    ./test
12M     ./mike1
12M     ./ibtmp1
176K    ./phpmyadmin
4.0K    ./server-cert.pem
680K    ./sys
48M     ./ib_logfile0
4.0K    ./ca-key.pem
127M    ./mike
4.0K    ./mysql_upgrade_info
4.0K    ./ib_buffer_pool
48M     ./ib_logfile1
4.0K    ./server-key.pem
186M    ./slogpost
76M     ./ibdata1
4.0K    ./client-cert.pem
41M     ./shar
5.9G    .

O espaço usado na minha nova máquina (os novos bancos de dados são beauty, shar, slogpost):

root@localhost:/var/lib/mysql# du -ha --max-depth=1
101M    ./#innodb_redo
101M    ./binlog.000161
101M    ./binlog.000069
101M    ./binlog.000008
101M    ./binlog.000095
101M    ./binlog.000082
101M    ./binlog.000047
4.0K    ./localhost.pid
4.0K    ./public_key.pem
101M    ./binlog.000075
36K     ./mysql
101M    ./binlog.000177
101M    ./binlog.000101
101M    ./binlog.000122
4.0K    ./server-key.pem
101M    ./binlog.000107
101M    ./binlog.000158
101M    ./binlog.000079
101M    ./binlog.000057
101M    ./binlog.000028
101M    ./binlog.000173
101M    ./binlog.000020
4.0K    ./binlog.index
101M    ./binlog.000112
101M    ./binlog.000121
101M    ./binlog.000139
101M    ./binlog.000142
101M    ./binlog.000152
101M    ./binlog.000060
101M    ./binlog.000136
101M    ./binlog.000010
101M    ./binlog.000045
101M    ./binlog.000077
101M    ./binlog.000125
101M    ./binlog.000168
101M    ./binlog.000169
101M    ./binlog.000119
101M    ./binlog.000007
101M    ./binlog.000176
101M    ./binlog.000127
101M    ./binlog.000066
4.0K    ./client-key.pem
101M    ./binlog.000123
101M    ./binlog.000099
101M    ./binlog.000143
101M    ./binlog.000118
4.0K    ./private_key.pem
101M    ./binlog.000070
101M    ./binlog.000145
101M    ./binlog.000030
4.0K    ./binlog.000002
19M     ./shar
4.0K    ./auto.cnf
101M    ./binlog.000116
101M    ./binlog.000160
101M    ./binlog.000156
101M    ./binlog.000148
101M    ./binlog.000097
101M    ./binlog.000043
101M    ./binlog.000140
101M    ./binlog.000042
101M    ./binlog.000063
101M    ./binlog.000015
101M    ./binlog.000050
0       ./debian-5.7.flag
101M    ./binlog.000003
101M    ./binlog.000180
8.2M    ./#ib_16384_1.dblwr
4.0K    ./binlog.000036
101M    ./binlog.000026
12M     ./ibtmp1
101M    ./binlog.000034
1.7M    ./performance_schema
16M     ./undo_002
101M    ./binlog.000023
101M    ./binlog.000071
101M    ./binlog.000033
32K     ./binlog.000038
101M    ./binlog.000011
76K     ./binlog.000039
101M    ./binlog.000110
101M    ./binlog.000017
101M    ./binlog.000012
101M    ./binlog.000032
101M    ./binlog.000165
101M    ./binlog.000086
101M    ./binlog.000157
183M    ./slogpost
2.3G    ./binlog.000133
101M    ./binlog.000056
101M    ./binlog.000019
101M    ./binlog.000022
2.3G    ./binlog.000183
101M    ./binlog.000073
101M    ./binlog.000138
101M    ./binlog.000009
101M    ./binlog.000067
101M    ./binlog.000181
101M    ./binlog.000013
101M    ./binlog.000162
101M    ./binlog.000088
101M    ./binlog.000120
101M    ./binlog.000054
101M    ./binlog.000064
8.6M    ./binlog.000035
101M    ./binlog.000085
101M    ./binlog.000144
101M    ./binlog.000091
101M    ./binlog.000061
101M    ./binlog.000141
4.0K    ./binlog.000135
101M    ./binlog.000109
101M    ./binlog.000103
101M    ./binlog.000132
101M    ./binlog.000094
101M    ./binlog.000151
101M    ./binlog.000076
101M    ./binlog.000149
101M    ./binlog.000104
101M    ./binlog.000163
101M    ./binlog.000027
101M    ./binlog.000114
116K    ./sys
101M    ./binlog.000182
8.0K    ./ib_buffer_pool
101M    ./binlog.000115
101M    ./binlog.000164
101M    ./binlog.000084
2.4G    ./beauty
101M    ./binlog.000016
101M    ./binlog.000153
101M    ./binlog.000172
101M    ./binlog.000041
101M    ./binlog.000174
101M    ./binlog.000100
8.0K    ./binlog.000185
101M    ./binlog.000113
101M    ./binlog.000046
101M    ./binlog.000178
101M    ./binlog.000124
101M    ./binlog.000074
101M    ./binlog.000105
101M    ./binlog.000179
28M     ./mysql.ibd
101M    ./binlog.000171
101M    ./binlog.000155
101M    ./binlog.000062
101M    ./binlog.000021
101M    ./binlog.000044
101M    ./binlog.000049
101M    ./binlog.000059
101M    ./binlog.000147
60K     ./binlog.000134
101M    ./binlog.000055
4.0K    ./binlog.000040
101M    ./binlog.000126
101M    ./binlog.000170
101M    ./binlog.000089
101M    ./binlog.000006
101M    ./binlog.000080
101M    ./binlog.000081
101M    ./binlog.000068
172K    ./binlog.000037
12M     ./ibdata1
101M    ./binlog.000146
101M    ./binlog.000031
101M    ./binlog.000129
101M    ./binlog.000150
4.0K    ./binlog.000001
804K    ./#innodb_temp
101M    ./binlog.000065
75M     ./binlog.000004
4.0K    ./ca-key.pem
101M    ./binlog.000025
101M    ./binlog.000108
4.0K    ./server-cert.pem
101M    ./binlog.000090
101M    ./binlog.000051
101M    ./binlog.000048
101M    ./binlog.000052
101M    ./binlog.000024
101M    ./binlog.000053
101M    ./binlog.000130
101M    ./binlog.000014
8.0K    ./binlog.000184
101M    ./binlog.000117
101M    ./binlog.000096
101M    ./binlog.000005
101M    ./binlog.000175
101M    ./binlog.000131
101M    ./binlog.000078
101M    ./binlog.000167
101M    ./binlog.000058
101M    ./binlog.000083
101M    ./binlog.000087
101M    ./binlog.000154
101M    ./binlog.000166
101M    ./binlog.000102
4.0K    ./client-cert.pem
101M    ./binlog.000128
4.0K    ./ca.pem
101M    ./binlog.000137
101M    ./binlog.000098
16M     ./undo_001
101M    ./binlog.000029
101M    ./binlog.000018
101M    ./binlog.000092
101M    ./binlog.000106
101M    ./binlog.000072
101M    ./binlog.000111
2.3G    ./binlog.000159
192K    ./#ib_16384_0.dblwr
101M    ./binlog.000093
27G     .

du -csh binlog* | tail -n 1
24G     total

(O banco de dados beautyna máquina antiga ocupa 5,0 G porque contém alguns dados extras)

11 bancos de dados na nova máquina ocupam 5,9 G, mas 3 bancos de dados na máquina antiga ocupam 27 G.

Por que tanto?

Para fazer backup de um banco de dados, eu simplesmente faço isso :

mysqldump -u $MUSER -h $MHOST -p$MPASS $MDB --no-tablespaces | sed -e 's/DEFINER=[^*]*\*/\*/' > $DBDUMP

para restaurar eu faço isso :

tar -Oxzf $ARCHIVE_FILE $DBDUMP | mysql -u $MUSER -h $MHOST -p$MPASS $MDB
mysql
  • 1 1 respostas
  • 65 Views

1 respostas

  • Voted
  1. Best Answer
    Rick James
    2025-01-22T03:00:15+08:002025-01-22T03:00:15+08:00
    binlog_expire_logs_seconds = 3600
    binlog_expire_logs_auto_purge = ON
    max_binlog_size = 1G
    

    Coloque-os em seu my.cnf, então reinicie o MySQL. Isso pode limpar a maioria dos arquivos em uma hora.

    Então considere o cenário

    log_bin = OFF
    

    e reiniciando. Em seguida, execute

    PURGE BINARY LOGS BEFORE NOW();
    

    Observe que sql_log_bin"controla se o registro no log binário está habilitado para a sessão atual (assumindo que o próprio log binário esteja habilitado)"

    Leia mais: https://dev.mysql.com/doc/refman/8.4/en/replication-options-binary-log.html#replication-sysvars-binlog

    (Espero que esta resposta cubra os detalhes ausentes nos comentários acima.)

    (dba.stackexchange.com é um lugar melhor para discutir a administração do MySQL/MariaDB.)

    • 1

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve