TUTORIAL Optimizing mysql usage on PIAF?

hecatae

resident hecatae
Joined
Feb 7, 2014
Messages
769
Reaction score
202
Grab your mysql username and password ( hint: root and passw0rd)

grab two scripts:

Code:
wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/mysqltuner.pl
 
wget https://launchpadlibrarian.net/78745738/tuning-primer.sh
 
chmod +x tuning-primer.sh
chmod +x mysqltuner.pl

run them,

post your results:
tuning-primer.sh
Code:
        -- MYSQL PERFORMANCE TUNING PRIMER --
            - By: Matthew Montgomery -
 
MySQL Version 5.1.73-log i386
 
Uptime = 0 days 3 hrs 56 min 57 sec
Avg. qps = 3
Total Questions = 53971
Threads Connected = 2
 
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.1/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 = 0.100000 sec.
You have 1 out of 53992 that take longer than 0.100000 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.1/en/point-in-time-recovery.html
 
WORKER THREADS
Current thread_cache_size = 16
Current threads_cached = 1
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
 
MAX CONNECTIONS
Current max_connections = 100
Current threads_connected = 2
Historic max_used_connections = 3
The number of used connections is 3% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocating
 
INNODB STATUS
Current InnoDB index space = 0 bytes
Current InnoDB data space = 0 bytes
Current InnoDB buffer pool free = 96 %
Current innodb_buffer_pool_size = 8 M
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 : 563 M
Configured Max Per-thread Buffers : 131 M
Configured Max Global Buffers : 560 M
Configured Max Memory Limit : 691 M
Physical Memory : 11.70 G
Max memory limit seem to be within acceptable norms
 
KEY BUFFER
Current MyISAM index space = 670 K
Current key_buffer_size = 500 M
Key cache miss rate is 1 : 91
Key buffer free ratio = 88 %
Your key_buffer_size seems to be fine
 
QUERY CACHE
Query cache is enabled
Current query_cache_size = 50 M
Current query_cache_used = 4 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 9.03 %
Current query_cache_min_res_unit = 4 K
Your query_cache_size seems to be too high.
Perhaps you can use these resources elsewhere
MySQL won't cache query results that are larger than query_cache_limit in size
 
SORT OPERATIONS
Current sort_buffer_size = 256 K
Current read_rnd_buffer_size = 256 K
Sort buffer seems to be fine
 
JOINS
Current join_buffer_size = 516.00 K
You have had 8 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 = 10110 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 = 5000 tables
Current table_definition_cache = 3000 tables
You have a total of 116 tables
You have 119 open tables.
The table_cache value seems to be fine
 
TEMP TABLES
Current max_heap_table_size = 30 M
Current tmp_table_size = 30 M
Of 4537 temp tables, 0% were created on disk
Created disk tmp tables ratio seems fine
 
TABLE SCANS
Current read_buffer_size = 128 K
Current table scan ratio = 113 : 1
read_buffer_size seems to be fine
 
TABLE LOCKING
Current Lock Wait ratio = 0 : 54264
Your table locking seems to be fine
mysqltuner.pl
Code:
 >>  MySQLTuner 1.4.0 - Major Hayden <[email protected]>
>>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
>>  Run with '--help' for additional options and output filtering
[OK] Currently running supported MySQL version 5.1.73-log
[!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM
 
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +CSV +InnoDB +MRG_MYISAM
[--] Data in MyISAM tables: 198M (Tables: 93)
[!!] InnoDB is enabled but isn't being used
[!!] Total fragmented tables: 8
 
-------- Security Recommendations  -------------------------------------------
[!!] User '@localhost' has no password set.
[!!] User '@pbx.local' has no password set.
[!!] User '[email protected]' has no password set.
[!!] User '[email protected]' has no password set.
 
-------- Performance Metrics -------------------------------------------------
[--] Up for: 3h 58m 20s (54K q [3.838 qps], 714 conn, TX: 108M, RX: 2M)
[--] Reads / Writes: 67% / 33%
[--] Total buffers: 590.0M global + 1.3M per thread (100 max threads)
[OK] Maximum possible memory usage: 721.2M (6% of installed RAM)
[OK] Slow queries: 0% (2/54K)
[OK] Highest usage of available connections: 3% (3/100)
[OK] Key buffer size / total MyISAM indexes: 500.0M/662.0K
[OK] Key buffer hit rate: 98.9% (40K cached / 442 reads)
[OK] Query cache efficiency: 74.8% (16K cached / 22K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (2 temp sorts / 1K sorts)
[OK] Temporary tables created on disk: 1% (69 on disk / 4K total)
[OK] Thread cache hit rate: 99% (3 created / 714 connections)
[OK] Table cache hit rate: 33% (119 open / 358 opened)
[OK] Open file limit used: 2% (236/10K)
[OK] Table locks acquired immediately: 100% (8K immediate / 8K locks)
 
-------- Recommendations -----------------------------------------------------
General recommendations:
    Add skip-innodb to MySQL configuration to disable InnoDB
    Run OPTIMIZE TABLE to defragment tables for better performance
    MySQL started within last 24 hours - recommendations may be inaccurate
 

hecatae

resident hecatae
Joined
Feb 7, 2014
Messages
769
Reaction score
202
Optimizations I have carried out, questions welcome

Code:
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
skip-name-resolve
myisam_use_mmap=1
max_connections = 100
max_user_connections = 50
join_buffer_size=512K
sort_buffer_size=256K
table_open_cache = 5000
table_definition_cache = 3000
max_allowed_packet = 32M
thread_cache_size = 16
query_cache_type = 1
query_cache_size =50M
query_cache_limit = 1M
max_heap_table_size = 30M
tmp_table_size = 30M
key_buffer_size = 500M
slow_query_log=1
slow_query_log_file=mysql-slow.log
long_query_time=0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
default_storage_engine = MYISAM
 

Members online

Forum statistics

Threads
25,825
Messages
167,856
Members
19,250
Latest member
mark-curtis
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top