LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 02-12-2009, 08:19 AM   #1
gavin2u
Member
 
Registered: Nov 2007
Location: Beijing, China
Distribution: Any free distro.
Posts: 47

Rep: Reputation: 15
Question mysql tuning problem: show query and fragmented tables!


hey, guys

first, good day.

these days, my box have been a matter of concern.

something goes wrong.

the ratio of show query is too high, and there are too many fragmented tables. how can i fix them.

THANKS IN ADVANCE.

(mysqltuner.pl and tuning-primer.sh give me some clues, see the reports from the two shell at the bottom of the post)

here, some key settings in current my.cnf:
Quote:
key_buffer=1024M
sort_buffer_size=8M
read_buffer_size=8M
read_rnd_buffer_size=8M
join_buffer_size=2M
myisam_sort_buffer_size=256M

wait_timeout=5
connect_timeout=10
interactive_timeout=20
max_connections=512
max_connect_errors=10000000

max_allowed_packet=16M
table_cache=2048
open_files_limit=5120
tmp_table_size=768M
max_heap_table_size=768M
thread_stack=256K
thread_cache_size=512

thread_concurrency=16
concurrent_insert=2
low_priority_updates=1

query_cache_size=32M
query_cache_limit=2M
query_cache_type=1
cpu used by mysql sometimes too high:
Quote:
top - 22:06:13 up 60 days, 8:06, 1 user, load average: 30.12, 30.45, 22.72
Tasks: 327 total, 1 running, 326 sleeping, 0 stopped, 0 zombie
Cpu(s): 16.4%us, 38.7%sy, 0.0%ni, 44.6%id, 0.1%wa, 0.0%hi, 0.2%si, 0.0%st
Mem: 8162592k total, 7833044k used, 329548k free, 80012k buffers
Swap: 8498376k total, 2416k used, 8495960k free, 5002692k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23972 mysql 15 0 2322m 924m 3568 S 417 11.6 94:59.53 mysqld
20494 root 15 0 283m 224m 604 S 3 2.8 1:13.70 lighttpd
20570 root 16 0 255m 17m 10m S 1 0.2 0:01.61 php-cgi
20603 root 16 0 255m 22m 14m S 1 0.3 0:01.61 php-cgi
20627 root 16 0 255m 20m 12m S 1 0.3 0:02.34 php-cgi
20665 root 15 0 256m 23m 15m S 1 0.3 0:04.41 php-cgi
...
system load average sometimes goes crazy high:
Quote:
load average: 55.67, 38.10, 26.71
my box's summary:
Quote:
CPU: Intel E5410 2.33G * 2
Mem: 2G * 4
OS: CentOS 5.2 x86_64

IP per day: 60,000
pageviews per day: 550,000

running app: PHP forum
report by mysqltuner.pl:
Quote:
>> MySQLTuner 0.9.9 - 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.22
[OK] Operating on 64-bit architecture

-------- Storage Engine Statistics -------------------------------------------
[--] Status: -Archive -BDB -Federated -InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 2G (Tables: 469)
[--] Data in MEMORY tables: 16M (Tables: 3)
[!!] Total fragmented tables: 115

-------- Performance Metrics -------------------------------------------------
[--] Up for: 31m 59s (420K q [219.334 qps], 49K conn, TX: 453M, RX: 77M)
[--] Reads / Writes: 60% / 40%
[--] Total buffers: 1.8G global + 26.2M per thread (512 max threads)
[!!] Maximum possible memory usage: 14.9G (191% of installed RAM)
[!!] Slow queries: 7% (32K/420K)
[OK] Highest usage of available connections: 55% (284/512)
[OK] Key buffer size / total MyISAM indexes: 1.0G/395.2M
[OK] Key buffer hit rate: 99.1% (5M cached / 46K reads)
[OK] Query cache efficiency: 38.1% (70K cached / 185K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (87 temp sorts / 14K sorts)
[OK] Temporary tables created on disk: 5% (569 on disk / 11K total)
[OK] Thread cache hit rate: 99% (284 created / 49K connections)
[OK] Table cache hit rate: 99% (881 open / 887 opened)
[OK] Open file limit used: 25% (1K/5K)
[OK] Table locks acquired immediately: 96% (280K immediate / 289K locks)
report by tuning-primer.sh :
Quote:
mysqld is alive

-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -

MySQL Version 5.0.22 x86_64

Uptime = 0 days 0 hrs 33 min 30 sec
Avg. qps = 218
Total Questions = 439489
Threads Connected = 14

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/...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 NOT enabled.
Current long_query_time = 2 sec.
You have 34225 out of 439514 that take longer than 2 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/...-recovery.html

WORKER THREADS
Current thread_cache_size = 512
Current threads_cached = 272
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 512
Current threads_connected = 12
Historic max_used_connections = 284
The number of used connections is 55% of the configured maximum.
Your max_connections variable seems to be fine.

MEMORY USAGE
Max Memory Ever Allocated : 8 G
Configured Max Per-thread Buffers : 13 G
Configured Max Global Buffers : 1 G
Configured Max Memory Limit : 14 G
Physical Memory : 7.78 G

Max memory limit exceeds 90% of physical memory

KEY BUFFER
Current MyISAM index space = 389 M
Current key_buffer_size = 1 G
Key cache miss rate is 1 : 116
Key buffer fill ratio = 5.00 %
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 = 32 M
Current query_cache_used = 8 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 27.39 %
Current query_cache_min_res_unit = 4 K
MySQL won't cache query results that are larger than query_cache_limit in size

SORT OPERATIONS
Current sort_buffer_size = 8 M
Current read_rnd_buffer_size = 7 M
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 2.00 M
You have had 0 queries where a join could not use an index properly
Your joins seem to be using indexes properly

OPEN FILES LIMIT
Current open_files_limit = 5120 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 489 tables
You have 883 open tables.
The table_cache value seems to be fine

TEMP TABLES
Current max_heap_table_size = 767 M
Current tmp_table_size = 768 M
Of 11369 temp tables, 5% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
Created disk tmp tables ratio seems fine

TABLE SCANS
Current read_buffer_size = 7 M
Current table scan ratio = 10037 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 30
You may benefit from selective use of InnoDB.

Last edited by gavin2u; 02-12-2009 at 08:36 AM.
 
Old 02-12-2009, 06:32 PM   #2
gavin2u
Member
 
Registered: Nov 2007
Location: Beijing, China
Distribution: Any free distro.
Posts: 47

Original Poster
Rep: Reputation: 15
any ideas plz, these problems have been troubling me for several nights...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL - Query and compare 2 tables rookiepaul Programming 4 05-12-2008 09:05 AM
help with mysql query: return nth rows in query hawarden Programming 2 07-31-2006 06:36 PM
php/,mysql problem: can't query JJX Linux - General 4 01-06-2005 05:10 PM
Problem with SQL query using MySQL gigglesnorter Programming 2 04-22-2004 04:11 PM
SQL query, comparing tables ngomong Programming 3 07-07-2002 07:44 PM


All times are GMT -5. The time now is 09:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration