Chicos,
Actualmente mi base de datos en Mysql consume mucho el CPU pero la memoria casi ni se usa, esto hace que demore mucho en responder dando lentitud a mi pagina.
Miren esta imagen:
Mi configuracion de mi my.cnf es la siguiente:
Código PHP:
[mysqld]
datadir=/var/lib/mysql
#tmpdir=/var/lib/mysqltmp
socket=/var/lib/mysql/mysql.sock
skip-locking
table_cache=2048
thread_cache_size=16
thread_concurrency=8
back_log=100
max_connect_errors=1000
open-files=20000
interactive_timeout=15
wait_timeout=300
set-variable=long_query_time=4
#max_connections=200
#log =/var/log/mysql.log
#log-bin = mysql-bin
#server-id=1
#binlog-do-db=repu_web
#replicate-wild-do-table=repu_web.%
log-slow-queries=/var/lib/mysqllogs/slow-log
#long_query_time=4
log-queries-not-using-indexes
max_allowed_packet=256M
tmp_table_size=5120M
max_heap_table_size=5120M
query_cache_size=128M
query_cache_limit=2M
query_cache_type=1
max_connections=90
#interactive_timeout=60
wait_timeout=10
connect_timeout=20
key_buffer=512M
low_priority_updates=1
concurrent_insert=2
# Per-Thread Buffers
# ------------------
sort_buffer_size=2M
read_buffer_size=2M
read_rnd_buffer_size=64M
join_buffer_size=512M
record_buffer=1M
key_buffer_size=512M
myisam_sort_buffer_size=64M
[mysql.server]
user=mysql
#basedir=/var/lib
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
open_files_limit=8192
no-auto-rehash
[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M
[mysqlhotcopy]
interactive-timeout
Ahora, corry 2 reporteadores y me envian lo siguiente:
Tunning-primer.sh Código PHP:
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.0.77-log x86_64
Uptime = 0 days 0 hrs 50 min 19 sec
Avg. qps = 1558
Total Questions = 4705358
Threads Connected = 27
Warning: Server has not been running for at least 48hrs.
It may not be safe to use these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
Visit http://www.mysql.com/products/enterprise/advisors.html
for info about MySQL's Enterprise Monitoring and Advisory Service
SLOW QUERIES
The slow query log is enabled.
Current long_query_time = 4 sec.
You have 21475 out of 4705511 that take longer than 4 sec. to complete
Your long_query_time seems to be fine
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See http://dev.mysql.com/doc/refman/5.0/en/point-in-time-recovery.html
WORKER THREADS
Current thread_cache_size = 16
Current threads_cached = 14
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 90
Current threads_connected = 24
Historic max_used_connections = 91
The number of used connections is 101% of the configured maximum.
You should raise max_connections
No InnoDB Support Enabled!
MEMORY USAGE
Max Memory Ever Allocated : 74.86 G
Configured Max Per-thread Buffers : 73.41 G
Configured Max Global Buffers : 650 M
Configured Max Memory Limit : 74.04 G
Physical Memory : 31.41 G
nMax memory limit exceeds 90% of physical memory
KEY BUFFER
Current MyISAM index space = 340 M
Current key_buffer_size = 512 M
Key cache miss rate is 1 : 11804
Key buffer free ratio = 67 %
Your key_buffer_size seems to be too high.
Perhaps you can use these resources elsewhere
QUERY CACHE
Query cache is enabled
Current query_cache_size = 128 M
Current query_cache_used = 38 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 29.78 %
Current query_cache_min_res_unit = 4 K
Query Cache is 27 % fragmented
Run "FLUSH QUERY CACHE" periodically to defragment the query cache memory
If you have many small queries lower 'query_cache_min_res_unit' to reduce fragmentation.
MySQL won't cache query results that are larger than query_cache_limit in size
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 64 M
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 768.00 M
You have had 641 queries where a join could not use an index properly
You have had 2601 joins without keys that check for key usage after each row
join_buffer_size >= 4 M
This is not advised
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
OPEN FILES LIMIT
Current open_files_limit = 20000 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine
TABLE CACHE
Current table_cache value = 2048 tables
You have a total of 370 tables
You have 900 open tables.
The table_cache value seems to be fine
TEMP TABLES
Current max_heap_table_size = 5.00 G
Current tmp_table_size = 5.00 G
Of 51181 temp tables, 34% were created on disk
Perhaps you should increase your tmp_table_size and/or max_heap_table_size
to reduce the number of disk-based temporary tables
Note! BLOB and TEXT columns are not allow in memory tables.
If you are using these columns raising these values might not impact your
ratio of on disk temp tables.
TABLE SCANS
Current read_buffer_size = 1 M
Current table scan ratio = 221 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 60
You may benefit from selective use of InnoDB.
MySQLTuner Código PHP:
>> MySQLTuner 1.2.0 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with '--help' for additional options and output filtering
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.77-log
[OK] Operating on 64-bit architecture
-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive +BDB -Federated -InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 1G (Tables: 353)
[!!] BDB is enabled but isn't being used
[!!] Total fragmented tables: 24
-------- Security Recommendations -------------------------------------------
[OK] All database users have passwords assigned
-------- Performance Metrics -------------------------------------------------
[--] Up for: 45m 21s (4M q [1K qps], 13K conn, TX: 38B, RX: 1B)
[--] Reads / Writes: 66% / 34%
[--] Total buffers: 5.6G global + 835.2M per thread (90 max threads)
[!!] Maximum possible memory usage: 79.0G (251% of installed RAM)
[OK] Slow queries: 0% (19K/4M)
[!!] Highest connection usage: 100% (91/90)
[OK] Key buffer size / total MyISAM indexes: 512.0M/340.2M
[OK] Key buffer hit rate: 100.0% (795M cached / 73K reads)
[OK] Query cache efficiency: 85.4% (3M cached / 3M selects)
[!!] Query cache prunes per day: 550788
[OK] Sorts requiring temporary tables: 1% (1K temp sorts / 103K sorts)
[!!] Joins performed without indexes: 2804
[!!] Temporary tables created on disk: 34% (23K on disk / 68K total)
[OK] Thread cache hit rate: 95% (656 created / 13K connections)
[OK] Table cache hit rate: 99% (895 open / 901 opened)
[OK] Open file limit used: 6% (1K/20K)
[OK] Table locks acquired immediately: 98% (982K immediate / 999K locks)
[!!] Connections aborted: 6%
-------- Recommendations -----------------------------------------------------
General recommendations:
Add skip-bdb to MySQL configuration to disable BDB
Run OPTIMIZE TABLE to defragment tables for better performance
MySQL started within last 24 hours - recommendations may be inaccurate
Reduce your overall MySQL memory footprint for system stability
Reduce or eliminate persistent connections to reduce connection usage
Adjust your join queries to always utilize indexes
Temporary table size is already large - reduce result set size
Reduce your SELECT DISTINCT queries without LIMIT clauses
Your applications are not closing MySQL connections properly
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
max_connections (> 90)
wait_timeout (< 10)
interactive_timeout (< 15)
query_cache_size (> 128M)
join_buffer_size (> 768.0M, or always use indexes with joins)
Quisiera que me ayuden a entender mejor mi configuracion, el DBA esta de vacaciones y esta inubicable.
El server tiene las siguientes caracteristicas:
Dell PowerEdge 2970
Dual Proccesor, Quad Core AMD Opteron
32 Gb Memoria