Common tuning methods in linux and common tuning methods in linux

Source: Internet
Author: User

Common tuning methods in linux and common tuning methods in linux

Performance Tuning is one of the most important tasks for O & M engineers. If your production environment experiences slow system response speed, abnormal hard disk I/O throughput, and the data processing speed is lower than the expected value, or if the CPU, memory, hard disk, network, and other system resources are exhausted for a long time, this article will help you. If not, add them to your favorites first.

1. hdparm:

Command: hdparm-t/dev/sda5 print: Timing buffered disk reads: 254 MB in 3.01 seconds = 84.34 MB/sec Description: You can specify which hard disk to query!

2. iostat checks disk I/O status:

Format: iostat [-c |-d] [-k] [-t] [-V] [-x [device] [interval] Description: iostat is short for I/O statistics (input/output statistics). The iostat tool monitors disk operation activities of the system. It reports disk activity statistics and CPU usage. Like vmstat, iostat also has a weakness that it cannot perform in-depth analysis on a process, only the overall situation of the system is analyzed, and the detection statistics are collected once every 1 second (5 times in total ).

Number of data blocks read per second by blk_read/s

Blk_wrtn/s

Blk_read indicates the number of all data blocks read.

Blk_wrtn indicates the number of all data blocks written.

3. vmstat reports memory and CPU status:

Name: statistical information of the reported virtual memory. Format: vmstat [-n] [latency [times]

R: Number of processes that run and wait for the CPU time slice.Longer than the number of CPUs, indicating insufficient CPU
B: Number of processes waiting for resources,The problem may be in I/O or memory.
Swpd: Memory size for switching to the memory swap zone [in KB]
Free: Number of currently idle physical memory in KB
Si: Memory transferred from disk
So: Transferred from memory to disk
Bi: Total amount of data read from Block devices
Bo: Total data written to block Devices
Bi + bo 1000 if it exceeds 1000, the read/write speed of the hard disk is incorrect.
In: The number of device interruptions per second observed during a certain interval [too many interruptions may be poor performance]
Cs: Column indicates the number of context switches generated per second
Us + sy> 80% Insufficient CPU resources
Us: Percentage of CPU time consumed by user processes
Sy: Percentage of CPU time consumed by kernel Processes
Id: Percentage of time when the CPU is idle
Wa: Percentage of time occupied by IO wait
Runq-sz: Number of processes that can run in the memory
Plist-sz: Number of active tasks in the system

4. sar detection of CPU resources:

Task Plan/etc/cron. d/sysstat log directory/var/log/sa view method Sar-q-f/var/log/sa/sa10

5. lscpu displays CPU information:

Dmesg displays boot information. lscpu displays CPU information. lscpu-p displays the number of CPU nodes. getconf LONG_BIT indicates the number of host locations. getconf-a. View All parameters./sys/class/dmi/ id to view Bios information bios _*

6. Call the strace display program:

strace –fc elinks –dump http://localhost

7. Optimize the hard disk for Data Writing/reading first:

Read the amount of data to be written in advance, and then process the write request. The value read by the iterator will be half the set value.

Set the value to be read to the cache. The write speed slows down because of the large amount of data.

The larger the length of the/sys/block/sda/queue/nr_requests queue, the higher the hard disk I/O speed, but the memory occupied

/Sys/block/sda/queue/scheduler scheduling algorithm Noop, anticipatory, deadline, [cfq]

8. Separate the log function of the Ext3 File System:

1. Create a m/dev/sdb1 file, format it to ext32, dumpe2fs/dev/sdb1, and view has_journal3 and Tune2fs-O ^ has_journal/dev/sdb1 in the file system function. log function 4. Split the log into another MB partition. /dev/sdb2. the block of the log volume must be/dev/sdb1Mke2fs-O journal_dev-B 1024/dev/sdb25, And/dev/sdb2 must be used as the/dev/sdb1 log volume. tune2fs-j-J device =/dev/sdb2/dev/sdb1

9. Disable the recording file system atime:

Frequent modification of atime to website files does not make sense, and affects the performance of mount-o remount and noatime DEVICE.

10. Modify the file log submission time:

By default, logs are submitted once every 5 seconds. Modifying logs for a longer time can improve performance, but data is easy to lose. Mount-o remount, commit = 15 DEVICE
11. RAID round robin write optimization, suitable for 0/5/6:

Chunk size. The number of bytes written at a time. The default value is 64 KB. As long as it is not fully written, it will not be moved to the next device.

It is set to switch to the next hard disk if only one file is written on each hard disk. If it is a 1 K small file, system resources will be wasted on switching the hard disk.

If you set the chunk size value to a large value, such as 100 MB, it makes no sense. It is better to use a hard disk.

Stripe size. The size of the Strip. Instead of writing data when there is data, it sets the data volume to be written each time. Generally, it is written once at 16 kb.

So. Chunk size (64 K)/stripe size (16 K), that is, write each Hard Disk four times.

---------------------------------- Calculate how much chunk size should be adjusted ------------------------------------

Use iostat-x to view the average number of requests per second since startup avgrq-sz

Chunk size = number of requests per second * 512/1024/number of disks, taking an integer that is at least two multiples

Stride = chunk size/block (4 k by default)

Create raid and set chunk sinze

Mdadm-C/dev/md0-l 0-n3-chunk = 8/dev/sdb [0, 123

Modify raid

Mke2fs-j-B 4096-E stride = 2/dev/md0

12. Number of hard disk blocks retained:

Dumpe2fs/dev/sda1 tune2fs-m 10/dev/sda1 reserve block percentage tune2fs-r reserve the number of blocks is too small, affect performance, retain too much and waste hard disk, default is 5%

After learning the above performance tuning commands and methods, I would like to summarize the following golden statements:

The performance of independent devices is faster than that of integrated devices because they do not occupy the overall resources of hosts.

Engineers generally do not remotely manage computers and need to provide logs and other information.

The larger the disk space, the slower the reading speed. You can consider using multiple hard disks to form a large space.

Partitioning is only marked on the hard disk, but not formatted as a file system, so the speed is fast.

The faster the hard disk depends on the outside. [The smaller the Partition Number is, the more the disk depends on the outside area. Therefore, the larger the data volume, the first partition.]

Program developers focus on the functional requirements of employers, and system administrators focus on program resource overhead.

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.