I. concept: 1. use disk array RAID to translate it into Chinese as a redundant array of cheap disks. Disk Array 2 Common raid level: araid0: strip, data is distributed in order braid1: disk image, two disks in one group, write data together when writing data, read from any one of the following concepts:
1. Use a disk array
RAID is translated into "Redundant Arrays of cheap disks ". "Disk Array" for short"
2. Common raid levels:
A. raid 0: strip and distribute data in sequence
B. raid 1: disk image, a group of two disks. when writing, the two are written together and read from any disk.
C. raid 10: Disk mirroring and striping are performed first, which provides both the reliability of raid 1 and the excellent concurrency performance of raid 0.
D. raid 4: Strip the disk group like raid 0, and add a disk to write the verification and error data of each Stripe.
E. raid 5: write the verification and error correction data blocks of each strip to each disk, not to a specific disk.
3. select the raid level:
A. frequent read/write, high reliability requirements, raid 10
B. frequent reads and less writes, which requires reliability. raid 5
C. frequent reads and writes, low reliability requirements, rand 0
4. Virtual file volumes or soft raid
A. The Logical Volume system lvm2 in linux supports striping
B. The md driver in linux supports raid 0, raid 1, raid 4, raid 5, and raid 6.
5. use symbolic links to distribute I/O
A. You can use the operating system symbol to connect different databases, tables, or indexes to different physical disks to achieve disk I/O distribution.
B. direct a database to another physical disk
C. direct the data file or index file of the MyISAM table (not supported by other storage engines) to another physical disk.
1) you can add data directory and index directory to the create table.
2) for an existing table, you can transfer the data file or index file to the Target Disk. However, the table definition file must be located in the mysql data file directory and cannot be connected using symbols.
6. disable the OS from updating the atime attribute of the file.
7. adjust the I/O scheduling algorithm:
A. NOOP algorithm: it does not sort I/O requests, and is more suitable for random devices.
B. Deadline algorithm: when the system has a large number of ordered requests, Deadline may cause the requests to be unable to be sorted well and cause frequent seek.
C. expected algorithms: the prediction-based I/O algorithm is suitable for environments with a large number of writes and is not suitable for databases with a large number of random reads such as Mysql.
D. completely fair queue: put the I/O requests into the queue corresponding to the process according to the process. CFQ round-robin transfer queue based on the time slice algorithm
8. RAID card battery charging and discharging problems:
A. RAID card battery will automatically charge and discharge
9. RAID card cache policy:
10. I/O performance fluctuation caused by RAID card battery charging and discharging
A. According to the next charging and discharging time of the RAID card battery, charge and discharge are regularly performed in advance when the business volume is low.
B. set the Forced WriteBack write policy. at this time, backup power sources such as UPS must be available.
11. NUMA architecture optimization:
A. multi-processor marriage (SMP): There are ways to expand the memory, use faster CPU, increase CPU, expand I/O, and increase more disks.
B. The SMP architecture is restricted in scalability, and the NUMA architecture appears. NUMA divides a computer into multiple nodes. each node has multiple CPUs, and the node uses a common memory controller. the nodes communicate with each other through an interconnected module.
C. There are four memory allocation policies for NUMA:
1) default: always allocated on the local node
2) binding: forcibly assigned to a specified node
3) crossover: Cross-allocated memory on all or specified nodes
4) priority: Distribute data on the specified node. otherwise, allocate data to other nodes.
D. If a single machine runs only one mysql instance, you can disable NUMA.
1) set disable in BIOS
2) append numa = off to the kernel line of/etc/grub. conf.
II. practice:
Abc @ ubuntu :~ $ Dmesg | grep-I scheduler
[1.124750] io scheduler noop registered
[1, 1.124754] io scheduler deadline registered (default)
[1, 1.124837] io scheduler cfq registered
Abc @ ubuntu :~ $ More/sys/block/sda/queue/schedue
Noop [deadline] cfq
Note: for various reasons, other related experiments in this section will be done later.