In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the Linux commands commonly used by Mogujie engineers. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
First, check the log online there is a problem, logging on the online machine to check the log is a very common operation. When I first logged on to the online machine to check the log, I only remembered the following commands (suppose our log file is now called service.log):
Cat service.log
Tail-f service.log
Vim serivice.log
(obviously not enough)
Now the daily output size of the log is about 1GB:
Daily output 1GB size log daily output 1GB size log every day if it is a small file, a simple cat command can still deal with, but if you directly use the cat command to open a 1GB log file, make sure you are stuck (it takes a long time for ctrl + c to exit the cat command to stop the cat command).
Usually I only use cat to see what the text content of this small file is.
Similarly, if it is a small file, a simple vim command to open a file is also acceptable, but if you use the vim command to open a 1GB or larger file, you can obviously feel slow and stuttered.
Usually I still like to use vim to find the corresponding records, my general operation:
Vim service
Press G to jump to the end of the file
Press? + keyword to search for the corresponding record
Press n to query up and N to query down
Tail-f service.log this command is usually used to check whether the traffic is coming in (or you can see the log directly when debugging, and then quickly turn off ctrl + c)
In the face of relatively large log files, we have to cooperate with grep to play. For example, we now know that a mobile phone number cannot receive SMS verification code, and we want to see what the log of this mobile phone number is like. So we can do this:
Cat service.log | grep 13888888888
In this way, all the records containing 1388888888888 in service.log can be found, and the search speed is still fast.
Retrieve the log now we can find the corresponding record according to the keyword, and then I want to look at the log context of that record [so that we can know the approximate execution status of this data]
First, we need to find out the line number of the corresponding record and add a-n argument to the cat command. So the command is: cat-n service.log | grep 13888888888. We can find the corresponding line number in the following figure.
Look at the number of rows the number of rows is now 29506, we usually only need to look at the first 10 lines and the last 10 lines of 29506 to almost know where the problem is, so we can do this:
Sed-n "29496 people 29516p" service.log: search starts at line 29496 and ends at line 29516
Cat-n service.log | tail-n + 29496 | head-n 20: start with line 29496 and push forward 20 entries
If the keyword is not accurate (there are too many records in the log output), we can use the more command to browse or output to a file for analysis:
Cat service.log | grep 13 | more: send the queried result to more for output
Cat service.log | grep 13 > / home/sanwai/aa.txt write the result of the query to the / home/sanwai/aa.txt file
Sometimes, if we want to count how many lines are output from this log, we can use this command:
Cat service.log | wc-l
View the number of rows see the reference for the number of rows:
Https://www.cnblogs.com/xiashan17/p/7059978.html
2. There are two commands for checking the process and the port lookup process:
Ps-ef
Ps aux
The above two commands list all the processes, so we still filter out the processes we want to look up through | pipes and grep, for example: ps-ef | grep java
Why are you checking out the progress? Knowing its progress ID, we can kill him.
Kill-9 processId: kill a process
Looking up ports is also a common operation. Common command: netstat-lntup:
L:listening n:num t:tcp u:udp p:display PID/Program name for sockets
View the information of all current tcp/udp ports to view the details of a port: lsof-i 4000
View the details of a port 3. View the status of the system 3.1 TOP view the status of the process in real time TOP command to view the status of the process, there is a load average may not be so easy to understand, let's explain:
Load average: the average number of processes in the run queue (how many processes are running on CPU or waiting to run) during a specific interval.
Load average has three values, which represent the average number of processes in the queue of running processes within 1 minute, 5 minutes, and 15 minutes.
Running processes + average number of processes ready to run during a specific time (1 minute, 5 minutes, 10 minutes)
The Linux process can be divided into three states:
Blocking process
Runnable process
Running process
For example, now the system has 2 running processes and 3 runnable processes, then the load of the system is the average number of load in a certain period of time.
The idea of 3.2free looking at memory usage linux's memory management mechanism includes (I dare not say) maximizing memory utilization, the kernel will apply for the remaining memory as cached, and cached does not fall into the category of free.
If there is not enough memory in the free, the kernel will reclaim some of the memory from the cached and reallocate the reclaimed memory to the application. So for linux systems, the memory available for allocation is not only free memory, but also cached memory (and actually buffers).
Available memory = free memory + cached memory + buffers
Buffer Cache and Page Cache. The former is for the read and write of disk blocks, and the latter is for the read and write of file inode. These Cache effectively shorten the time it takes to make system calls such as read,write,getdents. Disk operations include logical level (file system) and physical level (disk block).
These are the Linux commands commonly used by Mogujie engineers that Xiaobian shares. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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: 0
*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.