Introduction to Enterprise Production MySQL Optimization

Introduction to Enterprise Production MySQL Optimization

Compared with other large databases such as Oracle, DB2, SQL Server, etc., MySQL has its own shortcomings, but this does not reduce its popularity at all. For general individual users and small and medium-sized enterprises, the functions provided by MySQL are more than enough, and because MySQL is open source software, it can greatly reduce the total cost of ownership.

How does an enterprise optimize MySQL in production?

Reference answer:

a: Hardware optimization:

1. Use 64-bit CPU, at least 4 CPUs, and the larger the L2 cache, the better
2. The memory should be large. 32-64G can run 1-2 instances, and 96-128G can run 3-4 instances.
3. Use sas disk for mechanical disk, with a rotation speed of more than 15000, and use ssd if possible
4. Use raid10 for raid card
5. Multiple network cards, Gigabit or above
6. Do not use virtualization for databases, and the slave hardware should be better than the master

b: Operating system optimization

1. Choose x86_64 as the operating system and try to use xfs file system
2. Optimize disk storage parameters
3. Optimize kernel parameters
4. Optimize network, etc.

c: mysql architecture optimization

1. Configure the server to run multiple instances based on memory size
2. Master-slave replication uses mixed mode. Try not to synchronize across data centers. If you need to synchronize across data centers, try to use remote writing and local reading.
3. Regularly check and repair data differences between master and slave replication
4. Business splitting, search function does not use MySQL database to execute; some high-concurrency and general security businesses use nosql, such as memcache, redis, etc.
5. Add cache to the database front end, such as memcache, for user login and product query
6. Staticize dynamic data, staticize the entire file, and staticize page fragments
7. Database cluster read-write separation, one master and multiple slaves, cluster read-write separation through dbproxy
8. If a single table exceeds 8 million, the database and table will be split, such as manually splitting (login, product, order) into tables and databases.
9. Select backup from the database and perform backup of the database in separate tables and databases

d: MySQL database level optimization

1. Optimize my.cnf parameters
2. Optimize the design of database tables, including character sets, string length, creation of short indexes, and multiple use of composite indexes;
3. Optimize SQL statements and reduce the number of slow statements;

e: Database management process and system optimization

1. Human process: Development -> Core operation and maintenance/DBA
2. Test process: Intranet IDC test is performed online
3. Client management, PHPMYADMIN

f: MySQL database security optimization

1. The database is prohibited from setting up an external network
2. Optimize database file permissions;
3. Limit the permissions of authorized users, and try to use dedicated databases and dedicated users
4. Limit the operating rights of developers to the production database
5. Prevent SQL statement injection

Summarize

This is the end of this article on enterprise production MySQL optimization introduction. I hope it will be helpful to everyone. Interested friends can refer to: Detailed explanation of Oracle paging query performance optimization code, analysis of key points of ORACLE SQL statement optimization technology, introduction to C/C++ compiler optimization, etc. If you have any questions, you can leave a message at any time and the editor will reply to you in time.

You may also be interested in:
  • A brief talk about MySQL optimization tool - slow query
  • Solution to the problem "Table is already up to date" when optimizing a table in MySQL
  • 21 Best Practices for MySQL Database Performance Optimization

<<:  How to build nfs service in ubuntu16.04

>>:  Ubuntu16.04 builds php5.6 web server environment

Recommend

Vue implements multi-tab component

To see the effect directly, a right-click menu ha...

Ubuntu regularly executes Python script example code

Original link: https://vien.tech/article/157 Pref...

How to implement vue page jump

1. this.$router.push() 1. Vue <template> &l...

How to change the MySQL database file directory in Ubuntu

Preface The company's Ubuntu server places th...

Nginx installation detailed tutorial

1. Brief Introduction of Nginx Nginx is a free, o...

Linux command line quick tips: How to locate a file

We all have files stored on our computers -- dire...

Three methods of inheritance in JavaScript

inherit 1. What is inheritance Inheritance: First...

Example analysis of mysql stored procedure usage

This article describes the usage of MySQL stored ...

JavaScript String Object Methods

Table of contents Methods of String Object Method...

How to implement paging query in MySQL

SQL paging query:background In the company's ...

Implementation of tomcat image created with dockerfile based on alpine

1. Download the alpine image [root@docker43 ~]# d...

Detailed explanation of vue-router 4 usage examples

Table of contents 1. Install and create an instan...

Using zabbix to monitor the ogg process (Linux platform)

The ogg process of a database produced some time ...