essential system administration 3rd edition phần 9 pot

111 235 0
essential system administration 3rd edition phần 9 pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

memory that they never actually use, and they may run successfully if this setting is enabled. Changing parameter values is accomplished by modifying the values in these values. For example, the following command changes the settings related to the buffer cache: # echo "5 33 80" > /proc/sys/vm/buffermem 15.4.2.5 Solaris On Solaris systems, you can view the values of system parameters via the kstat command.For example, the following command displays system parameters related to paging behavior, including their default values on a system with 1 GB of physical memory: # kstat -m unix -n system_pages | grep 'free ' cachefree 1966 Units are pages. lotsfree 1966 desfree 983 minfree 491 Figure 15-4 illustrates the meanings and interrelationships of these memory levels. Figure 15-4. Solaris paging and swapping memory lLevels As the figure indicates, setting cachefree to a value greater than lotsfree provides a way of favoring processes' memory over thebuffer cache (by default, no distinction is made between them because lotsfree is equal to cachefree). In order to do so, you should decrease lotsfree to some point between its current level and desfree (rather than increasing cachefree). Solaris 9 has changed its virtual memory manager and has eliminated the cachefree variable. 15.4.2.6 Tru64 Tru64 memory management is controlled by parameters in thesysconfig vm subsystem. These are the most useful parameters: vm_aggressive_swap: Enable/disable aggressive swapping out of idle processes (0 by default). Enabling this can provide some memory management improvements on heavily loaded systems, but it is not a substitute for reducing excess consumption. There are several parameters that control the conditions under which the memory manager steals pages from active processes and/or swaps out idle processes in an effort to maintain sufficient free memory. They are listed in Figure 15-5 along with their interrelationships and effects. Figure 15-5. Tru64 paging and swapping memory levels The default for vm_page_free_min is 20 pages. The value of vm_page_free_target varies with the memory size; for a system with 1 GB of physical memory, it defaults to 512 pages. The reserved value is always 10 pages. The other variables are computed from these values. vm_page_free_swap (and the equivalent vm_page_free_optimal) is set to the point halfway between the minimum and the target, and vm_page_free_hardswap is set to about 16 times the target value. Several parameters relate to the size of the buffer cache. vm_minpercent specifies the percentage of memory initially used for the buffer cache (the default is 10%).The buffer cache size will increase if memory is available. The parameter ubc_maxpercent specifies the maximum amount of memory that it may use (the default is 100%). When memory is short and the size of the cache corresponds to ubc_borrowpercent or larger, pages will be returned to the general pool until the cache drops below this level (and process memory page stealing does not occur). The default for the borrow level is 20% of physical memory. On file servers, it will often make sense to increase one or both of the minimum and borrow percentages (to favor the cache over local processes in memory allocation). On a database server, though, you will probably want to reduce these sizes. 15.4.3 Managing Paging Space Specially designated areas of disk are used forpaging. On most Unix systems, distinct, dedicated disk partitions—called swap partitions—are used to hold pages written out from memory. In some recent Unix implementations, paging can also go to special page files stored in a regular Unix filesystem. [26] [26] Despite their names, both swap partitions and page files can be used for paging and for swapping (on systems supporting virtual memory). NOTE Many discussions of setting up paging space advise using multiple paging areas, spread across different physical disk drives. Paging I/O performance will generally improve the closer you come to this ideal. However, regular disk I/O also benefits from careful disk placement. It is not always possible to separate both paging space and important filesystems. Before you decide which to do, you must determine which kind of I/O you want to favor and then provide the improvements appropriate for that kind. In my experience, paging I/O is best avoided rather than optimized, and other kinds of disk I/O deserve far more attention than paging space placement. 15.4.3.1 How much paging space? There are as many answers to this question as there are people to ask. The correct answer is, of course, "It depends." What it depends on is the type of jobs your system typically executes. A single-user workstation might find a paging area of one to two times the size of physical memory adequate if all the system is used for is editing and small compilations. On the other hand, real production environments running programs with very large memory requirements might need two or even three times the amount of physical memory. Keep in mind that some processes will be killed if all available paging space is ever exhausted (and new processes will not be able to start). One factor that can have a large effect on paging space requirements is the way that the operating system assigns paging space to virtual memory pages implicitly created when programs allocate large amounts of memory (which may not all be needed in any individual run). Many recent systems don't allocate paging space for such pages until each page is actually accessed; this practice tends to minimize per-process memory requirements and stretch a given amount of physical memory as far as possible. However, other systems assign paging space to the entire block of memory as soon as it is allocated. Obviously, under the latter scheme, the system will need more page file space than under the former. Other factors that will tend to increase your page file space needs include: Jobs requiring large amounts of memory, especially if the system must run more than one at a time. Jobs with virtual address spaces significantly larger than the amount of physical memory. Programs that are themselves very large (i.e., have large executables). This often implies the item above, but not vice versa. A very, very large number of simultaneously running jobs, even if each individual job is fairly small. 15.4.3.2 Listing paging areas Most systems provide commands to determine the locations of paging areas and how much of the total space is currently in use: List paging areas Show current usage AIX lsps -a lsps -a FreeBSD pstat -s pstat -s HP-UX swapinfo -t -a -m swapinfo -t -a -m Linux cat /proc/swaps swapon -s or free -m -o Solaris swap -l swap -l or -s Tru64 swapon -s swapon -s Here is some output from a Solaris system: swapfile dev swaplo blocks free /dev/dsk/c0t0d0s1 136,1 16 1049312 1049312 The Solaris swap command also has a -s option, which lists statistics about current overall paging space usage: total: 22240k bytes allocated + 6728k reserved = 28968k used, 691568k available Under AIX, the command to list the paging space information is lsps -a: $ lsps -a Page Space Phys. Volume Volume Group Size %Used Active Auto hd6 hdisk0 rootvg 200MB 76 yes yes paging00 hdisk3 uservg 128MB 34 yes yes The output lists the paging space name, the physical disk it resides on, the volume group it is part of, its size, how much of it is currently in use, whether it is currently active, and whether it is activated automatically at boot time. This system has two paging spaces totaling about 328 MB; total system swap space is currently about 60% full. Here is some output from an HP-UX system: # swapinfo -tam Mb Mb Mb PCT START/ Mb TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME dev 192 34 158 18% 0 - 1 /dev/vg00/lvol2 reserve - 98 -98 memory 65 32 33 49% total 257 164 93 64% - 0 - The first three lines of the output provide details about the system swap configuration. The first line (dev) shows that 34 MB is currently in use within the paging area at /dev/vg00/lvol2 (its total size is 192 MB). The next line indicates that another 98 MB has been reserved within this paging area but is not yet in use. The third line of the display is present when pseudo-swap has been enabled on the system. This is accomplished by setting the swapmem_on kernel variable to 1 (in fact, this is the default). Pseudo-swap allows applications to reserve more swap space than physically exists on the system. It is important to emphasize that pseudo-swap does not itself take up any memory, up to a limit of seven eighths of physical memory. Line 3 indicates that there is 164 MB of memory overcommitment capacity remaining for applications to use (32 MB is in use). The final line (total) is a summary line. In this case, it indicates that there is 257 MB of total swap space on this system. 164 MB of it is currently either reserved or allocated: the 34 MB allocated from the paging area plus 98 MB reserved in the paging area plus 32 MB of the pseudo-swap capacity. 15.4.3.3 Activating paging areas Normally, paging areas are activated automatically at boot time. On many systems, swap partitions are listed in the filesystem configuration file, usually /etc/fstab. The format of the filesystem configuration file is discussed in detail in Section 10.2, although some example entries will be given here: /dev/ad0s2b none swap sw 0 0 FreeBSD /dev/vg01/swap swap pri=0 0 0 HP-UX /dev/hda1 swap swap defaults 0 0 Linux This entry says that the first partition on disk 1 is a swap partition. This basic form is used for all swap partitions. Solaris systems similarly place swap areas into /etc/vfstab: /dev/dsk/c0t0d0s1 - - swap - no - Tru64 systems lists swap areas within the vm section of /etc/sysconfigtab: vm: swapdevice = /dev/disk/dsk0b On FreeBSD, HP-UX, Tru64, and Linux systems, all defined swap partitions are activated automatically at boot time with a command like the following: swapon -a > /dev/console 2>&1 The swapon -a command says to activate all swap partitions. This command may also be issued manually when adding a new partition. Solaris provides the swapadd tool to perform the same function during boots. Under AIX, paging areas are listed in the file /etc/swapspaces : hd6: dev = /dev/hd6 paging00: dev = /dev/paging00 Each stanza lists the name of the paging space and its associated special file (the stanza name and the filename in /dev are always the same). All paging logical volumes listed in /etc/swapspaces are activated at boot time by a swapon -a command in /etc/rc. Paging logical volumes can also be activated when they are created or by manually executing the swapon -a command. 15.4.3.4 Creating new paging areas As we've noted, paging requires dedicated disk space, which is used to store paged-out data. Making a new swap partition on an existing disk without free space is a painful process, involving these steps: Performing a full backup of all filesystems currently on the device and verifying that the tapes are readable. Restructuring the physical disk organization (partition sizes and layout), if necessary. Creating new filesystems on the disk. At this point, you are treating the old disk as if it were a brand new one. Restoring files to the new filesystems. Activating the new swapping area and adding it to the appropriate configuration files. Most of these steps are covered in detail in other chapters. A better approach is the subject of the next subsection. 15.4.3.5 Filesystem paging Many modern Unix operating systems offer a great deal more flexibility by supporting filesystem paging —paging to designated files within normal filesystems. Page files can be created or deleted as needs change, albeit at a modest increase in paging operating system overhead. Under Solaris, the mkfile command creates new page files. For example, the following command will create the file /chem/page_1 as a 50 MB file: # mkfile 50m /chem/page_1 # swap -a /chem/page_1 0 102400 The mkfile command creates a 50 MB page file with the specified pathname. The argument specifying the size of the file is interpreted as bytes unless a k (KB) or m (MB) suffix is appended to it. The regular swap command is then used to designate an existing file as a page file by substituting its pathname for the special filename. On HP-UX systems, filesystem paging is initiated by designating a directory as the swap device to the swapon command. In this mode, it has the following basic syntax: swapon [-m min] [-l limit] [-r reserve] dir min is the minimum number of filesystem blocks to be used for paging (the block size is as defined when the filesystem was created: 4096 or 8192), limit is the maximum number of filesystem blocks to be used for paging space, and reserve is the amount of space reserved for files beyond that currently in use which may never be used for paging space. For example, the following command initiates paging to the /chem filesystem, limiting the size of the page file to 5000 blocks and reserving 10000 blocks for future filesystem expansion: # swapon -l 5000 -r 10000 /chem You can also create a new logical volume as an additional paging space under HP-UX. For example, the following commands create and activate a 125 MB swap logical volume named swap2: # lvcreate -l 125 -n swap2 -C y -r n /dev/vg01 # swapon /dev/vg01/swap2 The logical volume uses a contiguous allocation policy and has bad block relocation disabled (-C and -r, respectively). Note that no filesystem is built on the logical volume. On Linux systems, a page file may be created with commands like these: # dd if=/dev/zero of=/swap1 bs=1024 count=8192 Create 8MB file. # mkswap /swap1 8192 Make file a swap device. # sync; sync # swapon /swap1 Activate page file. On FreeBSD systems, a page file is created as follows: # dd if=/dev/zero of=/swap1 bs=1024 count=8192 Create 8MB file. # vnconfig -e vnc0 /swap1 swap Create pseudo disk /dev/vn0c and enable swapping. The vnconfig command configures the paging area and activates it. Under AIX, paging space is organized as special paging logical volumes. Like normal logical volumes, paging spaces may be increased in size as desired as long as there are unallocated logical partitions in their volume group. You can use the mkps command to create a new paging space or the chps command to enlarge an existing one. For example, the following command creates a 200 MB paging space in the volume group chemvg: # mkps -a -n -s 50 chemvg The paging space will be assigned a name like pagingnn where nn is a number: paging01, for example. The -a option says to activate the paging space automatically on system boots (its name is entered into /etc/swapspaces). The -n option says to activate the paging space immediately after it is created. The -s option specifies the paging space's size, in logical partitions (whose default size is 4 MB). The volume group name appears as the final item on the command line. The size of an existing paging space may be increased with the chps command. Here the -s option specifies the number of additional logical partitions to be added: # chps -s 10 paging01 This command adds 40 MB to the size of paging space paging01. FreeBSD does not support filesystem paging, although you can use a logical volume for swapping in either environment. The latter makes it much easier to add an additional paging space without adding a new disk. 15.4.3.6 Linux and HP-UX paging space priorities HP-UX and Linux allow you to specify a preferred usage order for multiple paging spaces via a priority system. The -p option to swapon may be used to assign a priority number to a swap partition or other paging area when it is activated. Priority numbers run from 0 to 10 under HP-UX, with lower numbered areas being used first; the default value is 1. On Linux systems, priorities go from 0 to 32767, with higher numbered areas being used first, and they default to 0. It is usually preferable to give dedicated swap partitions a higher usage priority than filesystem paging areas. 15.4.3.7 Removing paging areas Paging spaces may be removed if they are no longer needed, unless they're on the root disk. To remove a swap partition or filesystem page file in a BSD-style implementation—FreeBSD, Linux, HP-UX, and Tru64—remove the corresponding line from the appropriate system configuration file. Once the system is rebooted, the swap partition will be deactivated (rebooting is necessary to ensure that there are no active references to the partition or page file). Page files may then be removed normally with rm. Under Solaris, the -d option to the swap command deactivates a swap area. Here are some examples: # swap -d /dev/dsk/c1d1s1 0 # swap -d /chem/page_1 0 Once the swap -d command is executed, no new paging will be done to that area, and the kernel will attempt to free areas in it that are still in use, if possible. However, the file will not actually be removed until no processes are using it. Under AIX, paging spaces may be removed with rmps once they are deactivated: # chps -a n paging01 # rmps paging01 The chps command removes paging01 from the list to be activated at boot time (in /etc/swapspaces).The rmps command actually removes the paging space. Administrative Virtues: Persistence Monitoring system activity levels and tuning system performance both rely on the same system administrative virtue:persistence. These tasks naturally must be performed over an extended period of time, and they are also inherently cyclical (or even recursive). You'll need persistence most at two points: When you are just getting started and don't have any idea what is wrong with the system and what to try to improve the situation. After the euphoria from your early successes has worn off and you have to spend more time to achieve smaller improvements. System performance tuning—and system performance itself—both follow the 80/20 rule: getting the last 20% done takes 80% of the time. (System administration itself often follows another variation of the rule: 20% of the people do 80% of the work.) Keep in mind the law of diminishing returns, and don't waste any time trying to eke out that last 5% or 10%. I l@ve RuBoard I l@ve RuBoard 15.5 Disk I/O Performance Issues Disk I/O is the third major performance bottleneck that can affect a system or individual job. This section will look first at the tools for monitoring disk I/O and then consider some of the factors that can affect disk I/O performance. 15.5.1 Monitoring Disk I/O Performance Unfortunately, Unix tools for monitoring disk I/O data are few and rather poor. BSD-like systems provide the iostat command (all but Linux have some version of it). Here is an example of its output from a FreeBSD system experiencing moderate usage on one of its two disks: $ iostat 6 tty ad0 ad1 cd0 cpu tin tout KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us ni sy in id 0 13 31.10 71 2.16 0.00 0 0.00 0.00 0 0.00 0 0 11 2 87 0 13 62.67 46 2.80 0.00 0 0.00 0.00 0 0.00 0 0 10 2 88 0 13 9.03 64 0.56 0.00 0 0.00 0.00 0 0.00 1 0 7 1 91 0 13 1.91 63 0.12 0.00 0 0.00 0.00 0 0.00 2 0 4 2 92 0 13 2.29 64 0.14 0.00 0 0.00 0.00 0 0.00 2 0 5 1 92 The command parameter specifies the interval between reports (and we've omitted the first, summary one, as usual). The columns headed by disk names are the most useful for our present purposes. They show current disk usage as the number of transfers/sec (tps) and MB/sec. System V-based systems offer the sar command, and it can be used to monitor disk I/O. Its syntax in this mode is: $ sar -d interval [count] interval is the number of seconds between reports, and count is the total number of reports to produce (the default is one). In general, sar's options specify what data to include in its report. sar is available for AIX, HP-UX, Linux, and Solaris. However, it requires that process accounting be set up before it will return any data. This report shows the current disk usage on a Linux system: $ sar -d 5 10 Linux 2.4.7-10 (dalton) 05/29/2002 07:59:34 PM DEV tps blks/s 07:59:39 PM dev3-0 9.00 70.80 07:59:39 PM dev22-0 0.40 1.60 07:59:39 PM DEV tps blks/s 07:59:44 PM dev3-0 61.80 494.40 07:59:44 PM dev22-0 10.80 43.20 [...]...07: 59: 44 PM 07: 59: 49 PM 07: 59: 49 PM DEV dev3-0 dev22-0 tps 96 .60 0.00 blks/s 772.80 0.00 Average: Average: Average: DEV dev3-0 dev22-0 tps 78 .90 1.12 blks/s 671.80 4.48 The first column of every sar report is a time-stamp The other columns give the transfer operations per second... command produces a report that describes all the filesystems, their total capacities, and the amount of free space available on each one (reporting sizes in KB) Here is the output from a Linux system: File system /dev/sd0a /dev/sd0g Kbytes 7608 491 55 used 63 69 45224 avail 478 0 capacity 93 % 102% Mounted on / /corp This output reports the status of two filesystems: /dev/sd0a, the root disk, and /dev/sd0g,... quota system, you must determine which filesystems need quotas In most situations, the filesystems containing user home directories are appropriate candidates for quotas Filesystems that are reserved for public files (for example, the root filesystem) probably shouldn't use quotas The /tmp filesystem doesn't usually have quotas because it's designed to provide temporary scratch space Many operating systems... quotaon command is used to activate the quota system and enable quota checking: # quotaon filesystem # quotaon -a The first command enables the quota system for the specified filesystem The latter enables quotas on all filesystems listed with quotas in the filesystem configuration file For example, the following command enables quotas for the /chem filesystem: # quotaon /chem Similarly, the command... filesystem's name, the total number of kilobytes on the disk, the number of kilobytes in use, the number of kilobytes available, and the percentage of the filesystem's storage that is in use It is evident that both filesystems are heavily used In fact, the /corp filesystem appears to be overfull As we've noted earlier, the operating system generally holds back some amount of space in each filesystem,... improve system performance To change the values of hardwired kernel parameters that cannot be modified dynamically How often you have to build a new kernel depends greatly on which system you are administering On some older systems (mid- 199 0s versions of SCO Unix come to mind), you had to build a new kernel any time you added even the smallest, most insignificant new device or capability to the system. .. The quot command breaks down disk space usage within a single filesystem by user This command is available on all of the systems we are considering except Linux.[28] quot has the following syntax: [28] Linux does provide it for xfs filesystems # quot file -system quot reports the number of kilobytes used by each user in the specified filesystem It is run as root (to access the disk special files) Here's... chem_domain#one /1 advfs rq 0 1 Solaris /dev/dsk/c0t3d0s0 /1 ufs 2 yes 1 1 rw,logging,quota See Section 10.2 for full details on the filesystem configuration file on the various systems On AIX systems, add a line like the following to the filesystem's stanza in /etc/filesystems: quota = userquota,groupquota Include the userquota keyword for standard disk quotas and the groupquota keyword for group-based... sections Under some circumstances, a filesystem's performance can begin to degrade when a filesystem is more than 80% -90 % full Therefore, it is a good idea to take any corrective action before your filesystems reach this level, rather than waiting until they are completely full 15.6.2.1 Using find to locate or remove wasted space The find command may be used to locate potential candidates for archival and... the -p option, as in this example from an HP-UX system: $ netstat -s -p tcp Output shortened tcp: 178182 packets sent 111822 data packets (35681757 bytes) 30 data packets (3836 bytes) retransmitted 66363 ack-only packets (4332 delayed) 337753 packets received 897 09 acks (for 35680557 bytes) 3 49 duplicate acks 0 acks for unsent data 284726 packets (28761 894 7 bytes) received in-sequence 0 completely duplicate . a Linux system: $ sar -d 5 10 Linux 2.4.7-10 (dalton) 05/ 29/ 2002 07: 59: 34 PM DEV tps blks/s 07: 59: 39 PM dev3-0 9. 00 70.80 07: 59: 39 PM dev22-0 0.40 1.60 07: 59: 39 PM DEV tps blks/s 07: 59: 44 PM. dev3-0 61.80 494 .40 07: 59: 44 PM dev22-0 10.80 43.20 07: 59: 44 PM DEV tps blks/s 07: 59: 49 PM dev3-0 96 .60 772.80 07: 59: 49 PM dev22-0 0.00 0.00 Average: DEV tps blks/s Average: dev3-0 78 .90 671.80 Average:. 0.00 0 0 10 2 88 0 13 9. 03 64 0.56 0.00 0 0.00 0.00 0 0.00 1 0 7 1 91 0 13 1 .91 63 0.12 0.00 0 0.00 0.00 0 0.00 2 0 4 2 92 0 13 2. 29 64 0.14 0.00 0 0.00 0.00 0 0.00 2 0 5 1 92 The command parameter

Ngày đăng: 14/08/2014, 02:21

Tài liệu cùng người dùng

Tài liệu liên quan