May 19, 2004, 19: 53linux system optimization
Reference: Linux Debian Reference Manual http://qref.sourceforge.net/debian/reference/reference.zh-.html #Contents Linux system performance tuning http://www-900.ibm.com/developerWorks/cn/ Linux / management / tune / index.shtml # 2 For Intel? Pentium? 4 processor optimized Linux * kernel http://support.intel.com/support/cn/platform/petium4/linux.htm Linux process management http: / / www0.ccidnet.com/tech/OS/2001/03/19/58_1848.html Linux system call list http://www-900.ibm.com/developerworks/cn/linux/kernel/syscall/part1/Appendix. SHTML network traffic statistics analysis tool MRTG detection Linux network performance http://www.linuxaid.com.cn/Articles/9/2/920785824.SHTML Linux Concise System Maintenance Manual http://www.linuxaid.com.cn/articles / 5/1/515140392.SHTML MAGIC Linux Development Headquarters http://www.magiclinux.org/ http://www.magiclinux.org/drupal/?q=node&from=14 Linux is very space http://linux.tcpip .com.cn /
Grid Oracle RAC installation process Http://www.chinaitlab.com/www/news/Article_show.asp?id=18626 China IT Certification Lab http://www.chinaitlab.com/www/index.asp
LINUX optimization provided by BEA http://edocs.bea.com/wls/docs81/perform/index.html
First, adjust the hard disk parameters
Using the HDPARM tool can adjust the IDE hard disk performance, it is designed to consider using the UDMA drive. By default, Linux is safe to use, but the setting access IDE drive is the slowest. The default mode does not use UDMA possible fastest performance.
Using HDPARM tools, by activating the following features can be significantly improved:
32-bit supporting the default setting is 16 bits; multi-part access default settings are all interrupts.
Note: Before using HDPARM, make sure you have made a complete backup. Use HDPARM to change the IDE parameter, if an error may cause loss of all data on the drive.
HDPARM can provide a lot of information about the hard disk. Open a terminal window, enter the following command to get information about the first IDE drive in the system (change the device name to get information about other IDE drives):
HDPARM -V / DEV / HAD
The above command displays the information obtained from the drive when the system is started, including the drive operation under the 16-bit or 32-bit mode (I / O Support), whether it is multiple access (multcount). The display of more detailed information about the disk drive can use the -i parameter.
HDPARM can also test the drive transfer rate. Enter the first IDE drive in the command test system:
HDPARM-TT / DEV / HDA
This test can measure the speed of the drive directly read and the cache read. The result is an optimized "best example" number. Change the drive settings, activate 32-bit transmission, enter the following command:
HDPARM-C3 / DEV / HDA-C3 parameter activates 32-bit support, using -c0 can cancel it. -c1 parameters can also activate 32 bits support and use fewer memory overhead, but it does not work in many drives.
Most new IDE drives support multiple partial transmissions, but Linux defaults set to single-part transmission. Note: This setting is on some drives, activating multi-part transfer can cause complete crash of the file system. Most of this problem occurs on older drives. Enter the following command to activate multiple transmission:
HDPARM -M16 / DEV / HDA
-m16 parameter activation 16 partial transmission. In addition to the drive of the western data, most drivers are set to 16 or 32 parts. The driver buffer of the western data is small, and the performance will be significantly decreased when the setting is greater than 8. For the western data drive, it is the most appropriate to set to 4.
Activating multi-part access can reduce CPU load 30% to 50%, while adding data transfer rates to 50%. Use the -m0 parameter to cancel multiple transmissions.
HDPARM also has many options to set hard drives, which are not detailed.
Second, use software RAID
The redundant array of RAID, can also improve the performance and capacity of disk drives. Linux supports software RAID and hardware RAID. Software RAID is embedded in the Linux kernel, which is much less than the hardware RAID. The only cost of software RAID is the disk in the system, but the software RAID cannot enhance the performance of hardware RAID. Hardware RAID uses specially designed hardware, control system multiple disks. Hardware RAID may be expensive, but the resulting performance improvement is matched. The basic idea of RAID is to combine multiple small, inexpensive disk drives into a disk drive array, providing the same performance level as a single large drive in a large computer. The RAID drive array is like a single drive for your computer, and it can also use parallel processing. Disk read and write in parallel data paths of RAID disk arrays.
IBM initiated a study at California, a RAID level, an initial definition. There are now six defined RAID levels as shown below.
RAID 0: Level 0 is just a data band. In level 0, the data is split to more than one driver, and the result is a higher data throughput. This is the fastest and most effective form of RAID. However, there is no data image at this level, so the failure of any disks in the array will cause loss of all data.
RAID 1: Level 1 is a complete disk image. Create and support both copies of data on a stand-alone disk. Level 1 array compared to a drive fast, slow writing, but if any drive is wrong, there will be no data loss. This is the most expensive RAID level because each disk requires a second disk as a mirror. This level provides the best data security.
RAID 2: Level 2 Venue a drive for embedded error detection. Because all SCSI drives support embedded error detection, this level is out of time, basically useless. Linux does not use this level.
RAID 3: Level 3 is a disk belt with parity disks. Store parity information to a stand-alone drive that allows you to recover errors on any single drive. LINUX does not support this level.
RAID 4: Level 4 is a large block with a parity disk. The parity information means that any disk failure data can be recovered. Level 4 arrays are very good, slow written speed, because parity data must be updated each time.
RAID 5: Level 5 is similar to the level 4, but it distributes parity information into multiple drives. This increases the disk write speed. It is the same as level 4 of each megabytes, and high-level random performance under high level data is improved, which is the most widely used RAID system.
Software RAID is level 0, which makes multiple hard drives look like a disk, but the speed is much faster than any single disk because the drive is connected in parallel. Software RAID can use an IDE or SCSI controller or any disk combination. Third, configure the kernel parameters
Improve performance by adjusting system kernel parameters is sometimes obvious. If you decide to do this must be careful, because the system kernel changes possible to optimize the system, it may also cause the system to crash.
Note: Do not change the kernel parameters on a system that is in use because there is a risk of system crash. Therefore, it is necessary to test on a system that no one is used. Set a test machine to test the system to ensure that all work is normal.
TWEAK memory performance
In Linux, you can TWEAK system memory. If you encounter insufficient memory or the system is used for network, you can adjust the memory allocation settings.
Memory is generally assigned by 4 kilobytes per page. Adjust the "blank page" settings can be significantly improved in performance. Open the terminal window, enter the following command to view the current settings of the system:
CAT / Proc / Sys / VM / FREEPAGES
This will get three numbers, just like this:
128 256 384
These are the smallest blank page, blank page low and blank page high setting. These values are determined at startup. The minimum setting is twice that of the number of memory in the system; the low setting is 4 times the amount of memory; the high setting is 6 times the system memory; free memory cannot be less than the minimum blank page.
If the number of blank pages is below blank page high setting, the exchange (with disk space is assigned to the swap file). The intensive switch begins when the blank page is low.
Increasing blank page high settings can sometimes improve overall performance, such as adding high setting to 1MB, using the echo command to adjust this setting. Use the sample settings, enter this command to add blank page to 1MB:
Echo "128 256 1024"> / Proc / Sys / VM / FreePages
Note: This setting is not tested when the system has not been used to ensure monitoring system performance when doing any adjustment. This makes it possible to determine which setting is the best to the system.
4. Process Management Linux is a multi-user operating system. Multi-user means that multiple users can use a computer system at the same time; multitasking means that Linux can execute several tasks at the same time, which can perform another task while not completing a task.
The operating system manages the requests and multiple tasks of multiple users. Most systems have only one CPU and a main memory, but a system may have multiple secondary storage disks and multiple input / output devices. The operating system manages these resources and shares resources between multiple users. When you ask a request, give you a description, as if the system is only occupied by you alone. And actually operating the system monitors a task queue waiting for execution, including user jobs, operating system tasks, emails, and print jobs. The operating system assigns the appropriate time slice for each task according to the priority of each task, each of which is approximately zero points, although it looks short, but it is actually enough to complete thousands of instructions. . Each task will be run for a while, then hang, and the system is turned to handle other tasks; after a while, it is back to handle this task until a task is completed, removed from the task queue.
I. All running things on the process and homework Linux system can be called a process. Each user task, each system management daemon, can be called a process. Linux uses a minute management method to share all tasks to share system resources. What we are concerned about how to control these processes, allowing them to serve users well.
A comparative formal definition of the process is: a separate program running in its own virtual address space. Process and programs are different, the process is not a program, although it is generated by the program. The program is just a static instruction collection, does not account for the system's running resources; and the process is a program that can change, dynamic, using system running resources at any time. And a program can start multiple processes. The concept of processes and homework is also different. A working process is called a job, and the job can contain one or more processes, especially when the pipeline and redirect command are used.
The job control refers to the behavior of controlling the running process. For example, the user can hang a process, wait for a while, continue to execute the process. The shell will record all starting processes, during each process, the user can suspend the process or restart the process. Work control is a feature of many shells, including Bash and TCSHs, enables users to switch between multiple independent jobs.
For example, when the user edits a text file and needs to abort the editor to do other things, use job control, users can let the editor temporarily hang, returns the shell prompt to start doing other things. After the other things, the user can restart the pending editor, return to the place just stop, just like the user has never leaving the editor. This is just an example, and there are many other practical uses in job control.
Second, the startup process typed the program name of the program that needs to be run, and executes a program, in fact, it is started. Each process in the Linux system has a process number for system identification and scheduling process. There are two main ways to start a process: manual start and schedule start, the latter is set in advance, starting according to the user's request.
1. Manually start the command by the user, start a process directly, is a manual startup process. However, the manual startup process can be divided into front desk start and background startup.
The front desk start is the most common way to manually start a process. Generally, the user typed "LS -L", which has started a process and is a foreground process. At this time, the system is actually in a multi-process state. Perhaps some users will be confused: I only launched a process. But in fact, there are many runs in the background. The process that has been automatically started when the system starts. Other users quickly use "PS -X" to view after typing "ls -l" command, but did not see the LS process, and feel very strange. In fact, this is because the process of this process is too fast, and the process has been completed when using the PS.
Starting directly from the background a process is less used, unless the process is very time consuming, and the user does not have the result of the results. Suppose the user wants to start a process that needs to be run in a long time. In order not to make the entire shell in the formatting process, starting this process from the background is a wise choice.
2, dispatching is sometimes necessary to make some time-consuming time-time and occupying resources, these work is suitable for late night, at this time, users can schedule arrangements in advance, specify the time or occasion of the task run, and the system will automatically Complete all this work. To use the functionality of the automatic startup process, you need to master the following start commands.
The first important command is the AT command user uses the AT command to perform the specified command sequence at the specified time. That is, this command needs to specify a command, and an execution time can run normally. The AT command can only specify only time, or it can be specified at the time and date. It should be noted that there is a system discrimination issue at the specified time. For example: The user now specifies an execution time: 3:20 in the morning, and the time to send an AT command is 20:00 on the first day, then which day is the order? If the user is still working at 3:20, then the command will be completed at this time; if the user has exited the working status before 3:20, then the command will be implemented on the next morning. Below is the syntax format of the AT command :at [-v] [-q queue] [-f file name] [-mldbv] time
AT-C homework [job ...]
AT allows the use of a relatively complex specified time method, which can be accepted at the same day's HH: mm (hour: minute) time specified. If the time has passed, then it is performed on the second day. Of course, you can also use Midnight (late night), noon (noon), teatime (drink tea time, usually at 4 o'clock) to specify the time. The user can also use a 12-hour timing system, that is, after the time, add AM (morning) or PM (afternoon), it is morning or afternoon. You can also specify the specific date of the command execution, the specified format is Month Day or MM / DD / YY (month / day / year) or dd.mm.yy (day. Month. Year). The specified date must be followed behind the specified time.
The above introduction is an absolute timing method, in fact, it can also use the relative timing method, which is very good for orders that the order to be executed soon. The specified format is :now count time-units, now is the current time, time-units is a time unit, here can be Minutes, Hours (Hours), Days, Weeks (Week). Count is the amount of time, it is a few days, or a few hours, and so on.
There is also a timing method to use Today (Today), Tomorrow to specify the time of the completion command. The following examples illustrate the specific usage.
[Example] Specifies to execute an order at 5:30 pm today. Suppose it is currently 12: 30, on February 24, 2001, its command format is as follows:
AT 5:30 PM
AT 17:30
At 17:30 Today
AT Now 5 Hours
AT now 300 minutes
AT 17:30 24.2.99
AT 17:30 2/24/99
AT 17:30 Feb 24
The meaning of these commands is exactly the same, so it can be freely selected according to personal preferences and specific situations when scheduled time. The 24-hour timing method generally adopts an absolute time can avoid the occurrence of a timing error due to the user's own negligence, such as the above case, can be written:
AT 17:30 2/24/99
This is very clear, and others also understand.
For the AT command, the commands that require timing execution are read and executed from the standard input or using the -f option specified. If the AT command is executed from a Su command to the user shell, the current user is considered to be executing the user, all errors and output results will be given to this user. But if there is a message sent, it will be the original user, which is the owner of the shell when you log in. Perform the job in the Work Work at 10 am on July 31. In any case, the super user can use this command. For other users, whether it can be used depending on the two files: /etc/at.allow and /etc/at.deny.
The two commands described earlier in the cron command will complete certain tasks in a certain period of time, but pay attention to them can only be executed once. That is, when the command is specified, the system completes the task at the specified time, everything is over. But in many times, it is necessary to continuously repeat some commands, such as: a company automatically reports to the employee's activities every week, this time you need to use the cron command to complete the task. In fact, the cron command should not be started manually. The cron command is automatically started by a shell script when the system is started and enters the background (so do not need to use & symbol). The general user does not run the permission of the command, although the super user can start CRON manually, but it is recommended to put it in the shell script by the system itself.
First, the cron command searches for / var / spool / cron directory, looking for a crontab file named in the / etc / passwd file, which is found in the memory. For example, a user name foxy, the CRONTAB file it corresponds should be / var / spool / cron / foxy. That is, the crontab file named by the user is stored below the / var / spool / cron directory. The cron command will also search / etc / crontab file, which is written in different formats. After CRON starts, it will first check if the user sets the crontab file. If it is not transferred to the "sleep" state, the system resource is released. So the background process takes up a small resource. It is "awake" every minute to see if there is a command to run. After the command is executed, any output will be sent as a message to the owner of the crontab, or the user specified in the Mailto environment variable in the / etc / crontab file. Some of the working principle of CRON is briefly introduced, but the execution of the cron command does not require user interference; if the user needs to modify the command sequence to be executed in crontab, the crontab command is described below.
The crontab command crontab command is used to install, delete, or list a table for driving the cron background process. That is to say, the user puts the command sequence you need to perform in the crontab file to obtain execution. Each user can have its own crontab file. Let's take a look at how to create a CRONTAB file. The crontab file under / var / spool / cron cannot be created directly or directly. The crontab file is obtained through the crontab command. Now suppose there is a user name to foxy, you need to create a crontab file. First, you can use any text editor to create a new file, then write to the command you want to run and the time you want to perform regularly. The store is then exited. Assume that the file is / TMP/test.cron. Again is using the crontab command to install this file so that it is the user's crontab file. Type: CRONTAB TEST.CRON.
Such a crontab file is established. You can go to the / var / spool / cron directory below to find out more than a foxy file. This file is the desired crontab file.
How to enter the command and time you need to perform in the crontab file. Each line in this file includes six domains, where the top five domains are the time that the command is executed, and the last domain is the command to be executed. Spaces or tabs are separated by spaces between each domain. The format is as follows :minute hours day-of-month month-of-year day-of-week commands
The first one is minutes, the second item is the hour, the third one is the first few days, the fourth item is the first year of the year, the fifth item is a week of the week, the sixth item is to implement The command. These items cannot be empty and must be filled. If the user does not need to specify a few items, you can use * instead. Because * is a stroke manner, you can replace any character, so you can think that it is any time, that is, the item is ignored.
The process of hangs and recovery commands BG, the FG job control allows the process to hang the process and can restore the process of the process when needed, and will continue to run from the abstament after the operation is restored. As long as you press Ctrl Z on the keyboard to hang the current front desk job. After pressing Ctrl Z on the keyboard, the currently executed command CAT will hang. Use the jobs command to display the Shell's job list, including the specific job, job number, and the current state of the job. When the recovery process is executed, there are two options: put the pending job back to the front desk with the fg command; put the pending job in the background. Flexible use of the above commands will bring you great convenience.
Process View Because Linux is a multi-user system, sometimes you have to know what other users are doing now, and Linux is a multi-process system, often need to provide some allocation and management of these processes; and management, first, you must know the present Process situation: What are the processes? How is the process? and many more. So you need a process to see the work.
WHO Command This command is primarily used to see the current online user situation. This command is very useful. If the user wants to build instant messaging with other users, such as using the talk command, then the first thing to determine is that the user is indeed online, otherwise the Talk process will not be established. As another example, the system administrator wants to monitor each login user, and the WHO command should be used at this moment. The WHO command is very simple and can be used to accurately grasp the user's situation, so it is very extensive.
w Command This command is also used to display the user's situation that logs in to the system, but the WHO is different, the W command function is more powerful, but it can not only display anyone to log in to the system, but also display these users currently working, And statistics relatively more detailed and scientific relative to the WHO command, can think that the W command is a enhancement version of the who command. The display item of the W command is arranged in the following order: current time, the system starts to the current time, log in to the number of users, the system is in the average load of last 1 second, 5 seconds and 15 seconds. Then the data of each user, the item display order is as follows: login account, terminal name, remote hostname, login time, idle time, JCPU, PCPU, the command line that is currently running the process. Where JCPU time refers to all processes that are connected to the terminal (TTY). This time does not include past background work hours, but it includes time occupying the current running background job. The PCPU time refers to the time occupied by the current process (ie the process shown in the what item).
The PS command PS command is the most basic and very powerful process view command. Using this command can determine which processes are running and running, whether the process ends, there is no zombie in the process, which processes take up too much resources. In summary, all information can be obtained by executing the command.
The PS command is most commonly used to monitor the working conditions of the background process, as the background process is not communicating with the standard input / output devices on the screen keyboard, so if you need to detect the case, you can use the PS command. PS [Option] The command option is described below:
-e Displays all processes.
-f full format.
-H does not display the title.
-l long format.
-w wide output.
A Displays all processes on the terminal, including processes for other users.
R shows only the running process.
x Displays the process without the control terminal.
O [ | -] K1 [, [ | -] K2 [, ...]] According to the shortcut order specified in the shortcut button, the multi-stage sort order specified in the shortcut key is displayed. There is a default order specified for different formats of PS. These default sequences can be covered by the user's designation. The " " characters are optional, "-" characters are the direction of the pour finger.
The most commonly used three parameters are U, A, X.
The top command top command and the basic role of the PS command are the same, display the current process and other conditions; however, the TOP is a dynamic display process, that is, the current state can be continuously refreshed by the user button. If this command is executed at the front desk, it will exclusively, until the user terminates the program. More accurately, the TOP command provides real-time monitoring of the system processor. It will display the list of CPU most "sensitive" in the system. This command can be used according to the CPU. Memory use and execution time Sort the task; and many of the commands can be set by interactive commands or in a personal custom file.
Third, the process schedule When you need to interrupt a reception process, it is usually used to use the CTRL C key key; but for a background process, it is impossible to solve it. At this time, you must call the kill command. This command can terminate the background process. As for the termination of the reasons for the background process, it may be that the CPU time occupied by the process is too much; maybe this process has been hanged. In short, this is often happening.
The kill command ends the process by sending a specified signal to the process. If no send signal is specified, the default value is TERM signal. The TERM signal will terminate all processes that cannot capture the signal. As for those processes that can capture the signal, you may need to use a KILL (9) signal, which is not captured.
The syntax format of the kill command is simple, and there are roughly below:
Kill [-s signal | -p] [-a] process number ...
Kill -l [signal]