Upload
javier-tomas-zon
View
76
Download
1
Tags:
Embed Size (px)
Citation preview
MySQL for Sysadmins
Binlogic Conference 2012
BEGIN
• Scope
• Things you need to know
• Before install
• After install
• Online processes
• Application kit
Scope
• Sysadmins
• Database Administrators
• Dev Ops
• Operation Team
• Everyone that use MySQL
Things you need to know
• Use 64bits!
• Use kernel and software updated
• MySQL loves RAM
• MyISAM, InnoDB and many others
• Storage Engines are for tables not for DB
• Use partitions when is possible
• Optimize your SQL code
Before install
• Operating System
Before install
• HDD / SSD / RAM storage
Before install
• Filesystems
EXT3
EXT4
XFS
• RAID
RAID 0
RAID 1
RAID 5
RAID 6
RAID 10
Benchmark EXT4 vs XFS
Benchmark EXT4 vs XFS
Benchmark EXT4 vs XFS
Benchmark EXT4 vs XFS
Benchmark EXT4 vs XFS
Before install
• Disk Partitions• /
• /tmp
• /home
• innodb data / logs
• binary logs / relay logs
• datadir
• tmpdir
Before install
• MySQL version / branch• MySQL
• MariaDB
• Percona
• Custom branches
» Drizzle
After install
• Change MySQL defaults [ my.cnf ]
» bind-address
» skip-name-resolve
» Run: mysql_secure_install
» Check users privileges
After install
• MyISAM performance
– Read» key_buffer
» sort_buffer
» read_buffer_size
After install
• InnoDB performance
– Read» innodb_buffer_pool_size
» query_cache_size
» query_cache_type
– Write » innodb_flush_method
» innodb_flush_log_at_trx_commit
Reference: http://goo.gl/W6svD
InnoBD performance
InnoBD performance
InnoBD performance
InnoBD performance
After install
• Checks your logs» general_log_file
» general_log
» log_slow_queries
» long_query_time
» log-queries-not-using-indexes
After install
• Binary logs / Relay logs» server-id
» log_bin
» expire_logs_days
» max_binlog_size
» replicate_do_db
» relay_log
» relay_log_index
» relay-log-space-limit
» max-relay-log-size
After install
• Separated partitions for logs and data» datadir
» innodb_file_per_table
» innodb_data_home_dir
» innodb_log_group_home_dir
» innodb_log_file_size
» innodb_log_files_in_group
After install
• Double check your DDL scripts
• Keep monitoring your DML scripts
• Secure your server with DCL scripts
Online processes
• ALTER TABLE without Downtime
• How long? Could we test it before?
• Backup» INTO OUTFILE / mysqldump –T
» Copy Binary logs
• Restore» LOAD DATA INFILE / mysqlimport
» mysqlbinlog | mysql
Dumping faster
time mysqlimport sakila /tmp/sakila-dump/*.txt
real 0m0.188s
user 0m0.004s
sys 0m0.004s
Dumping faster
time mysql < sakila-data.sql
real 0m1.196s
user 0m0.056s
sys 0m0.008s
Application Kit
• Percona Toolkit» pt-heartbeat
» pt-online-schema-change
» pt-slave-delay
• Scripts en GitHub?
• Benchmarks » sysbench
» scripts
COMMIT
• Pay attention before and after install your server
• Check your SQL code before you start hate MySQL
• Run backups and test it! Take time for that..
• Make your own scripts
• Keep using MySQL =)
COMMIT
• Read » Blog de percona performance blog (EN)
» http://www.ilsistemista.net/ (EN)
» Binlogic Blog
» Kibibyte.net Blog ( 09/2012 )