2010-01-26 6 views
4

저는 한 달에 약 4 백만 페이지 뷰를 생성하는 프로덕션 서버를 가지고 있습니다. 서버에는 8GB의 RAM이 있고 mysql은 데이터베이스로 작동합니다.mysql은 결코 메모리를 해제하지 않습니다.

이로드를 처리하기 위해 mysql을 처리하는 데 문제가 있습니다. 이 일을 처리하려면 하루에 두 번 mysql을 다시 시작해야합니다. mysql의 문제점은 특정 직업으로 시작한다는 것인데, mysql이 소비하는 메모리는 소비 할 수있는 최대 값에 도달 할 때까지 계속 증가하고 mysql은 느리게 응답하지 않거나 전혀 응답하지 않아 서버를 정지시킵니다.

내 모든 테이블의 색인이 제대로 작성되어 있으며 긴 검색어가 없습니다. 여기에 할 일을 디버깅하는 방법에 대해 도움이 필요한 사람이 필요합니다.

내 모든 테이블은 myisam입니다.

필자는 key_buffer 매개 변수 등을 구성하려고 시도했지만 구조는하지 않았습니다. 어떤 종류의 도움이라도 대단히 감사합니다. 다음은 도움이되는 매개 변수입니다.

mysql --version 
mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (i686) using readline 5.1 


mysql> show variables; 
+---------------------------------+------------------------------------------------------------+ 
| Variable_name     | Value              | 
+---------------------------------+------------------------------------------------------------+ 
| auto_increment_increment  | 1               | 
| auto_increment_offset   | 1               | 
| automatic_sp_privileges   | ON               | 
| back_log      | 50               | 
| basedir       | /usr/              | 
| bdb_cache_size     | 8384512             | 
| bdb_home      | /var/lib/mysql/           | 
| bdb_log_buffer_size    | 262144              | 
| bdb_logdir      |               | 
| bdb_max_lock     | 10000              | 
| bdb_shared_data     | OFF              | 
| bdb_tmpdir      | /tmp/              | 
| binlog_cache_size    | 32768              | 
| bulk_insert_buffer_size   | 8388608             | 
| character_set_client   | latin1              | 
| character_set_connection  | latin1              | 
| character_set_database   | latin1              | 
| character_set_filesystem  | binary              | 
| character_set_results   | latin1              | 
| character_set_server   | latin1              | 
| character_set_system   | utf8              | 
| character_sets_dir    | /usr/share/mysql/charsets/         | 
| collation_connection   | latin1_swedish_ci           | 
| collation_database    | latin1_swedish_ci           | 
| collation_server    | latin1_swedish_ci           | 
| completion_type     | 0               | 
| concurrent_insert    | 1               | 
| connect_timeout     | 10               | 
| datadir       | /var/lib/mysql/           | 
| date_format      | %Y-%m-%d             | 
| datetime_format     | %Y-%m-%d %H:%i:%s           | 
| default_week_format    | 0               | 
| delay_key_write     | ON               | 
| delayed_insert_limit   | 100              | 
| delayed_insert_timeout   | 300              | 
| delayed_queue_size    | 1000              | 
| div_precision_increment   | 4               | 
| keep_files_on_create   | OFF              | 
| engine_condition_pushdown  | OFF              | 
| expire_logs_days    | 0               | 
| flush       | OFF              | 
| flush_time      | 0               | 
| ft_boolean_syntax    | + -><()~*:""&|            | 
| ft_max_word_len     | 84               | 
| ft_min_word_len     | 4               | 
| ft_query_expansion_limit  | 20               | 
| ft_stopword_file    | (built-in)             | 
| group_concat_max_len   | 1024              | 
| have_archive     | NO               | 
| have_bdb      | YES              | 
| have_blackhole_engine   | NO               | 
| have_compress     | YES              | 
| have_crypt      | YES              | 
| have_csv      | NO               | 
| have_dynamic_loading   | YES              | 
| have_example_engine    | NO               | 
| have_federated_engine   | NO               | 
| have_geometry     | YES              | 
| have_innodb      | YES              | 
| have_isam      | NO               | 
| have_merge_engine    | YES              | 
| have_ndbcluster     | NO               | 
| have_openssl     | DISABLED             | 
| have_ssl      | DISABLED             | 
| have_query_cache    | YES              | 
| have_raid      | NO               | 
| have_rtree_keys     | YES              | 
| have_symlink     | YES              |           | 
| init_connect     |               | 
| init_file      |               | 
| init_slave      |               | 
| interactive_timeout    | 28800              | 
| join_buffer_size    | 131072              | 
| key_buffer_size     | 2621440000             | 
| key_cache_age_threshold   | 300              | 
| key_cache_block_size   | 1024              | 
| key_cache_division_limit  | 100              | 
| language      | /usr/share/mysql/english/         | 
| large_files_support    | ON               | 
| large_page_size     | 0               | 
| large_pages      | OFF              | 
| lc_time_names     | en_US              | 
| license       | GPL              | 
| local_infile     | ON               | 
| locked_in_memory    | OFF              | 
| log        | OFF              | 
| log_bin       | ON               | 
| log_bin_trust_function_creators | OFF              | 
| log_error      |               | 
| log_queries_not_using_indexes | OFF              | 
| log_slave_updates    | OFF              | 
| log_slow_queries    | ON               | 
| log_warnings     | 1               | 
| long_query_time     | 8               | 
| low_priority_updates   | OFF              | 
| lower_case_file_system   | OFF              | 
| lower_case_table_names   | 0               | 
| max_allowed_packet    | 8388608             | 
| max_binlog_cache_size   | 4294963200             | 
| max_binlog_size     | 1073741824             | 
| max_connect_errors    | 10               | 
| max_connections     | 400              | 
| max_delayed_threads    | 20               | 
| max_error_count     | 64               | 
| max_heap_table_size    | 16777216             | 
| max_insert_delayed_threads  | 20               | 
| max_join_size     | 4294967295             | 
| max_length_for_sort_data  | 1024              | 
| max_prepared_stmt_count   | 16382              | 
| max_relay_log_size    | 0               | 
| max_seeks_for_key    | 4294967295             | 
| max_sort_length     | 1024              | 
| max_sp_recursion_depth   | 0               | 
| max_tmp_tables     | 32               | 
| max_user_connections   | 0               | 
| max_write_lock_count   | 4294967295             | 
| multi_range_count    | 256              | 
| myisam_data_pointer_size  | 6               | 
| myisam_max_sort_file_size  | 2146435072             | 
| myisam_recover_options   | OFF              | 
| myisam_repair_threads   | 1               | 
| myisam_sort_buffer_size   | 16777216             | 
| myisam_stats_method    | nulls_unequal            | 
| net_buffer_length    | 16384              | 
| net_read_timeout    | 30               | 
| net_retry_count     | 10               | 
| net_write_timeout    | 60               | 
| new        | OFF              | 
| old_passwords     | OFF              | 
| open_files_limit    | 2000              | 
| optimizer_prune_level   | 1               | 
| optimizer_search_depth   | 62               | 
| pid_file      | /var/run/mysqld/mysqld.pid         | 
| plugin_dir      |               | 
| port       | 3306              | 
| preload_buffer_size    | 32768              | 
| profiling      | OFF              | 
| profiling_history_size   | 15               | 
| protocol_version    | 10               | 
| query_alloc_block_size   | 8192              | 
| query_cache_limit    | 1048576             | 
| query_cache_min_res_unit  | 4096              | 
| query_cache_size    | 134217728             | 
| query_cache_type    | ON               | 
| query_cache_wlock_invalidate | OFF              | 
| query_prealloc_size    | 8192              | 
| range_alloc_block_size   | 4096              | 
| read_buffer_size    | 2097152             | 
| read_only      | OFF              | 
| read_rnd_buffer_size   | 8388608             | 
| relay_log      |               | 
| relay_log_index     |               | 
| relay_log_info_file    | relay-log.info            | 
| relay_log_purge     | ON               | 
| relay_log_space_limit   | 0               | 
| rpl_recovery_rank    | 0               | 
| secure_auth      | OFF              | 
| secure_file_priv    |               | 
| server_id      | 1               | 
| skip_external_locking   | ON               | 
| skip_networking     | OFF              | 
| skip_show_database    | OFF              | 
| slave_compressed_protocol  | OFF              | 
| slave_load_tmpdir    | /tmp/              | 
| slave_net_timeout    | 3600              | 
| slave_skip_errors    | OFF              | 
| slave_transaction_retries  | 10               | 
| slow_launch_time    | 2               | 
| socket       | /var/lib/mysql/mysql.sock         | 
| sort_buffer_size    | 2097152             | 
| sql_big_selects     | ON               | 
| sql_mode      |               | 
| sql_notes      | ON               | 
| sql_warnings     | OFF              | 
| ssl_ca       |               | 
| ssl_capath      |               | 
| ssl_cert      |               | 
| ssl_cipher      |               | 
| ssl_key       |               | 
| storage_engine     | MyISAM              | 
| sync_binlog      | 0               | 
| sync_frm      | ON               | 
| system_time_zone    | CST              | 
| table_cache      | 256              | 
| table_lock_wait_timeout   | 50               | 
| table_type      | MyISAM              | 
| thread_cache_size    | 8               | 
| thread_stack     | 196608              | 
| time_format      | %H:%i:%s             | 
| time_zone      | SYSTEM              | 
| timed_mutexes     | OFF              | 
| tmp_table_size     | 33554432             | 
| tmpdir       | /tmp/              | 
| transaction_alloc_block_size | 8192              | 
| transaction_prealloc_size  | 4096              | 
| tx_isolation     | REPEATABLE-READ           | 
| updatable_views_with_limit  | YES              | 
| version       | 5.0.77-log             | 
| version_bdb      | Sleepycat Software: Berkeley DB 4.1.24: (January 29, 2009) | 
| version_comment     | Source distribution          | 
| version_compile_machine   | i686              | 
| version_compile_os    | redhat-linux-gnu           | 
| wait_timeout     | 28800              | 
+---------------------------------+------------------------------------------------------------+ 
+0

거기에 열려있는 연결 수가 늘어납니다 ... 연결 누수가있을 가능성이 있습니까? –

+0

당신은 연결을 추적해야합니다 - 귀하의 webapp이 MySQL 서버의 유일한 "사용자"입니까? – onigunn

+0

예 .. webapp는이 msql 서버의 유일한 사용자입니다. @gid .. 확인했습니다. 연결 누설이 아닙니다. 감사합니다. – Ishu

답변

1

엄청나게 많은 주장을하고 있습니다.

그리고 당신은 쿼리를 생성하거나 데이터를 소비하고 있다고 말하지 않았습니다.

MySQL에는 문서화되지 않은 메모리 누수가있을 수 있지만, 한번도 경험하지 못한 문제가 있습니다.

내가 할 수있는 첫 번째 일은 많은 메모리를 사용하고있는 것을 보려고 메모리별로 정렬 된 최상위를 보는 것입니다. 더 많은 메모리를 차지합니다. 나는 당신이 문제의 원인이 될 수있는 결과 세트를 올바르게 공개하지 않는다는 것을 알게 될 것입니다.

+0

나는 이것이 쿼리를 생성하고 소비하는 대규모 웹 애플리케이션의 프로덕션 서버라고 썼다. 또는 내 질문에 대해 명확하지 않은 특정 것이 있습니다. 감사합니다. – Ishu

+0

그리고 나는 그것의 클라이언트가 아닌지 확인했다 .. 그것은 항상 메모리에 의해 분류 된 unix top 명령의 최상위 슬롯을 잡는 mysql이다.그리고 클라이언트가 아니라고 생각하게하는 또 다른 일은, 비록 내가 mysql을 재시작하지 않는다면, 아파치를 다시 시작하여 아파치를 지우고, 심지어 서버가 과부하 상태 일지라도. 그게 내 신념을 강화 그 mysql 그게 화나게 .... – Ishu

2

key_buffer를 2.5Gb로 설정 했습니까?

그리고 이것은 32 비트 시스템입니다.

농담하나요?

서버에서 MySQL을 실행하려면 정말로 64 비트 OS를 사용해야합니다. 그렇지 않으면 합리적으로 충분한 램을 사용할 수 없습니다. 메모리가 아닌 주소 공간이 부족한 것 같습니다. 이로 인해 문제가 발생합니다.

프로세스가 32 비트 Linux에서 사용할 수있는 최대 주소 공간은 일반적으로 3G 정도입니다. 당신은 당신의 대형 키 버퍼에 그것의 대부분을 불고있어 거의 호흡을하지 않습니다.

임시 해결 방법으로 키 버퍼를 많이 줄입니다. 64 비트로 마이그레이션 할 수있을 때까지 VM 사용을 모니터링해야합니다.

+0

흠 ... 꽤 많은 유효 지점 마크 ..하지만 내 트래픽을 주위에 내가 정말 ISAM 테이블과 함께 키 버퍼를 많이 줄일 수 없다, 비록 내가 가지고 지금 1.8G로 만들었습니다. 어떻게 생각해? 감사합니다. – Ishu

+1

트래픽이 반드시 문제는 아닙니다. 인덱스가 테이블의 크기보다 큰지 고려하십시오. 데이터베이스가 작거나 일반적으로 사용되는 하위 집합이 작 으면 키 버퍼가 그렇게 클 필요가 없습니다. 그러나 장기적으로는 64 비트로 전환하는 것이 좋은 생각입니다. – MarkR

관련 문제