Using software to implement RAID functions under Linux _unix Linux

Source: Internet
Author: User

Data security is one of the most important problems people use in computers. Typically, a hard disk mirroring technique is used in a server environment to achieve a dual backup of the data. Also, we can use this technology in a Linux environment.

In the Linux environment, the use of raidtools tools, not only can be two hard disk mirroring, but also can make soft RAID0, RAID1, RAID5. Said to be soft raid, because the raid disk is usually done through a dedicated RAID card, and in a Linux environment, the Raidtools software can be used to implement RAID functions, so called soft raid. This article describes several ways to build and use a RAID disk based on different versions of Linux.

First, earlier versions of Linux

Download and compile the Raidtools software package, the earlier version of the Raidtools package named MD, has now been officially renamed Raidtools. Download address: China free Software Library.

If you have downloaded the RAIDTOOLS-0.41.TAR.GZ software package from the Internet, unzip it and compile it yourself as follows:

$gunzip-d raidtools-0.41.tar.gz

$TAR-XVF Raidtools-0.4.1.tar

Before using Raidtools, it is important to know whether the core currently in use supports MD. If you're using 2.0.X at the core, and you're not compiling it yourself, in most cases, soft raid is supported. If you are unsure, you should compile the core yourself. When configured, you should select support for Md. After determining which core support raid is being used, compile the Raidtools package as follows:

$CD raidtools-0.41

$./configure

$make

The $make install##make install produces a total of 4 devices under/dev md0-md3.

Click the OK button to complete the installation.

Before using Raidtools, you also need to determine the kind of raid you want to use. At present, the use of raidtools can be used as RAID0, RAID1 and RAID5. Because there are only two hard drives to use RAID5, in addition to RAID5, you can also choose Linear mode or RAID0. The author chooses to make RAID0. The following is the production process.

1. Set up RAID disk

(1) Shutdown, two small hard drives are added to the slave interface of the first IDE controller and the Slave interface of the second IDE controller (the CD-ROM on this machine is connected to master of the second IDE controller).

(2) Power on the boot system, log in as root, run the following command to partition the hard disk:

#fdisk/dev/hdb

Divide all the hard drives into one primary partition and create a/DEV/HDB1 partition.

#fdisk/dev/hdd

Also, divide all the hard drives into one primary partition, creating a/DEV/HDD1 partition.

(3) After:

#/sbin/mdcreate RAID0-C4K/DEV/MD0/DEV/HDB1/DEV/HDD1

Of course, in order to improve the speed of access, you can make the hard disk more detailed division, as far as possible to distribute the partition in a reasonable location on different hard drives. Then, use Mdcreate to combine them into an MDX (x:1,2,3).

2. Use RAID0 disk

(1) Launch the newly created RAID disk:

#/sbin/mdadd-ar

(2) View the contents of the/proc/mdstats file to check the status of the RAID0.

#cat/proc/mdstats

System display:

Personalities: [1 linear] [2 RAID0]

Read-ahead not 8092 sectors

Md0:active RAID0 hdb1 hdd1 xxxx

Blocks 8k chunks

Md1:inactive

Md2:inactive

Md3:inactive

This means that the new RAID0 is already working.

In order to use the new RAID disk, a new file system should be created on the new disk, as follows:

#mke2fs/dev/md0## Note: Establish EXT2 file system on new storage device

A new file system is created, and then it is put into a directory on the root directory, and it is officially used. The installation method is as follows:

#mount/dev/md0/opt # # Note:/opt for the author in the root partition built a mount point

If necessary, Raidtools can also be used to establish RAID5 to improve the reliability of the data.

3. Automatic execution of RAID0 settings

Add the RAID0 load and file system to the Init.sysinit file so that the user does not have to manually install the raid as soon as the system is started.

The user should add the following two commands to the Init.sysinit file.

/sbin/mdrun-ar

Mount/dev/md0/opt

Of course, if you don't feel the hassle, you can also manually run the above command to start the soft RAID disk in a manual manner.

Second, the more recent Linux version

If you install a newer version of Linux, which already has raidtools tools, then you don't have to download the software and compile it yourself. This can be done when used:

1. Establishment of a document/ETC/RAIDTAB (for example, for the production of RAID0), the document reads as follows:

Raiddev/dev/md0

Raid-level 0

Nr-raid-disks 2

Persistent-superblock 1

Chunk-size 4

Device/dev/hdb1

Raid-disk0

Device/dev/hdd1

Raid-disk1

2. Run the following command:

#mkraid/dev/md0

This allows you to generate a new device:

/dev/md0.

To enable soft RAID methods:

#raidstart/dev/md0

The rest of the operation ibid.

If you are using a new version of the Linux system that may not work for you in either case, then you can use soft raid in a third way.

Third, the latest Linux version

The author of a PC installed red Hat Linux 6.1, self-compiling Raidtools0.42, 0.50BETA2, first find the desired header file, the required header files copied, the compilation is still not pass. As a result, the new version uses a series of new functions, and the situation is slightly different. However, in the new release, Raidtools is provided, in the/sbin directory, a series of raidtools tools, including Mkraid, Raid0run, Raidstop, Raidstart, and so on. If you want to compile your own, you can find the latest version of the Raidtools from China free Software Library 0.9, compile the 0.9 version of the Raidtools, compile the normal pass.

The new version of the raidtools slightly different, the author uses the system from the Raidtools, making soft raid methods are as follows:

1. Establishment of document/ETC/RAIDTAB, which reads as follows:

Raiddev/dev/md0

Raid-level 0

Nr-raid-disks 2

Persistent-superblock0

Chunk-size8

Device/dev/hdb1

Raid-disk0

Device/dev/hdd1

Raid-disk 1

2. To generate a soft RAID device, run the following command:

# mkraid-c/etc/raidtab/dev/md0

Then, run the following command to view the current RAID status:

[root@rh61/proc]# Cat Mdstat

If the system appears as follows:

Personalities: [RAID0]

Read-ahead 1024 Sectors

Md0:active RAID0 hdd1[1] hdb1[0] 2202416 blocks 8k chunks

Unused devices:

It means your RAID0 is working properly.

3. Establishment of a new file system

Now, in order to use the newly generated device, we should set up the Ext2 file system on the new RAID disk, and the command to create the new file system is as follows:

[root@rh61/sbin]# mkfs.ext2/dev/md0

After about two or three minutes, the new file system is generated correctly. You can start using it now. Use the following methods:

[root@rh61/sbin]# mount-t ext2/dev/md0/opt

Hang the/dev/md0 device (Mount) to the/OPT installation point.

Thereafter, the author installed Sybase 11.0.3.3 on this soft raid disk. After testing, it is found that the performance of the whole RAID0 system is not bad.
Related Article

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.