In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how to set the bandwidth of Linux instances and check whether CPU runs full or high. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Troubleshooting of Linux instance bandwidth and CPU running full or high
When using CVM ECS, if the speed of the service slows down, or if the ECS instance is suddenly disconnected, you can consider whether the server bandwidth and CPU run full or high. If you create an alarm task in advance, the system will automatically alert you when the bandwidth and CPU are full or high. Under Linux system, you can follow the steps below to troubleshoot:
Positioning problem. Find specific processes that affect bandwidth and CPU running full or high.
Analysis and processing. Check whether the processes that affect bandwidth and CPU running full or high are normal, and classify them.
For normal processes: you need to optimize the program or upgrade the server configuration.
For abnormal processes: you can check and kill the process manually or use third-party security tools to check and kill.
The relevant configuration and instructions in this article have been tested in the CentOS 6.564-bit operating system. The configuration of other types and versions of the operating system may vary. For details, please refer to the official documentation of the corresponding operating system.
If the CPU of the CVM ECS Linux system continues to run high, it will affect the system stability and business operation. This paper briefly explains the investigation and analysis of the problems with high occupancy rate of CPU.
The location of the problem of CPU running full or high
If the CPU of CVM ECS continues to run high, it will affect the stability of the system and business operation. On Linux systems, the common commands for viewing processes are as follows:
Ps-auxps-eftop
In Linux systems, the top command is usually used to view the load problems of the system and to locate processes that consume more CPU resources.
Operation steps
Connect to the ECS instance through the console management terminal, see using the remote connection feature to connect to the ECS instance.
Note: when the resource load is abnormal, it is usually impossible to connect remotely through SSH. It is recommended that you connect through the console management terminal.
Check the current operation of the system through the top command.
Top-17:27:13 up 27 days, 3:13, 1 user, load average: 0.02,0.03,0.05 Tasks: 94 total, 1 running, 93 sleeping, 0 stopped, 0 zombie% Cpu (s): 0.3 us, 0.1 sy, 0.0 ni, 99.5 id, 0.0 wa, 0.0 hi, 0.0 si, 0.1 st KiB Mem: 1016656 total, 946628 used, 70028 free 169536 buffers KiB Swap: 0 total, 0 used, 0 free. 448644 cached Mem PID USER PR NI VIRT RES SHR S% CPU% MEM TIME+ COMMAND 1 root 20 0 41412 3824 2308 S 0.0 0.4 systemd 2 root 20 00 S 0.0 MEM TIME+ COMMAND 00.04 kthreadd
For the load problem, you only need to pay attention to the first and third lines of the echo, as detailed below.
The first line of the top command displays 17:27:13 up 27 days, 3:13, 1 user, load average: 0.02,0.03,0.05 is the current time of the system, the time the system has been running so far, the number of users currently logged on to the system, and the system load, which is consistent with the query result of directly executing the uptime command.
The third line of the top command shows the overall usage of the current CPU resources, and the resource usage of each process is shown below.
Through the letter key P, the utilization rate of CPU can be arranged in reverse order, and then the processes with high CPU can be located in the system.
Note: with the letter key M, you can sort the system memory usage. If there is a multicore CPU, the numeric key 1 can show the load status of each core CPU.
The program file corresponding to each process ID can be viewed through ll / proc/PID/exe.
Analysis and treatment of full run or High run in CPU
If the CPU runs full or high, after confirming the specific process result, you need to terminate the abnormal process through the top command. For problems such as insufficient memory caused by the kswapd0 process, you need to upgrade the system specifications or optimize the program.
Use top to directly terminate processes that consume a lot of CPU
You can quickly terminate the corresponding abnormal process directly in the top runtime interface. The steps are as follows:
If you want to terminate a process, simply press the lowercase k key.
Enter the process PID that you want to terminate (the first column of the top output). For example, if you want to terminate a process with a PID of 86, enter 86 and press enter.
After the operation is successful, a message similar to Send pid 86 signal [15/sigterm] appears on the interface. Just press enter to confirm.
Kswapd0 process occupancy leads to higher CPU
The operating system uses a paging mechanism to manage physical memory, and the system will virtualize part of the hard disk space into memory use. Because the speed of memory is much faster than that of disk, the system has to change unwanted pages to disk and transfer needed pages to memory according to some paging mechanism.
Kswapd0 is the process responsible for paging in virtual memory management. Kswapd0 will perform a paging operation when the server is out of memory, which consumes a lot of host CPU resources. The steps are as follows:
View the kswapd0 process through the top command.
Check to see if the process is continuously non-sleeping and takes a long time to run. If so, it can be preliminarily determined that the system is continuing to change pages, and the kswapd0 process takes up a lot of CPU resources of the system.
You can further query the memory usage of the system and the processes in the system through free, ps and other instructions, and do further troubleshooting and analysis.
In view of the current problem of insufficient memory on your system, you can restart Apache to free memory.
Description: in the long run, you need to upgrade your memory.
Analysis and treatment of full bandwidth or high running
For the problem of full or high bandwidth caused by the normal process, the bandwidth of the server needs to be upgraded. For abnormal processes, it may be due to malware problems, or malicious access to some IP, or the service may be attacked by CC.
Typically, you can use the iftop tool or nethogs to see how much traffic is being consumed, and then navigate to a specific process.
Use iftop tool to troubleshoot
Install the iftop traffic monitoring tool inside the server.
Yum install iftop-y
When the public network bandwidth of the server is full, if you cannot log in remotely, you can enter the server through Aliyun terminal management, and run the following command to check the traffic usage:
Iftop-I eth2-P
Note: the-P parameter will display the request port. Execute the iftop-I eth0-P command to view the connection through which port of the server, as well as the private network traffic. Examples are as follows:
In the figure above, you can see that the high traffic consumption is the connection established on port 53139 and 115.205.150.235 on the server.
Execute the netstat command to reverse the process corresponding to port 53139.
Netstat-tunlp | grep 53139
After reverse checking, the vsftpd service on the server generates a lot of traffic. You can stop the service or use the iptables service to deal with the specified address, such as blocking the IP address or speed limit, to ensure that the server bandwidth can be used normally.
Use nethogs for troubleshooting
Install the nethogs traffic monitoring tool inside the server.
Yum install nethogs-y
Use the nethogs tool to view the process-level traffic information on the Nic. If it is not installed, you can install it by means of yum, apt-get, etc. Examples are as follows:
If the eth2 network card is full, execute the command nethogs eth2.
View the network bandwidth of each process and the corresponding PID of the process.
Determine the specific process that causes the bandwidth to run full or high.
If the process determines that it is malicious, you can terminate the program by executing kill-TERM.
Note: if it is a Web service program, you can use tools such as iftop to query the specific IP source, and then analyze whether the Web access log is normal traffic. Log analysis can be done using tools such as logwatch or awstats.
Using Web Application Firewall to defend against CC attacks
If your service is attacked by CC, please enable CC security protection in the Web App Firewall console as soon as possible.
Log in to the Web Application Firewall console.
In CC security, launch the status button and select normal in mode.
Thank you for reading! On how to set Linux instance bandwidth and CPU run full or high to check here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
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: 230
*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.