merhabalar mysql i optimizasyon konusunda biraz zayıfım. my.cnf dosyam aşağıda ne gibi bir değişiklikler yapmalıyım ?
CPU Bilgileri:
PHP- Kodu:
model name : Intel(R) Pentium(R) 4 CPU 3.20GHz
stepping : 9
cpu MHz : 3200.047
cache size : 1024 KB
my.cnf dosyasının içeriği:
PHP- Kodu:
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
safe-show-database
skip-innodb
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
log-slow-queries=/var/log/mysql-slow.log
bind-address = 127.0.0.1
key_buffer = 256M
join_buffer_size = 2M
table_cache = 1024
max_allowed_packet = 16M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_siz = 4M
tmp_table_size = 128M
thread_stack = 128K
max_heap_table_size = 64M
max_allowed_packet = 64M
bulk_insert_buffer_size = 8M
thread_cache_size = 384
max_connections = 200
table_cache = 1024
#thread_concurrency = 10
query_cache_limit = 4M
query_cache_size = 40M
query_cache_type = 1
default-storage-engine = MyISAM
#log = /var/log/mysql/mysql.log
log_slow_queries = /var/log/mysql/mysql-slow.log
long_query_time = 2
#log-queries-not-using-indexes
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
skip-bdb
[mysqldump]
quick
quote-names
max_allowed_packet = 32M
Top M çıktısı:
PHP- Kodu:
top - 00:19:53 up 19 days, 6:32, 1 user, load average: 4.37, 3.55, 3.14
Tasks: 141 total, 3 running, 138 sleeping, 0 stopped, 0 zombie
Cpu(s): 62.6%us, 31.9%sy, 0.0%ni, 4.0%id, 0.3%wa, 0.3%hi, 0.8%si, 0.0%st
Mem: 2068160k total, 1924136k used, 144024k free, 90812k buffers
Swap: 2096472k total, 24k used, 2096448k free, 1399892k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
20401 mysql 15 0 387m 225m 4800 S 185 11.2 2833:39 mysqld
3208 root 15 0 31772 28m 2540 S 0 1.4 0:23.60 spamd
3490 root 15 0 31772 26m 632 S 0 1.3 0:00.18 spamd
3491 root 18 0 31772 26m 540 S 0 1.3 0:00.22 spamd
20315 root 18 0 32184 10m 6164 R 0 0.5 0:34.21 apache2
2025 www-data 18 0 33016 10m 5308 S 0 0.5 0:03.93 apache2
2120 www-data 15 0 33264 10m 5312 S 0 0.5 0:02.72 apache2
2296 www-data 16 0 32940 10m 5028 S 1 0.5 0:01.94 apache2
2056 www-data 15 0 32952 10m 5144 S 0 0.5 0:02.55 apache2
2241 www-data 15 0 32952 10m 5108 S 0 0.5 0:01.84 apache2
2131 www-data 15 0 32924 9m 5156 S 0 0.5 0:01.35 apache2
2188 www-data 15 0 32896 9m 5164 S 0 0.5 0:00.79 apache2
1906 www-data 17 0 33372 9.8m 4796 S 0 0.5 0:06.36 apache2
2096 www-data 15 0 33280 9948 4780 S 0 0.5 0:01.71 apache2
2114 www-data 16 0 32920 9752 4568 S 0 0.5 0:03.89 apache2
2326 www-data 15 0 32936 9736 4612 S 0 0.5 0:02.29 apache2
2133 www-data 15 0 32696 9720 4568 S 0 0.5 0:02.04 apache2
1994 www-data 15 0 32692 9676 4588 S 0 0.5 0:01.77 apache2
2338 www-data 15 0 32892 9652 4600 S 0 0.5 0:00.93 apache2
2320 www-data 16 0 32700 9632 4516 S 0 0.5 0:00.46 apache2
tuning primer çıktısı:
PHP- Kodu:
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.0.32-Debian_7etch5-log i486
Uptime = 2 days 5 hrs 35 min 41 sec
Avg. qps = 30
Total Questions = 5949923
Threads Connected = 2
Server has been running for over 48hrs.
It should be safe to follow 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
Current long_query_time = 2 sec.
You have 40630 out of 5949948 that take longer than 2 sec. to complete
The slow query log is enabled.
Your long_query_time seems to be fine
WORKER THREADS
Current thread_cache_size = 384
Current threads_cached = 133
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 200
Current threads_connected = 3
Historic max_used_connections = 136
The number of used connections is 68% of the configured maximum.
Your max_connections variable seems to be fine.
MEMORY USAGE
Max Memory Ever Allocated : 1 G
Configured Max Per-thread Buffers : 1 G
Configured Max Global Buffers : 306 M
Configured Max Memory Limit : 2 G
Physical Memory : 1.97 G
Max memory limit exceeds 90% of physical memory
KEY BUFFER
Current MyISAM index space = 306 M
Current key_buffer_size = 256 M
Key cache miss rate is 1 : 4036
Key buffer fill ratio = 44.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 = 40 M
Current query_cache_used = 24 M
Current query_cache_limit = 4 M
Current Query cache Memory fill ratio = 60.97 %
Current query_cache_min_res_unit = 4 K
Query Cache is 21 % 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 record/read_rnd_buffer_size = 3 M
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 2.00 M
You have had 28 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
OPEN FILES LIMIT
Current open_files_limit = 2258 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
You currently have open more than 75% of your open_files_limit
You should set a higher value for open_files_limit in my.cnf
TABLE CACHE
Current table_cache value = 1024 tables
You have a total of 772 tables
You have 1024 open tables.
Current table_cache hit rate is 53%, while 100% of your table cache is in use
You should probably increase your table_cache
TEMP TABLES
Current max_heap_table_size = 64 M
Current tmp_table_size = 128 M
Of 91458 temp tables, 31% were created on disk
Effective in-memory tmp_table_size is limited to max_heap_table_size.
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 = 389 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 15
You may benefit from selective use of InnoDB.
If you have long running SELECT's against MyISAM tables and perform
frequent updates consider setting 'low_priority_updates=1'
If you have a high concurrency of inserts on Dynamic row-length tables
consider setting 'concurrent_insert=2.
onerileriniz icin şimdiden teşekkurler