MySQL DBA

15
MySQL Database Administration Best Practices Lalit Choudhary

Transcript of MySQL DBA

Page 1: MySQL DBA

MySQL Database Administration Best PracticesLalit Choudhary

Page 2: MySQL DBA

Agenda

▪Database design and Planning▪MySQL Installation and

Configuration ▪Optimization▪ Replication▪Backup and Monitoring▪Q&A

Page 3: MySQL DBA

Database design and planning● Outlining the functional specifications.

− Considering Application Workflow − Table Structure and Naming conventions − Workbench ERD

● Scope and Flexibility of database design.− Easy to extend− Capability to Handle large volume of data−

● ●

Page 4: MySQL DBA

MySQL Installation and Configuration● Ways to install MySQL

− Source code− Binaries− Packages− MySQL Installer MSI and ZIP Archive− Yum repository

● Configuration− Storage engine− Variables − User management and Access control

Page 5: MySQL DBA

Optimization

● Hardware− Storage and file types : SSD/HDD and EXT4 or XFS

on Linux− Memory : Optimal performance,Large

transaction,indexes,faster response time for ongoing changes and utilize Disk IO

− CPU : Faster processors with many cores provide better throughput

Page 6: MySQL DBA

Optimization

● Software− Configuration

● innodb_file_per_table● innodb_buffer_pool_size● innodb_buffer_pool_instances● innodb_log_file_size● innodb_flush_log_at_trx_commit● innodb_thread_concurrency● innodb_flush_method

Page 7: MySQL DBA

Optimization

● Query Optimization− indexes

● Replication − Read write Load Balancing

Page 8: MySQL DBA

Replication

● Replication Components − MASTER : Binary log dump Thread(s)− SLAVE : Replication Threads − Binary Logs : SBR/RBR/Mixed − Relay Logs− Information files

Page 9: MySQL DBA

Replication ● Important variables and configuration

− Master● server_id● log_bin● binlog_format● binlog_row_query_log_event● binlog-do-db● binlog-ignore-db

Page 10: MySQL DBA

Replication

● slave● server_id● log_bin● binlog_format● log_slave_updates● relay_log=file_name ● replicate-do-db=db_name● replicate-ignore-db=db_name● replicate_wild_do_table● replicate_wild_ignore_table

Page 11: MySQL DBA

Replication● Best practices

− Enable binary logs on slave● log_bin● log-slave-update● expire_log_days

− Crash-safe slaves ● master-info-repository=TABLE● Relay-log-info-repository=TABLE● Relay-log-recovery

− Secure slave● read-only● Skip-slave-start

− Avoid replication Lag ● slave_compressed_protocol● MTR replication

Page 12: MySQL DBA

Replication● With and without GTID

● Need Master_Log_File and Master_Log_Pos● GTID

− What problems GTID solves?● It is possible to identify a transaction uniquely across the

replication servers. Make the automation of failover process much easier. There is no need to do calculations, inspect the binary log and so on. Just MASTER_AUTO_POSITION=1.

● − Enable GTID replication

● gtid_mode: It can be ON or OFF (not 1 or 0). It enables the GTID on the server.

● log_bin: Enable binary logs. Mandatory to create a replication environment.

● log-slave-updates: Slave servers must log the changes that comes from the master in its own binary log.

● Enforce-gtid-consistency : Statements that can’t be logged in a transactionally safe manner are denied by the server.

 \\\

Page 13: MySQL DBA

Backup and Monitoring● Binary Backup

− MySQL Enterprise Backup ● Logical Backup

− mysqldump● Hot Backup

− Replication slave● Customized scripts

Page 14: MySQL DBA

Backup and Monitoring

● Monitoring and statistics − SHOW PROCESSLIST− System databases − Enterprise Monitoring(MEM)− MySQL Utilities− Audit logs & General logs−

Page 15: MySQL DBA

Thank you!