为MySQL数据库的InnoDB引擎配置裸设备(Raw Device)
MySQL 的 InnoDB 存储引擎不仅可以缓存索引,而且还可以缓存数据,如果将其表和索引存储在裸设备(Raw Device)上,从而绕过了文件
MySQL 的 InnoDB 存储引擎不仅可以缓存索引,而且还可以缓存数据,如果将其表和索引存储在裸设备(Raw Device)上,从而绕过了文件系统的高速缓存和缓冲器而直接访问磁盘,,那么将大大降低Linux文件系统的负担,使系统性能获得显著改善。
另外,从裸设备在数据库应用的优化原理中,我们也可以看到优化数据库的一个基本方向,就是如何设法降低因数据库特有的 I/O 密集型访问所导致的文件系统的繁重负担。因此,即使在现有的基于文件系统的数据库存储引擎上,也可考虑使用特殊的文件系统挂载方式。
例如为存储数据库文件的分区使用 noatime 作为挂载参数,由于访问次数(access times)不再被记录 可以带来系统性能的一定程度的提升。
──────────────────────────────────────────────────────────────────────────────
本笔记最新配置之系统环境:
──────────────────────────────────────────────────────────────────────────────
OS: CentOS6
HDD: /dev/sdc /dev/sdd
RAW: /dev/raw/raw1 /dev/raw/raw2
MySQL: 5.1.61
USER: mysql:mysql
参考官方网站的配置指引:
──────────────────────────────────────────────────────────────────────────────
(1) 设置裸设备(Prepare the raw device)
──────────────────────────────────────────────────────────────────────────────
在使用裸设备之前,必须先将磁盘设备绑定到裸设备上:
# /bin/raw /dev/raw/raw1 /dev/sdc;
--------------------------------------------------------------------------------
/dev/raw/raw1: bound to major 8, minor 32
--------------------------------------------------------------------------------
再绑定另一个裸设备,然后还要让您的MySQL数据库的运行用户有权读写裸设备:
# /bin/raw /dev/raw/raw2 /dev/sdd;
# chown root:mysql /dev/raw/raw1 /dev/raw/raw2;
# chmod 0660 /dev/raw/raw1 /dev/raw/raw2;
# /bin/raw -qa;
# /bin/raw -q /dev/raw/raw1;
# /bin/ls -l /dev/raw/raw1;
# blockdev --report /dev/raw/raw1;
# blockdev --report /dev/sdc;
vi /etc/udev/rules.d/60-raw.rules;
--------------------------------------------------------------------------------
ACTION=="add", KERNEL=="sdc", GROUP=="mysql", MODE=="0660", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdd", GROUP=="mysql", MODE=="0660", RUN+="/bin/raw /dev/raw/raw2 %N"
--------------------------------------------------------------------------------
Note: this make sure device /dev/sdc and /dev/sdd will bind automatically when server reboot.
# vi /etc/udev/rules.d/41-local-permissions-rules;
──────────────────────────────────────────────────────────────────────────────
(2) 如有需要,先备份旧有的InnoDB数据表
──────────────────────────────────────────────────────────────────────────────
如果您的数据库已经运行,并且现有数据存储于旧的InnoDB引擎之中,如果您需要迁移的话,
请在关闭数据库之前预先用mysqldump命令导出您的数据, 等新引擎配置好之后再导入即可。
可参考如下SQL命令查看和导出您的InnoDB数据表:
mysql> SELECT table_schema,table_name,engine FROM INFORMATION_SCHEMA.TABLES;
mysql> SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine='InnoDB';
如有需要,可用mysqldump导出数据,请参考如下格式(请用相应的数据库和表名称):
mysqldump -u root -p -h localhost [database].[table] > database.table.sql
注意:您必须逐个表导出旧的数据。
──────────────────────────────────────────────────────────────────────────────
(3) 初始化阶段MySQL的配置
──────────────────────────────────────────────────────────────────────────────
When you create a new data file, put the keyword newraw
immediately after the data file size in innodb_data_file_path:
# vi /etc/my.cnf;
--------------------------------------------------------------------------------
[mysqld]
innodb_buffer_pool_size=128M
innodb_data_home_dir=
innodb_data_file_path=/dev/raw/raw1:64Mnewraw;/dev/raw/raw2:64Mnewraw
--------------------------------------------------------------------------------

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

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

Hot Topics



InnoDB is one of the database engines of MySQL. It is now the default storage engine of MySQL and one of the standards for binary releases by MySQL AB. InnoDB adopts a dual-track authorization system, one is GPL authorization and the other is proprietary software authorization. InnoDB is the preferred engine for transactional databases and supports transaction security tables (ACID); InnoDB supports row-level locks, which can support concurrency to the greatest extent. Row-level locks are implemented by the storage engine layer.

InnoDB is a storage engine that stores data in tables on disk, so our data will still exist even after shutdown and restart. The actual process of processing data occurs in memory, so the data in the disk needs to be loaded into the memory. If it is processing a write or modification request, the contents in the memory also need to be refreshed to the disk. And we know that the speed of reading and writing to disk is very slow, which is several orders of magnitude different from reading and writing in memory. So when we want to get certain records from the table, does the InnoDB storage engine need to read the records from the disk one by one? The method adopted by InnoDB is to divide the data into several pages, and use pages as the basic unit of interaction between disk and memory. The size of a page in InnoDB is generally 16

1. Roll back and reinstall mysql. In order to avoid the trouble of importing this data from other places, first make a backup of the database file of the current library (/var/lib/mysql/location). Next, I uninstalled the Perconaserver 5.7 package, reinstalled the original 5.1.71 package, started the mysql service, and it prompted Unknown/unsupportedtabletype:innodb and could not start normally. 11050912:04:27InnoDB:Initializingbufferpool,size=384.0M11050912:04:27InnoDB:Complete

1. Mysql transaction isolation level These four isolation levels, when there are multiple transaction concurrency conflicts, some problems of dirty reading, non-repeatable reading, and phantom reading may occur, and innoDB solves them in the repeatable read isolation level mode. A problem of phantom reading, 2. What is phantom reading? Phantom reading means that in the same transaction, the results obtained when querying the same range twice before and after are inconsistent as shown in the figure. In the first transaction, we execute a range query. At this time, there is only one piece of data that meets the conditions. In the second transaction, it inserts a row of data and submits it. When the first transaction queries again, the result obtained is one more than the result of the first query. Data, note that the first and second queries of the first transaction are both in the same

MySQL storage engine selection comparison: InnoDB, MyISAM and Memory performance index evaluation Introduction: In the MySQL database, the choice of storage engine plays a vital role in system performance and data integrity. MySQL provides a variety of storage engines, the most commonly used engines include InnoDB, MyISAM and Memory. This article will evaluate the performance indicators of these three storage engines and compare them through code examples. 1. InnoDB engine InnoDB is My

MySQL is a widely used database management system, and different storage engines have different impacts on database performance. MyISAM and InnoDB are the two most commonly used storage engines in MySQL. They have different characteristics and improper use may affect the performance of the database. This article will introduce how to use these two storage engines to optimize MySQL performance. 1. MyISAM storage engine MyISAM is the most commonly used storage engine for MySQL. Its advantages are fast speed and small storage space. MyISA

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Tips and strategies to improve the read performance of MySQL storage engine: Comparative analysis of MyISAM and InnoDB Introduction: MySQL is one of the most commonly used open source relational database management systems, mainly used to store and manage large amounts of structured data. In applications, the read performance of the database is often very important, because read operations are the main type of operations in most applications. This article will focus on how to improve the read performance of the MySQL storage engine, focusing on a comparative analysis of MyISAM and InnoDB, two commonly used storage engines.
