http://www.mysql.com/doc/en/SHOW_VARIABLES.htmlhttp://www.mysql.com/doc/en/SHOW_STATUS.htmlSome comments about the above:
If Opened_tables is big, then your table_cache variable is probably too small.
If Key_reads is big, then your key_buffer_size variable is probably too small. The cache miss rate can be calculated with Key_reads/Key_read_requests.
If Handler_read_rnd is big, then you probably have a lot of queries that require MySQL to scan whole tables or you have joins that don't use keys properly.
If Threads_created is big, you may want to increase the thread_cache_size variable. The cache hit rate can be calculated with Threads_created/Connections.
If Created_tmp_disk_tables is big, you may want to increase the tmp_table_size variable to get the temporary tables memory-based instead of disk based.
==============
it seems to me that most of the above problems occur in my case.
I have a dual PII 600 with 256 meg memory, 30-50 concurrent users at most times.
** I dont quite understand why
query_cache_limit = 1
query_cache_size = 32
query_cache_type = 1
but seems in the server query_cache_size is zero. Maybe it does not read my my.cnf file? I did a myslq stop and mysql start in /etc/rc.d/init.d (linux)
Is the file type ok? myisam?? Any other problem that might be lurking? maybe bad upgrade that forgot an index??
===============
[mario@a3p etc]$ cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
max_connections=500
skip-innodb
query_cache_limit = 1
query_cache_size = 32
query_cache_type = 1
interactive_timeout=100
wait_timeout=100
connect_timeout=10
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
max_connect_errors=10
[mysql.server]
user=mysql
basedir=/var/lib
[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mario@a3p etc]$
[mario@a3p etc]$ x
==================
mysql> show variables;
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| back_log | 50 |
| basedir | / |
| binlog_cache_size | 32768 |
| bulk_insert_buffer_size | 8388608 |
| character_set | latin1 |
| character_sets | latin1 big5 czech euc_kr gb2312 gbk latin1_de sjis tis620 ujis dec8 dos german1 hp8 koi8_ru latin2 swe7 usa7 cp1251 danish hebrew win1251 estonia hungarian koi8_ukr win1251ukr greek win1250 croat cp1257 latin5 |
| concurrent_insert | ON |
| connect_timeout | 10 |
| convert_character_set | |
| datadir | /var/lib/mysql/ |
| delay_key_write | ON |
| delayed_insert_limit | 100 |
| delayed_insert_timeout | 300 |
| delayed_queue_size | 1000 |
| flush | OFF |
| flush_time | 0 |
| ft_boolean_syntax | + -><()~*:""&| |
| ft_min_word_len | 4 |
| ft_max_word_len | 254 |
| ft_max_word_len_for_sort | 20 |
| ft_stopword_file | (built-in) |
| have_bdb | NO |
| have_crypt | YES |
| have_innodb | DISABLED |
| have_isam | YES |
| have_raid | NO |
| have_symlink | YES |
| have_openssl | NO |
| have_query_cache | YES |
| init_file | |
| innodb_additional_mem_pool_size | 1048576 |
| innodb_buffer_pool_size | 8388608 |
| innodb_data_file_path | |
| innodb_data_home_dir | |
| innodb_file_io_threads | 4 |
| innodb_force_recovery | 0 |
| innodb_thread_concurrency | 8 |
| innodb_flush_log_at_trx_commit | 1 |
| innodb_fast_shutdown | ON |
| innodb_flush_method | |
| innodb_lock_wait_timeout | 50 |
| innodb_log_arch_dir | |
| innodb_log_archive | OFF |
| innodb_log_buffer_size | 1048576 |
| innodb_log_file_size | 5242880 |
| innodb_log_files_in_group | 2 |
| innodb_log_group_home_dir | |
| innodb_mirrored_log_groups | 1 |
| innodb_max_dirty_pages_pct | 90 |
| interactive_timeout | 100 |
| join_buffer_size | 1044480 |
| key_buffer_size | 16777216 |
| language | /usr/share/mysql/english/ |
| large_files_support | ON |
| local_infile | ON |
| locked_in_memory | OFF |
| log | OFF |
| log_update | OFF |
| log_bin | OFF |
| log_slave_updates | OFF |
| log_slow_queries | OFF |
| log_warnings | OFF |
| long_query_time | 10 |
| low_priority_updates | OFF |
| lower_case_table_names | OFF |
| max_allowed_packet | 16776192 |
| max_binlog_cache_size | 4294967295 |
| max_binlog_size | 1073741824 |
| max_connections | 500 |
| max_connect_errors | 10 |
| max_delayed_threads | 20 |
| max_heap_table_size | 16777216 |
| max_join_size | 4294967295 |
| max_sort_length | 1024 |
| max_user_connections | 0 |
| max_tmp_tables | 32 |
| max_write_lock_count | 4294967295 |
| myisam_max_extra_sort_file_size | 268435456 |
| myisam_max_sort_file_size | 2147483647 |
| myisam_repair_threads | 1 |
| myisam_recover_options | OFF |
| myisam_sort_buffer_size | 8388608 |
| net_buffer_length | 16384 |
| net_read_timeout | 30 |
| net_retry_count | 10 |
| net_write_timeout | 60 |
| new | OFF |
| open_files_limit | 0 |
| pid_file | /var/lib/mysql/a3p.a3p.com.pid |
| log_error | |
| port | 3306 |
| protocol_version | 10 |
| read_buffer_size | 2093056 |
| read_rnd_buffer_size | 262144 |
| rpl_recovery_rank | 0 |
| query_cache_limit | 1 |
| query_cache_size | 0 |
| query_cache_type | ON |
| server_id | 0 |
| slave_net_timeout | 3600 |
| skip_external_locking | ON |
| skip_networking | OFF |
| skip_show_database | OFF |
| slow_launch_time | 2 |
| socket | /var/lib/mysql/mysql.sock |
| sort_buffer_size | 2097144 |
| sql_mode | 0 |
| table_cache | 1024 |
| table_type | MYISAM |
| thread_cache_size | 128 |
| thread_stack | 126976 |
| tx_isolation | REPEATABLE-READ |
| timezone | EDT |
| tmp_table_size | 33554432 |
| tmpdir | /tmp/ |
| version | 4.0.13 |
| wait_timeout | 100 |
+---------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
117 rows in set (0.00 sec)
=====================================
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2661 to server version: 4.0.13
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show status;
+--------------------------+-----------+
| Variable_name | Value |
+--------------------------+-----------+
| Aborted_clients | 2165 |
| Aborted_connects | 0 |
| Bytes_received | 81226012 |
| Bytes_sent | 328805911 |
| Com_admin_commands | 0 |
| Com_alter_table | 0 |
| Com_analyze | 0 |
| Com_backup_table | 0 |
| Com_begin | 0 |
| Com_change_db | 14463 |
| Com_change_master | 0 |
| Com_check | 0 |
| Com_commit | 0 |
| Com_create_db | 0 |
| Com_create_function | 0 |
| Com_create_index | 0 |
| Com_create_table | 0 |
| Com_delete | 4861 |
| Com_delete_multi | 0 |
| Com_drop_db | 0 |
| Com_drop_function | 0 |
| Com_drop_index | 0 |
| Com_drop_table | 0 |
| Com_flush | 0 |
| Com_grant | 0 |
| Com_ha_close | 0 |
| Com_ha_open | 0 |
| Com_ha_read | 0 |
| Com_insert | 3402 |
| Com_insert_select | 0 |
| Com_kill | 0 |
| Com_load | 0 |
| Com_load_master_data | 0 |
| Com_load_master_table | 0 |
| Com_lock_tables | 1 |
| Com_optimize | 3 |
| Com_purge | 0 |
| Com_rename_table | 0 |
| Com_repair | 0 |
| Com_replace | 14255 |
| Com_replace_select | 0 |
| Com_reset | 0 |
| Com_restore_table | 0 |
| Com_revoke | 0 |
| Com_rollback | 0 |
| Com_select | 149555 |
| Com_set_option | 18 |
| Com_show_binlog_events | 0 |
| Com_show_binlogs | 0 |
| Com_show_create | 18 |
| Com_show_databases | 0 |
| Com_show_fields | 18 |
| Com_show_grants | 0 |
| Com_show_keys | 0 |
| Com_show_logs | 0 |
| Com_show_master_status | 0 |
| Com_show_new_master | 0 |
| Com_show_open_tables | 0 |
| Com_show_processlist | 0 |
| Com_show_slave_hosts | 0 |
| Com_show_slave_status | 0 |
| Com_show_status | 13941 |
| Com_show_innodb_status | 0 |
| Com_show_tables | 1 |
| Com_show_variables | 2 |
| Com_slave_start | 0 |
| Com_slave_stop | 0 |
| Com_truncate | 0 |
| Com_unlock_tables | 0 |
| Com_update | 14718 |
| Connections | 2663 |
| Created_tmp_disk_tables | 341 |
| Created_tmp_tables | 11948 |
| Created_tmp_files | 10 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Delayed_errors | 0 |
| Flush_commands | 1 |
| Handler_commit | 0 |
| Handler_delete | 4466 |
| Handler_read_first | 1116 |
| Handler_read_key | 507346 |
| Handler_read_next | 265654814 |
| Handler_read_prev | 285045 |
| Handler_read_rnd | 1099965 |
| Handler_read_rnd_next | 4047770 |
| Handler_rollback | 0 |
| Handler_update | 234038 |
| Handler_write | 34513 |
| Key_blocks_used | 15586 |
| Key_read_requests | 8554464 |
| Key_reads | 28379 |
| Key_write_requests | 65199 |
| Key_writes | 35567 |
| Max_used_connections | 33 |
| Not_flushed_key_blocks | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables | 69 |
| Open_files | 87 |
| Open_streams | 0 |
| Opened_tables | 116 |
| Questions | 201794 |
| Qcache_queries_in_cache | 0 |
| Qcache_inserts | 0 |
| Qcache_hits | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 0 |
| Qcache_free_memory | 0 |
| Qcache_free_blocks | 0 |
| Qcache_total_blocks | 0 |
| Rpl_status | NULL |
| Select_full_join | 0 |
| Select_full_range_join | 0 |
| Select_range | 4425 |
| Select_range_check | 0 |
| Select_scan | 23061 |
| Slave_open_temp_tables | 0 |
| Slave_running | OFF |
| Slow_launch_threads | 0 |
| Slow_queries | 290 |
| Sort_merge_passes | 0 |
| Sort_range | 52948 |
| Sort_rows | 4123249 |
| Sort_scan | 22924 |
| Table_locks_immediate | 188411 |
| Table_locks_waited | 9910 |
| Threads_cached | 14 |
| Threads_created | 34 |
| Threads_connected | 20 |
| Threads_running | 1 |
| Uptime | 37865 |
+--------------------------+-----------+
131 rows in set (0.02 sec)
mysql> flush tables;
ERROR 2006: MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 2712
Current database: *** NONE ***
Query OK, 0 rows affected (0.06 sec)
mysql> show status;
+--------------------------+-----------+
| Variable_name | Value |
+--------------------------+-----------+
| Aborted_clients | 2215 |
| Aborted_connects | 0 |
| Bytes_received | 82468714 |
| Bytes_sent | 331280816 |
| Com_admin_commands | 0 |
| Com_alter_table | 0 |
| Com_analyze | 0 |
| Com_backup_table | 0 |
| Com_begin | 0 |
| Com_change_db | 14669 |
| Com_change_master | 0 |
| Com_check | 0 |
| Com_commit | 0 |
| Com_create_db | 0 |
| Com_create_function | 0 |
| Com_create_index | 0 |
| Com_create_table | 0 |
| Com_delete | 4929 |
| Com_delete_multi | 0 |
| Com_drop_db | 0 |
| Com_drop_function | 0 |
| Com_drop_index | 0 |
| Com_drop_table | 0 |
| Com_flush | 1 |
| Com_grant | 0 |
| Com_ha_close | 0 |
| Com_ha_open | 0 |
| Com_ha_read | 0 |
| Com_insert | 3453 |
| Com_insert_select | 0 |
| Com_kill | 0 |
| Com_load | 0 |
| Com_load_master_data | 0 |
| Com_load_master_table | 0 |
| Com_lock_tables | 1 |
| Com_optimize | 3 |
| Com_purge | 0 |
| Com_rename_table | 0 |
| Com_repair | 0 |
| Com_replace | 14459 |
| Com_replace_select | 0 |
| Com_reset | 0 |
| Com_restore_table | 0 |
| Com_revoke | 0 |
| Com_rollback | 0 |
| Com_select | 151738 |
| Com_set_option | 18 |
| Com_show_binlog_events | 0 |
| Com_show_binlogs | 0 |
| Com_show_create | 18 |
| Com_show_databases | 0 |
| Com_show_fields | 18 |
| Com_show_grants | 0 |
| Com_show_keys | 0 |
| Com_show_logs | 0 |
| Com_show_master_status | 0 |
| Com_show_new_master | 0 |
| Com_show_open_tables | 0 |
| Com_show_processlist | 0 |
| Com_show_slave_hosts | 0 |
| Com_show_slave_status | 0 |
| Com_show_status | 14143 |
| Com_show_innodb_status | 0 |
| Com_show_tables | 1 |
| Com_show_variables | 2 |
| Com_slave_start | 0 |
| Com_slave_stop | 0 |
| Com_truncate | 0 |
| Com_unlock_tables | 0 |
| Com_update | 14955 |
| Connections | 2715 |
| Created_tmp_disk_tables | 351 |
| Created_tmp_tables | 12131 |
| Created_tmp_files | 10 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Delayed_errors | 0 |
| Flush_commands | 2 |
| Handler_commit | 0 |
| Handler_delete | 4539 |
| Handler_read_first | 1129 |
| Handler_read_key | 513855 |
| Handler_read_next | 268818314 |
| Handler_read_prev | 285153 |
| Handler_read_rnd | 1117897 |
| Handler_read_rnd_next | 4073775 |
| Handler_rollback | 0 |
| Handler_update | 237286 |
| Handler_write | 35023 |
| Key_blocks_used | 15586 |
| Key_read_requests | 8638064 |
| Key_reads | 28887 |
| Key_write_requests | 66218 |
| Key_writes | 36105 |
| Max_used_connections | 33 |
| Not_flushed_key_blocks | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables | 13 |
| Open_files | 23 |
| Open_streams | 0 |
| Opened_tables | 129 |
| Questions | 204750 |
| Qcache_queries_in_cache | 0 |
| Qcache_inserts | 0 |
| Qcache_hits | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 0 |
| Qcache_free_memory | 0 |
| Qcache_free_blocks | 0 |
| Qcache_total_blocks | 0 |
| Rpl_status | NULL |
| Select_full_join | 0 |
| Select_full_range_join | 0 |
| Select_range | 4468 |
| Select_range_check | 0 |
| Select_scan | 23397 |
| Slave_open_temp_tables | 0 |
| Slave_running | OFF |
| Slow_launch_threads | 0 |
| Slow_queries | 290 |
| Sort_merge_passes | 0 |
| Sort_range | 53674 |
| Sort_rows | 4196111 |
| Sort_scan | 23263 |
| Table_locks_immediate | 191304 |
| Table_locks_waited | 9938 |
| Threads_cached | 17 |
| Threads_created | 34 |
| Threads_connected | 17 |
| Threads_running | 1 |
| Uptime | 38585 |
+--------------------------+-----------+
131 rows in set (0.00 sec)
mysql> show status;
+--------------------------+-----------+
| Variable_name | Value |
+--------------------------+-----------+
| Aborted_clients | 2216 |
| Aborted_connects | 0 |
| Bytes_received | 82552734 |
| Bytes_sent | 331473570 |
| Com_admin_commands | 0 |
| Com_alter_table | 0 |
| Com_analyze | 0 |
| Com_backup_table | 0 |
| Com_begin | 0 |
| Com_change_db | 14682 |
| Com_change_master | 0 |
| Com_check | 0 |
| Com_commit | 0 |
| Com_create_db | 0 |
| Com_create_function | 0 |
| Com_create_index | 0 |
| Com_create_table | 0 |
| Com_delete | 4932 |
| Com_delete_multi | 0 |
| Com_drop_db | 0 |
| Com_drop_function | 0 |
| Com_drop_index | 0 |
| Com_drop_table | 0 |
| Com_flush | 1 |
| Com_grant | 0 |
| Com_ha_close | 0 |
| Com_ha_open | 0 |
| Com_ha_read | 0 |
| Com_insert | 3456 |
| Com_insert_select | 0 |
| Com_kill | 0 |
| Com_load | 0 |
| Com_load_master_data | 0 |
| Com_load_master_table | 0 |
| Com_lock_tables | 1 |
| Com_optimize | 3 |
| Com_purge | 0 |
| Com_rename_table | 0 |
| Com_repair | 0 |
| Com_replace | 14472 |
| Com_replace_select | 0 |
| Com_reset | 0 |
| Com_restore_table | 0 |
| Com_revoke | 0 |
| Com_rollback | 0 |
| Com_select | 151885 |
| Com_set_option | 18 |
| Com_show_binlog_events | 0 |
| Com_show_binlogs | 0 |
| Com_show_create | 18 |
| Com_show_databases | 0 |
| Com_show_fields | 18 |
| Com_show_grants | 0 |
| Com_show_keys | 0 |
| Com_show_logs | 0 |
| Com_show_master_status | 0 |
| Com_show_new_master | 0 |
| Com_show_open_tables | 0 |
| Com_show_processlist | 0 |
| Com_show_slave_hosts | 0 |
| Com_show_slave_status | 0 |
| Com_show_status | 14157 |
| Com_show_innodb_status | 0 |
| Com_show_tables | 1 |
| Com_show_variables | 2 |
| Com_slave_start | 0 |
| Com_slave_stop | 0 |
| Com_truncate | 0 |
| Com_unlock_tables | 0 |
| Com_update | 14970 |
| Connections | 2718 |
| Created_tmp_disk_tables | 351 |
| Created_tmp_tables | 12143 |
| Created_tmp_files | 10 |
| Delayed_insert_threads | 0 |
| Delayed_writes | 0 |
| Delayed_errors | 0 |
| Flush_commands | 2 |
| Handler_commit | 0 |
| Handler_delete | 4542 |
| Handler_read_first | 1129 |
| Handler_read_key | 514245 |
| Handler_read_next | 268955608 |
| Handler_read_prev | 285153 |
| Handler_read_rnd | 1119232 |
| Handler_read_rnd_next | 4074272 |
| Handler_rollback | 0 |
| Handler_update | 237450 |
| Handler_write | 35055 |
| Key_blocks_used | 15586 |
| Key_read_requests | 8642738 |
| Key_reads | 28957 |
| Key_write_requests | 66269 |
| Key_writes | 36130 |
| Max_used_connections | 33 |
| Not_flushed_key_blocks | 0 |
| Not_flushed_delayed_rows | 0 |
| Open_tables | 13 |
| Open_files | 23 |
| Open_streams | 0 |
| Opened_tables | 129 |
| Questions | 204945 |
| Qcache_queries_in_cache | 0 |
| Qcache_inserts | 0 |
| Qcache_hits | 0 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 0 |
| Qcache_free_memory | 0 |
| Qcache_free_blocks | 0 |
| Qcache_total_blocks | 0 |
| Rpl_status | NULL |
| Select_full_join | 0 |
| Select_full_range_join | 0 |
| Select_range | 4471 |
| Select_range_check | 0 |
| Select_scan | 23420 |
| Slave_open_temp_tables | 0 |
| Slave_running | OFF |
| Slow_launch_threads | 0 |
| Slow_queries | 290 |
| Sort_merge_passes | 0 |
| Sort_range | 53728 |
| Sort_rows | 4201492 |
| Sort_scan | 23286 |
| Table_locks_immediate | 191493 |
| Table_locks_waited | 9941 |
| Threads_cached | 15 |
| Threads_created | 34 |
| Threads_connected | 19 |
| Threads_running | 1 |
| Uptime | 38618 |
+--------------------------+-----------+
131 rows in set (0.00 sec)