昨天导数据,今天早上check的时候发现数据还没导完,按平常的速度肯定是已经导完了,看了下日志发现下面内容,说明磁盘满了,腾出空间之后程序继续运行,并且刚开始的一段时间非常块,推测是使用的bin日志的内容写入数据,而不是网络IO获取的,所以速度相当的块,估计是网络IO的十倍,短时间之后恢复正常,应该是bin日志的数据导入完毕,继续网络I/O:
15660 --- Cause: java.sql.SQLException: Disk is full writing './mysql-bin.000029' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
15661 at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:107)
15662 at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)
15663 at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
15664 at org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:399)
15665 at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
15666 ... 7 more
15667 Caused by: java.sql.SQLException: Disk is full writing './mysql-bin.000029' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
15668 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
15669 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4098)
15670 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4030)
15671 at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
15672 at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
15673 at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2677)
15674 at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2134)
15675 at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1369)
15676 at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
15677 at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
15678 at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:80)
15679 at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)
15680 at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)
今天插入了大量的数据到数据库,结果查到一半不动了。比较奇怪,查了磁盘,结果显示满了:
[testuser@rendering mysql]$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda1 ext3 24G 23G 0 100% /
/dev/sda3 ext3 420G 46G 353G 12% /export
tmpfs tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs tmpfs 963M 3.0M 960M 1% /var/lib/ganglia/rrds
glusterfs#rendering:/test413
fuse 16G 4.6G 9.9G 32% /mnt/test413
glusterfs#rendering:/shareweb
fuse 32G 26G 3.9G 88% /mnt/shareweb
glusterfs#rendering:/iozonetest
fuse 1.3T 65G 1.2T 6% /mnt/iozonetest
glusterfs#rendering:/iozonetestreplicated
fuse 432G 9.8G 400G 3% /mnt/iozonetestreplicated
查看了mysql 的日记的地点:
mysql> show variables like '%log%';
+-----------------------------------------+------------------------------------------+
| Variable_name | Value |
+-----------------------------------------+------------------------------------------+
| back_log | 50 |
| binlog_cache_size | 32768 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_format | STATEMENT |
| binlog_stmt_cache_size | 32768 |
| expire_logs_days | 0 |
| general_log | OFF |
| general_log_file | /var/lib/mysql/rendering.log |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_buffer_size | 8388608 |
| innodb_log_file_size | 5242880 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_mirrored_log_groups | 1 |
| log | OFF |
| log_bin | ON |
| log_bin_trust_function_creators | OFF |
| log_error | /var/lib/mysql/rendering.scut.edu.cn.err |
| log_output | FILE |
| log_queries_not_using_indexes | OFF |
| log_slave_updates | OFF |
| log_slow_queries | OFF |
| log_warnings | 1 |
| max_binlog_cache_size | 18446744073709547520 |
| max_binlog_size | 1073741824 |
| max_binlog_stmt_cache_size | 18446744073709547520 |
| max_relay_log_size | 0 |
| relay_log | mysql-relay-bin |
| relay_log_index | |
| relay_log_info_file | relay-log.info |
| relay_log_purge | ON |
| relay_log_recovery | OFF |
| relay_log_space_limit | 0 |
| slow_query_log | OFF |
| slow_query_log_file | /var/lib/mysql/rendering-slow.log |
| sql_log_bin | ON |
| sql_log_off | OFF |
| sync_binlog | 0 |
| sync_relay_log | 0 |
| sync_relay_log_info | 0 |
+-----------------------------------------+------------------------------------------+
41 rows in set (0.00 sec)
查看错误日记:(果然是磁盘慢了的原因,磁盘满了,mysql默认会隔一定时间去重试看是有空间写入)
vi /var/lib/mysql/rendering.scut.edu.cn.err
120508 15:40:03 [ERROR] /usr/sbin/mysqld: Disk is full writing './mysql-bin.000008' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
120508 15:40:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 15:50:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 16:00:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 16:10:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 16:20:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 16:30:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 16:40:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 16:50:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 17:00:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 17:10:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 17:20:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 17:30:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 17:40:03 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 17:45:03 [ERROR] Error writing file 'mysql-bin' (errno: 28)
120508 17:47:04 [Warning] IP address '121.12.125.104' could not be resolved: Name or service not known
120508 17:55:59 [ERROR] /usr/sbin/mysqld: Disk is full writing './mysql-bin.000008' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
120508 17:55:59 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
120508 18:05:59 [ERROR] /usr/sbin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
查看mysql 数据的位置:
mysql> show variables like '%dir%';
+-----------------------------------------+----------------------------+
| Variable_name | Value |
+-----------------------------------------+----------------------------+
| basedir | /usr |
| binlog_direct_non_transactional_updates | OFF |
| character_sets_dir | /usr/share/mysql/charsets/ |
| datadir | /var/lib/mysql/ |
| innodb_data_home_dir | |
| innodb_log_group_home_dir | ./ |
| innodb_max_dirty_pages_pct | 75 |
| lc_messages_dir | /usr/share/mysql/ |
| plugin_dir | /usr/lib64/mysql/plugin/ |
| slave_load_tmpdir | /tmp |
| tmpdir | /tmp |
+-----------------------------------------+----------------------------+
11 rows in set (0.00 sec)
到mysql的数据目录去查看哪些文件占用了最多的空间:
[root@rendering mysql]# ls -alh
total 9.8G
drwxr-xr-x 9 mysql mysql 4.0K May 8 14:30 .
drwxr-xr-x 37 root root 4.0K May 3 13:13 ..
-rw-rw---- 1 mysql mysql 1.8G May 8 17:45 ibdata1
-rw-rw---- 1 mysql mysql 5.0M May 8 17:45 ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M May 8 17:45 ib_logfile1
drwx------ 2 mysql mysql 4.0K Apr 20 23:55 mysql
-rw-rw---- 1 mysql mysql 1.1G Apr 29 19:20 mysql-bin.000001
-rw-rw---- 1 mysql mysql 1.1G Apr 29 20:28 mysql-bin.000002
-rw-rw---- 1 mysql mysql 1.1G Apr 29 21:37 mysql-bin.000003
-rw-rw---- 1 mysql mysql 1.1G May 5 14:10 mysql-bin.000004
-rw-rw---- 1 mysql mysql 1.1G May 5 15:18 mysql-bin.000005
-rw-rw---- 1 mysql mysql 1.1G May 5 16:26 mysql-bin.000006
-rw-rw---- 1 mysql mysql 1.1G May 8 14:30 mysql-bin.000007
-rw-rw---- 1 mysql mysql 1002M May 8 17:45 mysql-bin.000008
-rw-rw---- 1 mysql mysql 152 May 8 14:30 mysql-bin.index
srwxrwxrwx 1 mysql mysql 0 Apr 21 23:41 mysql.sock
-rw-r--r-- 1 root root 6 Apr 20 23:55 mysql_upgrade_info
drwx------ 2 mysql mysql 4.0K Apr 20 23:55 performance_schema
-rw-rw---- 1 mysql root 32K May 8 17:47 rendering.scut.edu.cn.err
-rw-rw---- 1 mysql mysql 5 Apr 21 23:41 rendering.scut.edu.cn.pid
-rw-r--r-- 1 mysql mysql 698 Apr 20 16:55 RPM_UPGRADE_HISTORY
-rw-r--r-- 1 mysql mysql 349 Apr 20 16:55 RPM_UPGRADE_MARKER-LAST
drwx------ 2 mysql mysql 4.0K May 8 14:27 scutdb
drwx------ 2 mysql mysql 4.0K Apr 4 00:08 silverlight
drwx------ 2 mysql mysql 4.0K Apr 30 13:06 taa
drwx------ 2 mysql mysql 4.0K Mar 30 10:30 test
drwx------ 2 mysql mysql 4.0K Apr 21 00:07 test_partition
可见是mysql-bin占了大头,mysql-bin是主从复制时产生的bin日记(在从服务器上还有relay-bin日记)。先把这些日记删掉:
reset master;
其后log-bin被删除。
数据库的数据是在MyISAM引擎是在 .MYD 文件中,在InnoDB 则由指定:| innodb_data_file_path | ibdata1:10M:autoextend | (表结构都是 .FRM)
mysql> show variables like '%InnoDB%'
-> ;
+---------------------------------+------------------------+
| Variable_name | Value |
+---------------------------------+------------------------+
| have_innodb | YES |
| ignore_builtin_innodb | OFF |
| innodb_adaptive_flushing | ON |
| innodb_adaptive_hash_index | ON |
| innodb_additional_mem_pool_size | 8388608 |
| innodb_autoextend_increment | 8 |
| innodb_autoinc_lock_mode | 1 |
| innodb_buffer_pool_instances | 1 |
| innodb_buffer_pool_size | 134217728 |
| innodb_change_buffering | all |
| innodb_checksums | ON |
| innodb_commit_concurrency | 0 |
| innodb_concurrency_tickets | 500 |
| innodb_data_file_path | ibdata1:10M:autoextend |
--转自