Setting Total Data Size of MySQL

Why set a max size?

How can we do it?

ls /var/lib/mysql/ib* -al
-rw-r-----   1 mysql mysql 4294967296 May  9 21:36 ibdata1
-rw-r-----   1 mysql mysql 4294967296 May  9 21:36 ibdata2
-rw-r-----   1 mysql mysql 8589934592 May  9 21:36 ibdata3
-rw-rw----   1 mysql mysql   67108864 May  9 21:36 ib_logfile0
-rw-rw----   1 mysql mysql   67108864 May  9 21:36 ib_logfile1

What if we run out of space?

// FIND PROBLEM >>

mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.56
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysqlserver01-bin.000155
Read_Master_Log_Pos: 658288440
Relay_Log_File: mysqlserver02-relay-bin.1187043
Relay_Log_Pos: 612269140
Relay_Master_Log_File: mysqlserver01-bin.000155
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB: 
Replicate_Ignore_DB: 
Replicate_Do_Table: 
Replicate_Ignore_Table: 
Replicate_Wild_Do_Table: 
Replicate_Wild_Ignore_Table: 
Last_Errno: 1114
Last_Error: Could not execute Write_rows event on table my_database.my_table; The table 'my_table' is full, Error_code: 1114; handler error HA_ERR_RECORD_FILE_FULL; the event's master log mysqlserver01-bin.000155, end_log_pos 612269231
Skip_Counter: 0
Exec_Master_Log_Pos: 612268987
Relay_Log_Space: 658288807
Until_Condition: None
Until_Log_File: 
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File: 
Master_SSL_CA_Path: 
Master_SSL_Cert: 
Master_SSL_Cipher: 
Master_SSL_Key: 
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error: 
Last_SQL_Errno: 1114
Last_SQL_Error: Could not execute Write_rows event on table my_database.my_table; The table 'my_table' is full, Error_code: 1114; handler error HA_ERR_RECORD_FILE_FULL; the event's master log mysqlserver01-bin.000155, end_log_pos 612269231
Replicate_Ignore_Server_Ids: 
Master_Server_Id: 1
1 row in set (0.00 sec)

Before we allow it to use more, we should make sure we have it!

cat /etc/my.cnf
[mysqld]
binlog_cache_size = 8M
binlog-format = row
datadir=/var/lib/mysql
default-storage-engine=InnoDB
event_scheduler = On
expire_logs_days = 3
innodb_autoextend_increment = 100M
innodb_buffer_pool_size = 7G
<b>innodb_data_file_path = ibdata1:4G;ibdata2:4G;ibdata3:8G;ibdata4:1G:autoextend:max:8G
</b>innodb_data_home_dir = /var/lib/mysql
innodb_log_files_in_group = 2
innodb_log_file_size = 64M
innodb_log_group_home_dir = /var/lib/mysql
join_buffer_size = 256K
key_buffer = 1G
log-bin=mysqlserver02-bin
log-slave-updates
log = /var/log/mysqld.log
log-error = /var/log/mysqld.error.log
max_allowed_packet = 64M
max-binlog-size = 5G
max_connections = 1000
max_heap_table_size = 256M
max-relay-log-size = 5G
query_cache_limit = 2M
query_cache_size = 128M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
relay-log=mysqlserver02-relay-bin
relay-log-space-limit = 10G
report-host = mysqlserver02
server-id = 2
skip-name-resolve
slave-net-timeout = 10
slave-skip-errors = 0,121,126,1062,1213,1158,1053,1007,1452,1032
socket=/var/lib/mysql/mysql.sock
sort_buffer_size = 4M
table_cache = 1250
table_definition_cache = 5000
thread_cache_size = 64
tmp_table_size = 256M
wait_timeout = 120

[mysqldump]
max_allowed_packet = 160M

[mysql.server]
user = mysql

[mysqld_safe]
err-log=/var/log/mysqld.log

/etc/init.d/mysql restart ERROR! MySQL server PID file could not be found! Starting MySQL........... SUCCESS!

mysql -u root -p

Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 55 Server version: 5.5.23-log MySQL Community Server (GPL)

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show slave status\G 1. row Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.56 Master_User: repluser Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysqlserver01-bin.000155 Read_Master_Log_Pos: 662948226 Relay_Log_File: mysqlserver02-relay-bin.1187043 Relay_Log_Pos: 641453172 Relay_Master_Log_File: mysqlserver01-bin.000155 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 641453019 Relay_Log_Space: 662949036 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 1545 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 1 row in set (0.00 sec)