안녕하세요...
MySQL 관련 문의 사항이 있어서 글 올립니다.
현재 저희 사이트는 MySQL NDB Cluster로 구성되어 있으며 Variable은 아래 표의 내용과 같습니다
초기 시스템 오픈할때는 별 문제가 없었는데요...한달 정도 운영 후에 데이터가 5만건 이상인 테이블의 데이터를 SELECT 하게되면 속도가 현저히 떨어지는 현상이 발생 했습니다.
테스트 DB는 InnoDB로 되어있으며 동일한 데티어량의 동일한 쿼리로 조회했을 경우 운영DB에서 30초 가량 걸리는 SELECT SQL 문장이 0.5초 이내로 나옵니다.
테스트를 MySQL NDBCluster 환경에서 진행했어야 하나 여러 사정이 생겨서 진행을 못했더니 이런 문제가 발생을 하네요...
느낌상 buffer_pool 변수나 Qcache가 문제가 될것 같은데....정확히 잘 모르겠어서 글 올립니다.
Variable_name |
Value |
Aborted_clients |
11540 |
Aborted_connects |
46 |
Binlog_cache_disk_use |
8233 |
Binlog_cache_use |
1563544 |
Bytes_received |
3117278586 |
Bytes_sent |
78116928749 |
Com_admin_commands |
2080598 |
Com_assign_to_keycache |
0 |
Com_alter_db |
0 |
Com_alter_db_upgrade |
0 |
Com_alter_event |
0 |
Com_alter_function |
0 |
Com_alter_procedure |
0 |
Com_alter_server |
0 |
Com_alter_table |
267 |
Com_alter_tablespace |
53 |
Com_analyze |
0 |
Com_backup_table |
0 |
Com_begin |
1838 |
Com_binlog |
0 |
Com_call_procedure |
23522 |
Com_change_db |
36127 |
Com_change_master |
0 |
Com_check |
0 |
Com_checksum |
0 |
Com_commit |
2769415 |
Com_create_db |
0 |
Com_create_event |
0 |
Com_create_function |
11 |
Com_create_index |
0 |
Com_create_procedure |
174 |
Com_create_server |
0 |
Com_create_table |
112 |
Com_create_trigger |
0 |
Com_create_udf |
0 |
Com_create_user |
0 |
Com_create_view |
3 |
Com_dealloc_sql |
1066 |
Com_delete |
27918 |
Com_delete_multi |
0 |
Com_do |
0 |
Com_drop_db |
0 |
Com_drop_event |
0 |
Com_drop_function |
11 |
Com_drop_index |
0 |
Com_drop_procedure |
268 |
Com_drop_server |
0 |
Com_drop_table |
138 |
Com_drop_trigger |
0 |
Com_drop_user |
0 |
Com_drop_view |
9 |
Com_empty_query |
0 |
Com_execute_sql |
1066 |
Com_flush |
6 |
Com_grant |
0 |
Com_ha_close |
0 |
Com_ha_open |
0 |
Com_ha_read |
0 |
Com_help |
0 |
Com_insert |
2443812 |
Com_insert_select |
33039 |
Com_install_plugin |
0 |
Com_kill |
3824 |
Com_load |
0 |
Com_load_master_data |
0 |
Com_load_master_table |
0 |
Com_lock_tables |
6576 |
Com_optimize |
0 |
Com_preload_keys |
0 |
Com_prepare_sql |
1066 |
Com_purge |
0 |
Com_purge_before_date |
0 |
Com_release_savepoint |
0 |
Com_rename_table |
0 |
Com_rename_user |
0 |
Com_repair |
0 |
Com_replace |
0 |
Com_replace_select |
116 |
Com_reset |
0 |
Com_restore_table |
0 |
Com_revoke |
0 |
Com_revoke_all |
0 |
Com_rollback |
177605 |
Com_rollback_to_savepoint |
0 |
Com_savepoint |
0 |
Com_select |
18942162 |
Com_set_option |
11362789 |
Com_show_authors |
0 |
Com_show_binlog_events |
0 |
Com_show_binlogs |
0 |
Com_show_charsets |
0 |
Com_show_collations |
179380 |
Com_show_column_types |
0 |
Com_show_contributors |
0 |
Com_show_create_db |
0 |
Com_show_create_event |
0 |
Com_show_create_func |
64 |
Com_show_create_proc |
2053 |
Com_show_create_table |
17128 |
Com_show_create_trigger |
0 |
Com_show_databases |
570 |
Com_show_engine_logs |
0 |
Com_show_engine_mutex |
0 |
Com_show_engine_status |
2479211 |
Com_show_events |
0 |
Com_show_errors |
0 |
Com_show_fields |
21254 |
Com_show_function_status |
254 |
Com_show_grants |
0 |
Com_show_keys |
221 |
Com_show_master_status |
9 |
Com_show_new_master |
0 |
Com_show_open_tables |
2 |
Com_show_plugins |
0 |
Com_show_privileges |
0 |
Com_show_procedure_status |
266 |
Com_show_processlist |
1749161 |
Com_show_profile |
0 |
Com_show_profiles |
0 |
Com_show_slave_hosts |
9 |
Com_show_slave_status |
0 |
Com_show_status |
4852368 |
Com_show_storage_engines |
14 |
Com_show_table_status |
14971 |
Com_show_tables |
6638 |
Com_show_triggers |
14830 |
Com_show_variables |
806881 |
Com_show_warnings |
35 |
Com_slave_start |
0 |
Com_slave_stop |
0 |
Com_stmt_close |
1066 |
Com_stmt_execute |
1066 |
Com_stmt_fetch |
0 |
Com_stmt_prepare |
1066 |
Com_stmt_reprepare |
0 |
Com_stmt_reset |
0 |
Com_stmt_send_long_data |
0 |
Com_truncate |
13 |
Com_uninstall_plugin |
0 |
Com_unlock_tables |
6572 |
Com_update |
676640 |
Com_update_multi |
0 |
Com_xa_commit |
0 |
Com_xa_end |
0 |
Com_xa_prepare |
0 |
Com_xa_recover |
0 |
Com_xa_rollback |
0 |
Com_xa_start |
0 |
Compression |
OFF |
Connections |
190119 |
Created_tmp_disk_tables |
137614 |
Created_tmp_files |
483 |
Created_tmp_tables |
6076445 |
Delayed_errors |
0 |
Delayed_insert_threads |
0 |
Delayed_writes |
0 |
Flush_commands |
3 |
Handler_commit |
14116642 |
Handler_delete |
2126502 |
Handler_discover |
42 |
Handler_prepare |
74 |
Handler_read_first |
308805 |
Handler_read_key |
14670129 |
Handler_read_next |
18423200239 |
Handler_read_prev |
4974280 |
Handler_read_rnd |
106699732 |
Handler_read_rnd_next |
3518999145 |
Handler_rollback |
307756 |
Handler_savepoint |
0 |
Handler_savepoint_rollback |
0 |
Handler_update |
24374895 |
Handler_write |
1805819624 |
Innodb_buffer_pool_pages_data |
511 |
Innodb_buffer_pool_pages_dirty |
0 |
Innodb_buffer_pool_pages_flushed |
344599 |
Innodb_buffer_pool_pages_free |
0 |
Innodb_buffer_pool_pages_misc |
1 |
Innodb_buffer_pool_pages_total |
512 |
Innodb_buffer_pool_read_ahead_rnd |
536 |
Innodb_buffer_pool_read_ahead_seq |
27369 |
Innodb_buffer_pool_read_requests |
20347786 |
Innodb_buffer_pool_reads |
319711 |
Innodb_buffer_pool_wait_free |
0 |
Innodb_buffer_pool_write_requests |
3959277 |
Innodb_data_fsyncs |
10481 |
Innodb_data_pending_fsyncs |
0 |
Innodb_data_pending_reads |
0 |
Innodb_data_pending_writes |
0 |
Innodb_data_read |
11935223808 |
Innodb_data_reads |
355021 |
Innodb_data_writes |
299610 |
Innodb_data_written |
11671405568 |
Innodb_dblwr_pages_written |
344599 |
Innodb_dblwr_writes |
3746 |
Innodb_log_waits |
1 |
Innodb_log_write_requests |
809512 |
Innodb_log_writes |
3222 |
Innodb_os_log_fsyncs |
2987 |
Innodb_os_log_pending_fsyncs |
0 |
Innodb_os_log_pending_writes |
0 |
Innodb_os_log_written |
379415040 |
Innodb_page_size |
16384 |
Innodb_pages_created |
20520 |
Innodb_pages_read |
728335 |
Innodb_pages_written |
344599 |
Innodb_row_lock_current_waits |
0 |
Innodb_row_lock_time |
0 |
Innodb_row_lock_time_avg |
0 |
Innodb_row_lock_time_max |
0 |
Innodb_row_lock_waits |
0 |
Innodb_rows_deleted |
0 |
Innodb_rows_inserted |
1731614 |
Innodb_rows_read |
45087381 |
Innodb_rows_updated |
0 |
Key_blocks_not_flushed |
0 |
Key_blocks_unused |
0 |
Key_blocks_used |
6694 |
Key_read_requests |
10573357 |
Key_reads |
26341 |
Key_write_requests |
2559965 |
Key_writes |
1685212 |
Last_query_cost |
0 |
Max_used_connections |
267 |
Ndb_cluster_node_id |
21 |
Ndb_config_from_host |
XXX.XXX.XXX.XXX |
Ndb_config_from_port |
1186 |
Ndb_number_of_data_nodes |
2 |
Ndb_number_of_ready_data_nodes |
2 |
Ndb_connect_count |
0 |
Ndb_execute_count |
0 |
Ndb_scan_count |
0 |
Ndb_pruned_scan_count |
0 |
Ndb_cluster_connection_pool |
1 |
Ndb_conflict_fn_max |
0 |
Ndb_conflict_fn_old |
13 |
Not_flushed_delayed_rows |
0 |
Open_files |
58 |
Open_streams |
0 |
Open_table_definitions |
186 |
Open_tables |
659 |
Opened_files |
592495 |
Opened_table_definitions |
1378 |
Opened_tables |
135052 |
Prepared_stmt_count |
0 |
Qcache_free_blocks |
0 |
Qcache_free_memory |
0 |
Qcache_hits |
0 |
Qcache_inserts |
0 |
Qcache_lowmem_prunes |
0 |
Qcache_not_cached |
0 |
Qcache_queries_in_cache |
0 |
Qcache_total_blocks |
0 |
Queries |
46396864 |
Questions |
46085996 |
Rpl_status |
NULL |
Select_full_join |
71936 |
Select_full_range_join |
0 |
Select_range |
11855 |
Select_range_check |
0 |
Select_scan |
6620372 |
Slave_heartbeat_period |
0 |
Slave_open_temp_tables |
0 |
Slave_received_heartbeats |
0 |
Slave_retried_transactions |
0 |
Slave_running |
OFF |
Slow_launch_threads |
0 |
Slow_queries |
15361 |
Sort_merge_passes |
134 |
Sort_range |
2927792 |
Sort_rows |
126079764 |
Sort_scan |
314916 |
Ssl_accept_renegotiates |
0 |
Ssl_accepts |
0 |
Ssl_callback_cache_hits |
0 |
Ssl_cipher |
|
Ssl_cipher_list |
|
Ssl_client_connects |
0 |
Ssl_connect_renegotiates |
0 |
Ssl_ctx_verify_depth |
0 |
Ssl_ctx_verify_mode |
0 |
Ssl_default_timeout |
0 |
Ssl_finished_accepts |
0 |
Ssl_finished_connects |
0 |
Ssl_session_cache_hits |
0 |
Ssl_session_cache_misses |
0 |
Ssl_session_cache_mode |
NONE |
Ssl_session_cache_overflows |
0 |
Ssl_session_cache_size |
0 |
Ssl_session_cache_timeouts |
0 |
Ssl_sessions_reused |
0 |
Ssl_used_session_cache_entries |
0 |
Ssl_verify_depth |
0 |
Ssl_verify_mode |
0 |
Ssl_version |
|
Table_locks_immediate |
11861293 |
Table_locks_waited |
0 |
Tc_log_max_pages_used |
0 |
Tc_log_page_size |
0 |
Tc_log_page_waits |
0 |
Threads_cached |
115 |
Threads_connected |
21 |
Threads_created |
793 |
Threads_running |
1 |
Uptime |
6291615 |
Uptime_since_flush_status |
6291615 |
참고로 my.cnf 파일도 같이 올립니다.
[MYSQLD]
user=mysql
basedir=/usr
datadir=/usr/local/mysql/data
pid-file=/usr/local/mysql/logs/mysqld.pid
socket=/tmp/mysql.sock
port=3306
log-error=/usr/local/mysql/logs/error.log
log_warnings=1
character-set-server=utf8
default-storage-engine=ndbcluster
#ndb-cluster-connection-pool=1
ndbcluster
ndb-connectstring="XXX.XXX.XXX.XXX:1186,XXX.XXX.XXX.XXX:1186"
## Binary Log
log-bin=/usr/local/mysql/logs/mysql-bin
log-bin-index=/usr/local/mysql/logs/mybin.index
max-binlog-size=512M
sync-binlog=0
expire-logs-days=7
#LOGS
#log
## Solow Quriy Log
log-slow-queries=/usr/local/mysql/logs/slow-query.log
long-query-time=3
#log-queries-not-using-indexes
#log-slow-admin-statements
## OTHER THINGS, BUFFERS ETC
max_allowed_packet=1M
max-connections=4096
max_heap_table_size=512M
thread-cache-size=128
query-cache-type=0 ## Do not change this parameter.
query-cache-size=0 ## Do not change this parameter.
table-cache=1000
thread_concurrency=8
tmpdir=/usr/local/mysql/tmp
lower-case-table-names=1
# If you wnat to disable InnoDB, uncomment the following parameter.
# skip-innodb
## Tread Buffer
sort_buffer_size=5M
read_buffer_size=5M
join_buffer_size=5M
tmp_table_size=512M
##
[MYSQL_CLUSTER]
ndb-connectstring="XXX.XXX.XXX.XXX:1186,XXX.XXX.XXX.XXX:1186"
[MYSQL]
socket=/tmp/mysql.sock
default-character-set=utf8
[client]
socket=/tmp/mysql.sock
default-character-set=utf8 |