服务器规格:具有以下信息的VPS
model name : Intel(R) Xeon(R) CPU E5649 @ 2.53GHz
MemTotal: 2058776 kB
MemFree: 244436 kB
我们正在运行Invision Power Services的IP.Board,正在使用
innodb_file_per_table
并已重新加载数据库以减小ibdata1的大小。但是,尽管ibdata1
尺寸减小了,但最近我们仍然遇到CPU和I / O使用率高的问题。
根据我的检查,我认为这是由上较高的I / O使用率引起的ibdata1
。以下是我使用pt-ioprofile -cell sizes
(在Percona ToolKit中)获得的数据。基本上,这是30秒内收集的I / O总量。
# pt-ioprofile -cell sizes
Fri Jul 20 10:22:23 ICT 2012
Tracing process ID 8581
total pread read pwrite fsync open close getdents lseek fcntl filename
6995968 0 0 6995968 0 0 0 0 0 0 /db/mysql/ibdata1
1019904 0 0 1019904 0 0 0 0 0 0 /db/mysql/ib_logfile0
204800 204800 0 0 0 0 0 0 0 0 /db/mysql/admin_phpbb3forum/phpbb_posts.ibd
49152 49152 0 0 0 0 0 0 0 0 /db/mysql/admin_ips/ips_reputation_cache.ibd
32768 32768 0 0 0 0 0 0 0 0 /db/mysql/admin_ips/ips_reputation_totals.ibd
29808 0 0 0 0 0 0 29808 0 0 /db/mysql/admin_ips/
... (other trivial I/O records truncated)
跑步iotop
,我看到DISK WRITE:
那张上下左右2M/s
和200K/s
我的问题是,为什么我们有很高的I / O写上ibdata1
,并ib_logfileX
同时我们只有每秒约5-10小更新到我们的会话表,这也MEMORY
表(只大小约为300K)?令我感到困惑的是,在任何其他表文件上也没有等效的写I / O,这表明写I / O不是由引起的UPDATE/INSERT/DELETE
。
请注意,我只是一个偶然的程序员,有责任维护它,所以请随时询问更多信息。我已经对该服务器做了很多事情,但是请不要以为我已经做了我应该做的事情。
附加信息:
# ls -l /db/mysql/ib*
-rw-rw---- 1 mysql mysql 18874368 Jul 21 01:26 /db/mysql/ibdata1
-rw-rw---- 1 mysql mysql 134217728 Jul 21 01:26 /db/mysql/ib_logfile0
-rw-rw---- 1 mysql mysql 134217728 Jul 21 01:26 /db/mysql/ib_logfile1
和
mysql> SHOW VARIABLES LIKE 'innodb%';
+-------------------------------------------+------------------------+
| Variable_name | Value |
+-------------------------------------------+------------------------+
| innodb_adaptive_flushing | ON |
| innodb_adaptive_flushing_method | estimate |
| innodb_adaptive_hash_index | ON |
| innodb_adaptive_hash_index_partitions | 1 |
| innodb_additional_mem_pool_size | 20971520 |
| innodb_autoextend_increment | 8 |
| innodb_autoinc_lock_mode | 1 |
| innodb_blocking_buffer_pool_restore | OFF |
| innodb_buffer_pool_instances | 1 |
| innodb_buffer_pool_restore_at_startup | 0 |
| innodb_buffer_pool_shm_checksum | ON |
| innodb_buffer_pool_shm_key | 0 |
| innodb_buffer_pool_size | 402653184 |
| innodb_change_buffering | all |
| innodb_checkpoint_age_target | 0 |
| innodb_checksums | ON |
| innodb_commit_concurrency | 0 |
| innodb_concurrency_tickets | 500 |
| innodb_corrupt_table_action | assert |
| innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir | |
| innodb_dict_size_limit | 0 |
| innodb_doublewrite | ON |
| innodb_doublewrite_file | |
| innodb_fake_changes | OFF |
| innodb_fast_checksum | OFF |
| innodb_fast_shutdown | 1 |
| innodb_file_format | Barracuda |
| innodb_file_format_check | ON |
| innodb_file_format_max | Barracuda |
| innodb_file_per_table | ON |
| innodb_flush_log_at_trx_commit | 2 |
| innodb_flush_method | O_DIRECT |
| innodb_flush_neighbor_pages | 0 |
| innodb_force_load_corrupted | OFF |
| innodb_force_recovery | 0 |
| innodb_ibuf_accel_rate | 100 |
| innodb_ibuf_active_contract | 1 |
| innodb_ibuf_max_size | 201310208 |
| innodb_import_table_from_xtrabackup | 0 |
| innodb_io_capacity | 4000 |
| innodb_kill_idle_transaction | 0 |
| innodb_large_prefix | OFF |
| innodb_lazy_drop_table | 0 |
| innodb_lock_wait_timeout | 50 |
| innodb_locks_unsafe_for_binlog | OFF |
| innodb_log_block_size | 4096 |
| innodb_log_buffer_size | 4194304 |
| innodb_log_file_size | 134217728 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | ./ |
| innodb_max_dirty_pages_pct | 75 |
| innodb_max_purge_lag | 0 |
| innodb_mirrored_log_groups | 1 |
| innodb_old_blocks_pct | 37 |
| innodb_old_blocks_time | 0 |
| innodb_open_files | 300 |
| innodb_page_size | 16384 |
| innodb_purge_batch_size | 20 |
| innodb_purge_threads | 1 |
| innodb_random_read_ahead | OFF |
| innodb_read_ahead | linear |
| innodb_read_ahead_threshold | 56 |
| innodb_read_io_threads | 24 |
| innodb_recovery_stats | OFF |
| innodb_recovery_update_relay_log | OFF |
| innodb_replication_delay | 0 |
| innodb_rollback_on_timeout | OFF |
| innodb_rollback_segments | 128 |
| innodb_show_locks_held | 10 |
| innodb_show_verbose_locks | 0 |
| innodb_spin_wait_delay | 6 |
| innodb_stats_auto_update | 0 |
| innodb_stats_method | nulls_equal |
| innodb_stats_on_metadata | OFF |
| innodb_stats_sample_pages | 8 |
| innodb_stats_update_need_lock | 1 |
| innodb_strict_mode | OFF |
| innodb_support_xa | ON |
| innodb_sync_spin_loops | 30 |
| innodb_table_locks | ON |
| innodb_thread_concurrency | 0 |
| innodb_thread_concurrency_timer_based | OFF |
| innodb_thread_sleep_delay | 10000 |
| innodb_use_global_flush_log_at_trx_commit | ON |
| innodb_use_native_aio | ON |
| innodb_use_sys_malloc | ON |
| innodb_use_sys_stats_table | OFF |
| innodb_version | 1.1.8-rel27.1 |
| innodb_write_io_threads | 24 |
+-------------------------------------------+------------------------+
90 rows in set (0.00 sec)
来自@RolandoMySQLDBA:请运行
SET @TimeInterval = 300;
SELECT variable_value INTO @num1 FROM information_schema.global_status
WHERE variable_name = 'Innodb_os_log_written';
SELECT SLEEP(@TimeInterval);
SELECT variable_value INTO @num2 FROM information_schema.global_status
WHERE variable_name = 'Innodb_os_log_written';
SET @ByteWrittenToLog = @num2 - @num1;
SET @KB_WL = @ByteWrittenToLog / POWER(1024,1) * 3600 / @TimeInterval;
SET @MB_WL = @ByteWrittenToLog / POWER(1024,2) * 3600 / @TimeInterval;
SET @GB_WL = @ByteWrittenToLog / POWER(1024,3) * 3600 / @TimeInterval;
SELECT @KB_WL,@MB_WL,@GB_WL;
并显示输出。这将告诉您在接下来的5分钟内每小时将多少字节写入ib_logfile0 / ib_logfile1。
在SQL查询结果之上(本地时间上午8点,而在线成员大约是当天统计的25%):
mysql> SELECT @KB_WL,@MB_WL,@GB_WL;
+--------+----------+-------------------+
| @KB_WL | @MB_WL | @GB_WL |
+--------+----------+-------------------+
| 95328 | 93.09375 | 0.090911865234375 |
+--------+----------+-------------------+
1 row in set (0.00 sec)
SHOW VARIABLES LIKE 'innodb%';
并在您的问题中显示该内容!!!
ls -l /var/lib/mysql/ib*
我要查看文件大小。我还需要知道您正在运行哪个版本的MySQL,以及是否所有数据都是InnoDB。