منبع اصلی نوشتار زیر در این لینک قرار دارد

تیونینگ Mysql

سرویس  Mysql آرگومان های بسیار زیادی داره که بسته به احتیاجاتمون به فراخور استفاده ای که داریم میتونیم مقدار دهی و بهینه کنیم ، انجام اینکار برای دیتابیس های بزرگ هم زمان بره و هم سخته ، چون باید به روش آزمون و خطا اینکارو بکنیم . اسکریپت هایی در سطح اینترنت هستند که در این رابطه کار ما رو ساده تر کردن طوری که زمان تیونینگ رو حداکثر تا یه هفته کاهش دادند.

توی این پست میخوام یک اسکریپت که امتحان خودشو پس داده رو بهتون معرفی کنم ، آخرین ورژن این اسکریپت رو میتونید از اینجا دانلود کنید.

[root@oslearn ~]# wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh
--۲۰۱۴-۱۱-۱۱ ۱۹:۵۷:۲۲--  https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh
Resolving launchpad.net... 91.189.89.222, 91.189.89.223
Connecting to launchpad.net|91.189.89.222|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://launchpadlibrarian.net/78745738/tuning-primer.sh [following]
--۲۰۱۴-۱۱-۱۱ ۱۹:۵۷:۲۳--  https://launchpadlibrarian.net/78745738/tuning-primer.sh
Resolving launchpadlibrarian.net... 91.189.89.229, 91.189.89.228
Connecting to launchpadlibrarian.net|91.189.89.229|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 51892 (51K) [text/x-sh]
Saving to: “tuning-primer.sh”

۱۰۰%[===================================================================================================================>] 51,892       247K/s   in 0.2s

۲۰۱۴-۱۱-۱۱ ۱۹:۵۷:۲۳ (۲۴۷ KB/s) - “tuning-primer.sh” saved [51892/51892]

[root@oslearn ~]#

بعد باید پرمیژن اجرایی به فایل بدیم :

[root@oslearn ~]# chmoe +x tuning-primer.sh

خوب حالا طبق ساختار زیر اجراش میکنیم :

[root@oslearn ~]# ./tuning-primer.sh

Using login values from ~/.my.cnf
- INITIAL LOGIN ATTEMPT FAILED -
Testing for stored webmin passwords:
 None Found
Could not auto detect login info!
Found potential sockets: /var/lib/mysql/mysql.sock
Using: /var/lib/mysql/mysql.sock
Would you like to provide a different socket?: [y/N] N
Do you have your login handy ? [y/N] : y
User: mohammad
Password: *****************************

Would you like me to create a ~/.my.cnf file for you? [y/N] : y

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

MySQL Version 5.5.30-log x86_64

Uptime = 93 days 7 hrs 5 min 21 sec
Avg. qps = 305
Total Questions = 2459502368
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.5/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 = 1.000000 sec.
You have 30698 out of 2459502534 that take longer than 1.000000 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.5/en/point-in-time-recovery.html

WORKER THREADS
Current thread_cache_size = 4
Current threads_cached = 3
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine

MAX CONNECTIONS
Current max_connections = 75
Current threads_connected = 1
Historic max_used_connections = 49
The number of used connections is 65% of the configured maximum.
Your max_connections variable seems to be fine.

INNODB STATUS
Current InnoDB index space = 349 M
Current InnoDB data space = 382 M
Current InnoDB buffer pool free = 1 %
Current innodb_buffer_pool_size = 1.00 G
Depending on how much space your innodb indexes take up it may be safe
to increase this value to up to 2 / 3 of total system memory

MEMORY USAGE
Max Memory Ever Allocated : 2.12 G
Configured Max Per-thread Buffers : 1.03 G
Configured Max Global Buffers : 1.44 G
Configured Max Memory Limit : 2.48 G
Physical Memory : 7.68 G
Max memory limit seem to be within acceptable norms

KEY BUFFER
Current MyISAM index space = 14 M
Current key_buffer_size = 384 M
Key cache miss rate is 1 : 89
Key buffer free ratio = 81 %
Your key_buffer_size seems to be fine

QUERY CACHE
Query cache is enabled
Current query_cache_size = 64 M
Current query_cache_used = 55 M
Current query_cache_limit = 2 M
Current Query cache Memory fill ratio = 86.30 %
Current query_cache_min_res_unit = 4 K
However, 16554905 queries have been removed from the query cache due to lack of memory
Perhaps you should raise query_cache_size
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 = 8 M
Sort buffer seems to be fine

JOINS
Current join_buffer_size = 2.00 M
You have had 111188 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 = 50000 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_open_cache = 512 tables
Current table_definition_cache = 400 tables
You have a total of 4706 tables
You have 512 open tables.
Current table_cache hit rate is 0%
, while 100% of your table cache is in use
You should probably increase your table_cache
You should probably increase your table_definition_cache value.

TEMP TABLES
Current max_heap_table_size = 128 M
Current tmp_table_size = 128 M
Of 2330793 temp tables, 10% were created on disk
Created disk tmp tables ratio seems fine

TABLE SCANS
Current read_buffer_size = 2 M
Current table scan ratio = 6 : 1
read_buffer_size seems to be fine

TABLE LOCKING
Current Lock Wait ratio = 1 : 10702047
Your table locking seems to be fine

[root@oslearn ~]#

در نهایت خروجی دستور به ما میگه که کجاها تویکانفیگ اشکال داره  که باید پیاده سازی بشه.

امیدوارم که این آموزش هم براتون مفید واقع شده باشه.

پیروز باشید.



برچسب ها : , , , , , , ,