Tasks: 583 total,   4 running, 579 sleeping,   0 stopped,   0 zombie
Cpu(s): 35.3%us,  6.9%sy,  0.0%ni, 57.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  65976288k total, 50604344k used, 15371944k free,  7638260k buffers
Swap: 65537156k total,      360k used, 65536796k free, 38368636k cached  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  620 mysql     15   0 3889m 1.3g 5820 S 1110.7  2.0 328:51.92 mysqld
10191 nobody    18   0  161m  18m 3972 R 68.9  0.0   0:02.10 httpd
 9701 nobody    17   0  160m  18m 4320 R 50.6  0.0   0:04.73 httpd
10254 nobody    17   0  162m  19m 4312 R 38.4  0.0   0:02.78 httpd
10239 nobody    18   0  163m  20m 4068 S 36.8  0.0   0:01.81 httpd
10255 nobody    17   0  161m  19m 4304 S 19.0  0.0   0:04.71 httpd
 9839 nobody    17   0  161m  19m 4324 S 10.5  0.0   0:04.66 httpd
 9826 nobody    20   0  161m  19m 4296 S  8.5  0.0   0:04.74 httpd
10182 nobody    15   0  154m  12m 4360 S  1.6  0.0   0:03.26 httpd各位大哥救救小弟吧,这台服务器跑着apache和mysql服务,其中mysql的使用已经1110.7%,这是什么原因哪?

解决方案 »

  1.   

    这个百分比是每个cpu跑的加起来的总和  比如你又16核 每个跑50% 则显示800%
    你在top命令后q键上面的1 就可以看到了
      

  2.   

    查查MySQL都在干什么show processlist;
      

  3.   

    受教了,我对mysql做了一些优化,性能好像提高了一些,但是还是不尽如人意,不知有没有大哥能给我看下mysql的配置还有哪能在优化优化:---------------+
    | Variable_name                                     | Value                                                                                                                  |
    +---------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
    | auto_increment_increment                          | 1                                                                                                                      |
    | auto_increment_offset                             | 1                                                                                                                      |
    | autocommit                                        | ON                                                                                                                     |
    | automatic_sp_privileges                           | ON                                                                                                                     |
    | back_log                                          | 50                                                                                                                     |
    | basedir                                           | /usr/local/mysql                                                                                                       |
    | big_tables                                        | OFF                                                                                                                    |
    | binlog_cache_size                                 | 4194304                                                                                                                |
    | binlog_direct_non_transactional_updates           | OFF                                                                                                                    |
    | binlog_format                                     | STATEMENT                                                                                                              |
    | binlog_stmt_cache_size                            | 32768                                                                                                                  |
    | bulk_insert_buffer_size                           | 134217728                                                                                                              |
    | character_set_client                              | utf8                                                                                                                   |
    | character_set_connection                          | utf8                                                                                                                   |
    | character_set_database                            | latin1                                                                                                                 |
    | character_set_filesystem                          | binary                                                                                                                 |
    | character_set_results                             | utf8                                                                                                                   |
    | character_set_server                              | latin1                                                                                                                 |
    | character_set_system                              | utf8                                                                                                                   |
    | character_sets_dir                                | /usr/local/mysql/share/charsets/                                                                                       |
    | collation_connection                              | utf8_general_ci               
    | collation_database                                | latin1_swedish_ci                                                                                                      |
    | collation_server                                  | latin1_swedish_ci                                                                                                      |
    | completion_type                                   | NO_CHAIN                                                                                                               |
    | concurrent_insert                                 | ALWAYS                                                                                                                 |
    | connect_timeout                                   | 10                                                                                                                                                                                                  |
    | date_format                                       | %Y-%m-%d                                                                                                               |
    | datetime_format                                   | %Y-%m-%d %H:%i:%s                                                                                                      |
    | default_storage_engine                            | InnoDB                                                                                                                 |
    | default_week_format                               | 0                                                                                                                      |
    | delay_key_write                                   | ON                                                                                                                     |
    | delayed_insert_limit                              | 100                                                                                                                    |
    | delayed_insert_timeout                            | 300                                                                                                                    |
    | delayed_queue_size                                | 1000                                                                                                                   |
    | div_precision_increment                           | 4                                                                                                                      |
    | engine_condition_pushdown                         | ON                                                                                                                     |
    | error_count                                       | 0                                                                                                                      |
    | event_scheduler                                   | OFF                                                                                                                    |
    | expire_logs_days                                  | 0                                                                                                                      |
    | external_user                                     |                                                                                                                        |
    | flush                                             | OFF                                                                                                                    |
    | flush_time                                        | 0                                                                                                                      |
    | foreign_key_checks                                | ON                                                                                                                     |
    | ft_boolean_syntax                                 | + -><()~*:""&|                                                                                                         |
    | ft_max_word_len                                   | 84                                                                                                                     |
    | ft_min_word_len                                   | 4                                                                                                                      |
                                                                               |
    | ft_query_expansion_limit                          | 20                                                                                                                     |
    | ft_stopword_file                                  | (built-in)                                                                                                             |
    | general_log                                       | OFF                                                                                                                    |
    | group_concat_max_len                              | 1024                                                                                                                   |
    | have_compress                                     | YES                                                                                                                    |
    | have_crypt                                        | YES                                                                                                                    |
    | have_csv                                          | YES                                                                                                                    |
      

  4.   

                                                                               |
    | have_dynamic_loading                              | YES                                                                                                                    |
    | have_geometry                                     | YES                                                                                                                    |
    | have_innodb                                       | YES                                                                                                                    |
    | have_ndbcluster                                   | NO                                                                                                                     |
    | have_openssl                                      | DISABLED                                                                                                               |
    | have_partitioning                                 | YES                                                                                                                    |
    | have_profiling                                    | YES                                                                                                                    |
    | have_query_cache                                  | YES                                                                                                                    |
    | have_rtree_keys                                   | YES                                                                                                                    |
    | have_ssl                                          | DISABLED                                                                                                               |
    | have_symlink                                      | YES                                                                                                                    |
    | hostname                                          | servera                                                                                                                |
    | identity                                          | 0                                                                                                                      |
    | ignore_builtin_innodb                             | OFF                                                                                                                    |
    | init_connect                                      |                                                                                                                        |
    | init_file                                         |                                                                                                                        |
    | init_slave                                        |                                                                                                                        |
    | 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                                                                                                 |
    | innodb_data_home_dir                              |                                                                                                                        |
    | innodb_doublewrite                                | ON                                                                                                                     |
    | innodb_fast_shutdown                              | 1                                                                                                                      |
    | innodb_file_format                                | Antelope                                                                                                               |
    | innodb_file_format_check                          | ON                                                                                                                     |
    | innodb_file_format_max                            | Antelope                                                                                                               |
    | innodb_file_per_table                             | OFF                                                                                                                    |
    | innodb_flush_log_at_trx_commit                    | 1                                                                                                                      |
    | innodb_flush_method                               |                                                                                                                        |
    | innodb_force_recovery                             | 0                                                                                                                      |
    | innodb_io_capacity                                | 200                                                                                                                    |
    | innodb_lock_wait_timeout                          | 50                                                                                                                     |
    | 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_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_purge_batch_size                           | 20                                                                                                                     |
      

  5.   

                                                                              |
    | max_delayed_threads                               | 20                                                                                                                     |
    | max_error_count                                   | 64                                                                                                                     |
    | max_heap_table_size                               | 16777216                                                                                                               |
    | max_insert_delayed_threads                        | 20                                                                                                                     |
    | max_join_size                                     | 18446744073709551615                                                                                                   |
    | max_length_for_sort_data                          | 1024                                                                                                                   |
    | max_prepared_stmt_count                           | 16382                                                                                                                  |
    | max_relay_log_size                                | 0                                                                                                                      |
    | max_seeks_for_key                                 | 18446744073709551615                                                                                                   |
    | max_sort_length                                   | 1024                                                                                                                   |
    | max_sp_recursion_depth                            | 0                                                                                                                      |
    | max_tmp_tables                                    | 32                                                                                                                     |
    | max_user_connections                              | 0                                                                                                                      |
    | max_write_lock_count                              | 1                                                                                                                      |
    | min_examined_row_limit                            | 0                                                                                                                      |
    | multi_range_count                                 | 256                                                                                                                    |
    | myisam_data_pointer_size                          | 6                                                                                                                      |
    | myisam_max_sort_file_size                         | 9223372036853727232                                                                                                    |
    | myisam_mmap_size                                  | 18446744073709551615                                                                                                   |
    | myisam_recover_options                            | OFF                                                                                                                    |
    | myisam_repair_threads                             | 1                                                                                                                      |
    | myisam_sort_buffer_size                           | 536870912                                                                                                              |
    | myisam_stats_method                               | nulls_unequal                                                                                                          |
    | myisam_use_mmap                                   | OFF                                                                                                                    |
    | net_buffer_length                                 | 16384                                                                                                                  |
    | net_read_timeout                                  | 30                                                                                                                     |
    | net_retry_count                                   | 10                                                                                                                     |
    | net_write_timeout                                 | 60                                                                                                                     |
    | new                                               | OFF                                                                                                                    |
    | old                                               | OFF                                                                                                                    |
    | old_alter_table                                   | OFF                                                                                                                    |
    | old_passwords                                     | ON                                                                                                                     |
    | open_files_limit                                  | 25000                                                                                                                  |
    | optimizer_prune_level                             | 1                                                                                                                      |
    | optimizer_search_depth                            | 62                                                                                                                     |
    | optimizer_switch                                  | index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on |
    | performance_schema                                | OFF                                                                                                                    |
    | performance_schema_events_waits_history_long_size | 10000                                                                                                                  |                                                                         |
    | performance_schema_events_waits_history_size      | 10                                                                                                                     |
    | performance_schema_max_cond_classes               | 80                                                                                                                     |
    | performance_schema_max_cond_instances             | 1000                                                                                                                   |
    | performance_schema_max_file_classes               | 50                                                                                                                     |
    | performance_schema_max_file_handles               | 32768                                                                                                                  |
    | performance_schema_max_file_instances             | 10000                                                                                                                  |
    | performance_schema_max_mutex_classes              | 200                                                                                                                    |
    | performance_schema_max_mutex_instances            | 1000000                                                                                                                |
    | performance_schema_max_rwlock_classes             | 30                                                                                                                     |
      

  6.   


    mysql> show global variables like '%innodb_buffer_pool_size%';
    +-------------------------+-----------+
    | Variable_name           | Value     |
    +-------------------------+-----------+
    | innodb_buffer_pool_size | 319815680 |
    +-------------------------+-----------+
    1 row in set (0.00 sec)mysql> show global variables like 'key_buffer_size%';
    +-----------------+-----------+
    | Variable_name   | Value     |
    +-----------------+-----------+
    | key_buffer_size | 164626432 |
    +-----------------+-----------+
    1 row in set (0.00 sec)这2个值值得关注
    Key_buffer_size,如果是MYISAM表多,这个调大点
    innodb_buffer_pool_size,如果是INNODB表多,这个调大点,到物理内存的60%-80%