Performance Tuning for Linux Servers [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Performance Tuning for Linux Servers [Electronic resources] - نسخه متنی

Sandra K. Johnson

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید



Preinstallation Planning



Before installing Linux on the system, there are several things worth considering that might help optimize the performance of the operating system and the applications that run on it later. These areas include the following:



Placing partitions



Using multiple hard drives



Selecting file systems



Converting file systems



Configuring RAID



Ready? Let's examine each in further detail.


Partition Placement



At a minimum, Linux requires a root and a swap partition. Where these and other frequently accessed partitions reside on disks ultimately impacts system performance. Following are some of the recommendations for placement of the root, swap, and other frequently accessed partitions that take advantage of the disk geometry:



Use separate partitions for root, swap, /var, /usr, and /home.



Most drives today pack more sectors on the outer tracks of the hard drive platter than on the inner tracks, so it's much faster to read and write data from the outer tracks. Lower-numbered partitions are usually allocated at the outer tracks (for example, /dev/hda1 is closer to the drive's outer edge than /dev/hda3), so place partitions that require frequent access first.



The first partition should be the swap partition (to optimize memory swap operations).



The next partition should be /var because log entries are frequently written to /var/log.



The next partition should be /usr, because base system utilities and commands are placed in /usr.



The root and /home partitions can reside near the end of the drive.



Now that we have considered how best to place the most frequently used partitions on a hard drive, we will look at how to take advantage of your multiple hard drivesif you have more than one in your system.


Using Multiple Hard Drives



Most systems today have more than one hard drive. If your system has only one drive, and if performance is really important to you (which is why you are reading this book in the first place!), you may need to seriously consider adding more drives to your system to improve performance. To take full advantage of multiple drives, you'll need to do the following:



Place frequently accessed partitions on the faster drives.



If the drives are relatively equal in performance, place frequently used partitions on alternate drives. For example, place /var on one drive and /usr on another drive. The swap partition should be on its own drive.



Consider using RAID if you have multiple drives with relatively equal performance. (This will be discussed in more detail later.)



Place each drive as the master device on its own I/O channel (for example, IDE) to maximize bus throughput. You will need to modify the file system table (/etc/fstab) after moving drives across I/O channels because the device name will change. If the drive contains the root or /boot partition, you need to edit the grub /boot/grub/menu.lst file as well.



When using multiple hard drives, you need to make some decisions in modifying the file system table. In the next section, we'll discuss selecting file systems.


Selecting File Systems



In addition to the original ext2 file system, new enterprise Linux distributions, such as RHEL 3, RHEL 4, and SLES 9, also support journaled file system technology, such as ext3 and ReiserFS. XFS is also included in several Linux distributions but may not be fully supported. Chapter 11, "File System Tuning," for a complete discussion of tuning file systems for improved performance on Linux.


Converting File Systems



If the existing file system is ext2, converting it to ext3 can be done using the tune2fs command. For example, if you want to convert the existing ext2 partition /dev/hda1 to ext3, issue the following command:



tune2fs j /dev/hda1


Converting to a file system type other than ext3 is more time-consuming. For example, to convert /usr, which is on /dev/hdb2, to ReiserFS, do the following:



Choose an empty partition that is larger than /dev/hdb2say, /dev/hdb3as a temporary partition.



Format the temporary partition:



mkreiserfs /dev/hdb3



Create a temporary directory:



mkdir /mnt/tempfs



Copy the contents of /usr to a temporary directory:



cp preserver=all R /usr/mnt/tempfs



Unmount /usr:



umount /usr



Unmount /mnt/tempfs:



umount /mnt/tempfs



Mount /usr on /dev/hdb3:



mount /dev/hdb3 /usr



Reformat the old /usr partition:



mkreiserfs /dev/hdb2 mount /dev/hdb2 /mnt/tempfs



Copy the contents of /usr back to its original partition:



cp preserve=all R /usr /mnt/tempfs



Unmount /usr:



umount /usr



Unmount /mnt/tempfs:



umount /mnt/tempfs



Remount /usr on its original partition:



mount /dev/hdb2 /usr



Repeat this process for other directories you want to convert.


The final step for preinstallation planning for optimization is configuring RAID.


Configuring RAID



RAID (Redundant Array of Inexpensive Disks) lets you configure multiple physical disks into a single virtual disk, thereby taking advantage of multiple disks and I/O channels working in parallel on a disk I/O operation. Many Linux distributions, especially enterprise versions, now provide RAID support. The easiest way to configure RAID is during installation. However, RAID can be configured on a preinstalled system as well. Here's how:



If new partitions are created, modify /etc/fstab appropriately. If the root and /boot partitions are on these new partitions, modify the /boot/grub/menu.lst file accordingly.



If existing partitions are combined to create a new RAID partition:



Verify that the raidtools package is present:



mkraid V



Verify that RAID support is compiled into the kernel:



cat /proc/mdstat



Create or modify /etc/raidtab. Create the following entry for each of the RAID devices:



/* Create RAID device md0 */
raiddev /dev/md 0 /* New RAID device */
raid-level 0 /* RAID 0 as example here */
nr-raid-disk 2 /* Assume two disks */
/* Automatically detect RAID devices on boot */
persistent-superblock 1
chunk-size 32 /* Writes 32 KB of data to each disk */
device /dev/hda1
raid-disk 0
device /dev/hdc1
raid-disk 1



Large chunk sizes are better when working with larger files; smaller chunk sizes are more suitable for working with smaller files.



Create the RAID device:



mkraid /dev/md0



View the status of the RAID devices:



cat /proc/mdstat



Format the RAID device with the ReiserFS file system, for example:



mkreiserfs /dev/md0



Modify /etc/fstab to indicate which partition(s) are on the RAID device. For example, to have /usr on the RAID device /dev/md0, make sure that the /usr line in /etc/fstab points to /dev/md0.



To squeeze the most performance out of the disk I/O subsystem, make sure that DMA and 32-bit transfers are enabled. This can be done via the hdparm utility, as follows (all commands are examples only):



Verify that DMA is enabled:



hdparm d /dev/hda



If DMS is not enabled, enable it by issuing the following command:



hdparm dl /dev/hda



Verify that 32-bit transfers are enabled:



hdparm c /dev/hda



If 32-bit transfers are not enabled, enable them by issuing the following command:



hdparm cl /dev/hda



Verify the effectiveness of the options by running simple disk read tests as follows:



hdparm Tt/dev/had



So far, we have discussed how best to set up the disk I/O subsystem for optimal performance. Now we need to look at two key configurable kernel features that are available on the 2.6 kernel. These 2.6 kernel features can impact performance for some application workloads.




/ 227