bitsCN.com
MYSQL DBA需要做的事儿
http://www.fastcloud.cn/zhishi/zhishi387.html
很早前就想写篇文章介绍一下互联网DBA需要干的一些事情,但苦于没有时间,忙于平台建设,最近,各个模块都初具规模,故有时间静下心来,介绍一下。
众所周知,互联网DBA与传统行业DBA有很大的不同,那就是管理的机器多,新技术更新快,面对的开发多、网络环境复杂、要求7*24待机;这样就导致互联网DBA的工作在传统DBA工作之上,增加了更多的复杂性,我们必须考虑如何大批量部署,如何集中化监控、如何解决单点故障而保障7*24,而为了做到这些,不是靠堆人力,我们必须有一个完整的平台作为支撑,那么数据库平台到底要建成什么样子呢?
1、强有力的监控系统(监+控):
监控是我们的眼睛,我们不可能7*24个小时盯着我们的DB,所以,我们需要监控系统来帮我们盯着,一旦异常,监控不仅仅通知我们,而必须要有控制,例如:MySQL 从库宕机了我们通过监控自动让其下线;从库同步状态失效了,可以自动修复同步等;并且,随着机器的增加、实例daemon的增加,我们会发现我们的手机报警会急剧增加,为了我们自己晚上能睡一个安稳觉,我们怎么去降低我们的报警,例如:哪些该短信,哪些该邮件;所有机器的磁盘空间报警是否可以整合后在报呢?这就是我们监控系统必须考虑的,
2、自动审核系统:
开发很多,项目很多,但是开发的习惯都不一致,可能会导致我们审核表结构的时头都看大了,为了保证线上的统一,为了保证不被开发的神奇SQL搞伤,不被N多的项目审核压垮,我们必须有一个自动建表审核系统,我们定义一些规则,如:不能用预留字段、主键必须为INT,BIGINT等,然后开发填写准备上线的表结构,通过系统自动审核,审核通过的,自动上线,审核不通过的,给出建议;
3、慢日志分析系统:
随着自动审核系统的上线,我们可能会漏掉一些索引使用不太好的SQL,那么我们就需要慢日志分系统帮助我们,在设计该系统时候,我们需要考虑是实时抓取慢日志,还是每天定期推送慢日志、慢日志抓取后是立即推送给开发还是自动分析完以后给出建议给开发、慢日志还要考虑一些SQL是否需要过滤,因为他可能是每天的统计,当然这些都是自动的,设计完后,不需要人工介入;
4、统计系统:
我们必须清晰的知道线上DB的整体运行情况,访问量的变化、写入量的变化、图是死的,他不会欺骗任何人;我们能通过访问统计知道是否有恶意访问、是否需要优化,是否需要增加节点抗住更大的压力;
5、备份系统:
不管你信不信,我是信了,冷备份总是我们的救命草,不管我们做的多么好,故障总会有,drop database也会发生,所以,一个完整的备份系统,势在必行,我们的备份是否正常,备份的数据是否能恢复,恢复需要多少时间,都是我们备份系统需要考虑的;
6、管理系统:
我们机器少则上百台,多则可能好几千,如何清晰知道每台机器跑了多少daemon,DB Proxy下面有哪些机器,如何能对主库机器、从库机器进行脚本分别分发等;都需要管理系统来帮我们完成;
7、中间层:
是把双刃剑,他能给我们带来好的扩展,例如:动态添加从库、主库失效检测等;但是他带来了DBA管理的复杂性、带来了更多的故障点、带来了更多的bug、如果DB Proxy性能不好的话,那就更糟了,并且为了解决client透明,我们必须考虑很多,例如:连接保持,如:字符集、last_insert_id、use dbname等;如果我们有人力开发维护,那么我相信Proxy会带给我们欢乐;
以上各个系统都是为我们管理DB提供支持,如果没有这些系统支持,那么数据库管理就谈不上平台,谈不上批量管理,谈不上承载百亿访问量,百T数据量的数据库;当然在涉及这样的系统时候,我们也要考虑新技术的引进,例如:如果能快速的打造NoSQL 平台等;当然在部署这些模块的时候,我们时时刻刻记得,所有的模块都是会变的,我们需要不停的学习,不停的改进,才会打造宕机时间更低的数据库服务。
后续会慢慢分享出,我们这些模块是如何做的,及其进度如何。
bitsCN.com
MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

MySQL is not a programming language, but its query language SQL has the characteristics of a programming language: 1. SQL supports conditional judgment, loops and variable operations; 2. Through stored procedures, triggers and functions, users can perform complex logical operations in the database.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is an open source relational database management system suitable for data storage, management, query and security. 1. It supports a variety of operating systems and is widely used in Web applications and other fields. 2. Through the client-server architecture and different storage engines, MySQL processes data efficiently. 3. Basic usage includes creating databases and tables, inserting, querying and updating data. 4. Advanced usage involves complex queries and stored procedures. 5. Common errors can be debugged through the EXPLAIN statement. 6. Performance optimization includes the rational use of indexes and optimized query statements.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

InnoDB's lock mechanisms include shared locks, exclusive locks, intention locks, record locks, gap locks and next key locks. 1. Shared lock allows transactions to read data without preventing other transactions from reading. 2. Exclusive lock prevents other transactions from reading and modifying data. 3. Intention lock optimizes lock efficiency. 4. Record lock lock index record. 5. Gap lock locks index recording gap. 6. The next key lock is a combination of record lock and gap lock to ensure data consistency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use