Article Title: how to implement software RAID in Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Data plays an important role in today's enterprises. The security of data storage is one of the important issues that people need to pay attention to when using computers. Usually, people use a variety of redundant disk array RAID technology on the server side to protect data. High-end servers generally provide expensive hardware RAID controllers, however, many small and medium-sized enterprises do not have enough funds to bear the expenses. Is there a way to implement RAID through software? In fact, in Linux, hardware RAID can be implemented through software, which saves both investment and achieves good results. Today, I will introduce how to implement a soft RAID 1 (data image) array with a Spare-disk in the network environment.
TIPS: What is RAID1 (data image )? RAID 1 is a reliable data storage method. Each disk has a corresponding image disk. Writing data to any disk will be copied to the image disk. The system can read data from any disk in a group of image disks, that is, the same data will be repeatedly written twice, such a disk image will definitely increase the system cost. Because the space we can use is only half of the total disk capacity.
Because mdadm is used in this article, and the software is usually integrated in Redhat linux, you can directly use it. If the system is not installed, you can go to the http://www.cse.unsw.edu.au /~ Neilb/source/mdadm to download the mdadm-1.8.1.tgz for compilation and installation, you can also go to the http://www.cse.unsw.edu.au /~ Neilb/source/mdadm/rpm download mdadm-1.8.1-1.i386.rpm for direct installation.
Step 1: log on to the system as the root user and partition the disk.
# Fdisk/dev/sdb
Divide all disk space on the device/dev/sdb into a primary partition, create a/dev/sdb1 partition, and change the partition type to fd (linux raid auto ), then, perform the same operation on the remaining disks. Create three partitions:/dev/sdb1,/dev/sdc1, And/dev/sdd1.
Step 2: Create a RAID Array
# Madam-cv/dev/md0-l1-n2-x1/dev/sd {B, c, d} 1
Tip: The-C parameter is used to create an array. /Dev/md0 is the device name of the array. -L1 is the array mode. You can select different array modes such as, and 5, which correspond to RAID 0, RAID 1, raid 4, and RAID 5 respectively. -N2 indicates the number of active disks in the array, and the number of additional disks must be equal to the total number of disks in the array. -X1 is the number of slave disks in the array. Because we use RAID1, we set that the current array contains a backup disk. /Dev/sd {B, c, d} 1 is the name of the disk that participates in the creation of the array. The array consists of three disks, two of which are the active disks of the image, A backup disk provides replacement after failure.
Step 3: View RAID Arrays
It takes a long time to create a RAID. Because the disk needs to be synchronized, you can view the/proc/mdstat file. The file displays the current RAID status and the time required for synchronization.
After the preceding prompt is displayed, the created RAID 1 is ready for use.
Step 4: edit the array configuration file
The configuration file of mdadm mainly provides daily management. editing this file can make RAID work better for us. Of course, this step is not necessary. RAID can also work without editing the configuration file.
First, scan all arrays in the system.
# Mdadm-detail-scan
The scan result displays the array name, mode, and disk name, and lists the UUID numbers of the array. The UUID also exists in each disk of the array, A disk without this number cannot be composed of arrays.
Next, edit the configuration file/etc/mdadm. conf of the array, modify the scan display result according to the file format, and add it to the end of the file.
# Vi/etc/mdadm. conf
Add the following content to the mdadm. conf file:
The array name and mode are defined in the configuration file, as well as the number and name of active disks in the array, and a backup disk group group1.
Step 5: start and stop the RAID1 Array
The command to start and stop the Raid 1 array is very simple. Run "mdadm-as/dev/md0" directly at startup. Run mdadm-s/dev/md0 to stop the RAID1 array. In addition, add the command mdadm-as/dev/md0 to the rc. sysinit STARTUP script file and set the array to start with the system startup.
Summary: The steps for configuring RAID1 are not very cumbersome compared with RAID5. However, when using mdadm, be sure not to divide multiple partitions on one hard disk and then combine multiple partitions into an array, this method not only does not increase the access speed of the hard disk, but also reduces the overall system performance. The correct method is to divide a hard disk into one or more partitions, and then combine multiple partitions of Different Hard disks into an array. In addition, it is recommended that the system directory such as/usr be not placed in the array, because the system will not run normally once an array is faulty.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service