In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "Linux how to use software to achieve RAID", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Linux how to use software to achieve RAID" bar!
The security of data is one of the most important issues when people use computers. Usually, people will use hard disk mirroring technology in the server environment to achieve double backup of data. Also in the Linux environment, we can use this technology. In the Linux environment, we can use the Raidtool tool, not only can mirror two hard drives. You can also make soft RAID0, RAID4, & nbspRAID5. Soft RAID is said to be because raid disks are usually carried out through dedicated raid cards. In the Linux environment, we can use the software raidtool to achieve RAID function.
So it is called soft RAID. There are several ways to set up and use raid disks:
The first method:
Download and compile the raidtools package yourself. The earlier version of the raidtool package, called md, has now been officially renamed raidtool. Download address:
China Free Software Library, search for downloads through search engines.
If you have downloaded the raidtools-0.41.tar.gz package from the Internet. After unlocking it, compile it yourself. The steps are as follows:
$gunzip -d raidtools-0.41.tar.gz
$tar -xvf raidtools-0.4.1.tar
Before using raidtools, you first need to know whether the core currently in use supports md. If the core you are using is 2.0.x, and it is not
If you have compiled it yourself, it supports soft RAID in most cases. If you are not sure, you should compile the core yourself. When configuring, you should choose support for md.
Determine which core support RAID is in use. The raidtools package is compiled as follows:
$cd raidtools-0.41
$. / configure
$& nbspmake
$make install # # make install generates md0-md3 under / dev for a total of 4 devices.
OK, installation complete.
Before using raidtool, first decide what kind of RAID you want to use. At present, raidtool can be used as RAID0,RAID1,RAID5.
Because there are only two hard drives and cannot use RAID5, in addition to RAID5, you can also choose to be linear mode or RAID0. The author chose to be RAID0.
The following is the production process:
First, shut down and add two small hard drives to the slave interface of the first IDE controller. Connect the second hard drive to the slave on the second IDE controller
Interface (the CDROM on this machine is connected to the master of the second IDE controller).
Power up the system, log in as root, and run the following command to partition the hard drive:
# fdisk / dev/hdb
Divide all the hard drives into a primary partition and create a / dev/hdb1 partition.
# fdisk / dev/hdd
Similarly, all the hard drives are divided into a primary partition, creating a / dev/hdd1 partition.
After that:
# / sbin/mdcreate raid0 -c4k / dev/md0 / dev/hdb1 / dev/hdd1
Of course, in order to improve the access speed, you can divide the hard disk in detail and distribute the partitions on different hard drives as reasonably as possible. Then use it.
Mdcreate combines them into a single mdx (xpurl 1m 2pm 3)
In order to use the newly created RAID device, start it first:
# / sbin/mdadd -ar
After that, look at the contents of the / proc/mdstats file to check the status of RAID0.
# cat / proc/mdstats
The system displays:
Personalities:
Read_ahead not 8092 sectors
Md0: & nbspactive raid0 hdb1 hdd1 xxxx blocks 8k chunks
Md1: inactive
Md2: inactive
Md3: inactive
This means that the newly created RAID0 is up and running. In order to use the new raid disk, a new file system should also be created on the new disk, as follows:
# mke2fs / dev/md0 # # Note: establish an ext2 file system on a new storage device
Set up a new file system, and then mount it to a directory under the root, and you can officially use it. The installation method is as follows:
Finally, the loading of RAID0 and the mounting of the file system are all added to the init.sysinit file, so that as soon as the system starts, RAID is executed first.
Users no longer have to install it manually.
The user should add the following two commands to the init.syinit file.
/ sbin/mdrun -ar
Mount / dev/md0 / opt
Of course, if you don't find it troublesome, you can also run the above command manually to start the soft raid disk manually.
The second way: if you have a newer Linux distribution that already comes with the raidtool tool, you don't have to download the software and compile it yourself.
When you use it, you can do this:
First, create a file / etc/raidtab (take the production of raid0 as an example), with the following contents:
Raiddev / dev/md0
Raid-level 0
Nr-raid-disks 2
Persistent-superblock 1
Chunk-size 4
Device / dev/hdb1
Raid-disk 0
Device / dev/hdd1
Raid-disk 1
Then, run the following command:
# mkraid / dev/md0
This allows you to generate a new device: / dev/md0.
Enable the soft raid method:
# raidstart / dev/md0
The other operations are the same as above.
If the distribution you are using is very new and either of the following situations does not apply to you, you can use soft RAID in the following ways.
Red hat Linux 6.1is installed on one of the author's PC. When I compile raidtool0.42,0.50beta2 by myself, I can't find the desired header at first.
File, after the author will copy the required header file, the compilation still can not pass. It turns out that because the new release adopts a series of new functions, the situation is a little bit.
It's a little different. However, raidtools is available in the new release, and in the / sbin directory, there are a range of tools for raidtools, including
A set of tools such as mkraid,raid0run,raidstop,raidstart. If you want to compile it yourself, you can find it in the China Free Software Library.
The latest version of raidtool is 0.9. Self-compiled version 0.9 of raidtool. The compilation passed normally.
The new version of raidtool is slightly different. The author uses the raidtool that comes with the system to make soft RAID as follows:
1. First, create the file / etc/raidtab,2, which contains the following contents:
Raiddev / dev/md0
Raid-level & nbsp0
Nr-raid-disks & nbsp2
Persistent-superblock & nbsp0
Chunk-size & nbsp8
Device / dev/hdb1
Raid-disk & nbsp0
Device / dev/hdd1
Raid-disk & nbsp1
3. Generate soft raid devices. 4, 5. Run the following command:
# & nbspmkraid -c / etc/raidtab / dev/md0
After that, run the following command to see the current running status of RAID.
# & nbspcat mdstat
If the system displays as follows:
Personalities:
Read_ahead 1024 sectors
Md0: & nbspactive raid0 hdd1 hdb1 2202416 blocks 8k chunks
Unused devices:
Indicates that your RAID0 is working properly.
3. Establish a new file system
Now, in order to use the new equipment, we should build the ext2 file system on the new raid disk. The command to create the new file system is as follows:
# & nbspmkfs.ext2 / dev/md0
After about two or three minutes, the new file system is generated correctly. You can start using it now. The method of use is as follows:
# & nbspmount -t ext2 / dev/md0 / opt
Mount the / dev/md0 device to the / opt mount point.
# mount / dev/md0 / opt # # Note: / opt is a mount point built by the author in the root partition
Of course, you can also use raidtools to build raid5 if necessary. To improve the reliability of the data.
Since then, the author installed Sybase 11.0.3.3 on this soft raid disk, and after testing, it is found that the performance of the whole RAID0 system is good.
Finally, when using Raidtools, we should pay attention to: to use raidtool to make soft RAID, it is best not to divide multiple partitions on a hard disk, and then put this
These partitions are made into RAID with raidtool. Because this will not improve the access speed of the hard disk, but will reduce the performance of the refurbished system. To
To use a soft raid disk, it is best to divide a hard disk into multiple partitions, and then make different hard disk partitions into a soft raid disk. In addition, users had better not
To place the / usr directory on the raid disk. If the raid disk goes wrong, you're screwed. The swap partition of the system had better not be put on the raid disk.
Although some people think that this can improve the access speed, the author is worried that in case there are a lot of systems on the swap partition when you are using the system.
Then suddenly the raid disk went wrong, and it was over.
Thank you for your reading, the above is the content of "how Linux uses software to achieve RAID". After the study of this article, I believe you have a deeper understanding of how Linux uses software to achieve RAID, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.