Java interview finishing four - LINUX common instructions

1. Linux common commands
a) Top - macroscopically observe the CPU usage and memory usage of each process in the system
i. Process statistics (total processes, running processes, sleeping processes, etc.)
ii. CPU statistics (user CPU usage , kernel CPU usage, etc.)
iii. Memory information (total physical memory, used physical memory, free physical memory, total swap area, used swap area, etc.)
iv. Process details (id, percentage of CPU used, usage
v. top -H -p <pid> output the running status of all threads in a specific process b) Pidstat
- used to monitor the system resources occupied by all or specified processes Conditions, such as CPU, memory, device IO, task switching, threads, etc.
i. The command form is "pidstat [option] interval [count]"
ii. -u cpu usage statistics
iii. -r memory usage statistics
iv. -d IO statistics
v. -p statistics for specific processes
c) dstat - is a multifunctional product that can replace vmstat, iostat, netstat and ifstat commands.
By default, it is divided into five areas: CPU usage, disk statistics, network statistics, memory paging statistics, system information
i. -l: Display load statistics
ii. -m: Display memory usage (including used, buffer, cache, free value)
iii. -r : display I/O statistics
iv. -s : display swap partition usage
v. -t: display the current time on the first line
vi. –fs: display file system statistics (including total number of files and inodes value)
vii. –nocolor: no color (sometimes useful)
viii. –socket: Display network statistics
d) Netstat - Monitor TCP/IP network status
e) Ifstat - Statistics network interface traffic status
f) Vmstat - Display virtual memory status
g) Iostat - Monitor system input and output devices and CPU usage
h) Jps –l - Display the pid and class name of all java processes
i) Jstack - Output the thread stack information of the Java application
i. Jstack <pid> - View the stack status of the current process,
j) printf %x <pid> ——Get the hexadecimal value of pid
k) jstat ——A tool used to observe the running time of the java program,
i. -gc: Display heap information related to GC
ii. -gccapacity: Display the capacity and usage of each generation
l ) jinfo - view the JVM parameters of the running Java program, and support to modify individual parameters at runtime
jinfo [option] <pid>
i. -flags print the parameter value of the JVM
ii. -flag <name>=<value> set the specified JVM parameter value
iii. -flag [+|-]<name> Set the boolean value of the specified JVM parameter
m) jmap - can generate heap snapshots and object statistics of Java applications
jmap -histo 17338 > jmap.log
jmap -dump:format=b,file=heap.hprof 17338 generate snapshot information
n) jhat - yes Analyze the heap snapshot of the Java program
jhat heap.hprof Access the 7000 port through the browser to view the heap snapshot information
2. CPU usage efficiency monitoring
a) Use jps -l to find the pid of the java program
b) Use pidstat -p <pid> -u -t 1 3 Output the cpu usage of the pid process and find the thread with high cpu usage
c) Use top –p <pid> -H to view the thread with high cpu usage
d) Jstack <pid> > jstack.log Input thread Stack log
e) Printf %x <pid> Convert the pid to hexadecimal format
f) Analyze the related logs corresponding to nid=hexadecimal thread number in jstack.log
3. IO usage monitoring
a) Use jps –l to find java The pid of the program
b) Use pidstat –p <pid> -d -t 1 3 to output the IO usage of the pid process and find the thread with high IO usage
c) The subsequent analysis method is the same as the CPU analysis method
4. Memory usage monitoring
a) pidstat -p 17338 -r 1 3
5. GC efficiency monitoring

jstat -gc 12538 5000 will display the GC situation of java with process number 12538
every 5 seconds
.conf file
soft nofile 65535 hard nofile 65535
b) Enable timewait to quickly recycle
net.ipv4.tcp_tw_recycle = 1
c) The number of timewait, the default is 180000
net.ipv4.tcp_max_tw_buckets = 6000
d) Enable reuse. Allow TIME-WAIT sockets to be reused for new TCP connections
net.ipv4.tcp_tw_reuse = 1
e) Allow the system to open the port range
net.ipv4.ip_local_port_range = 1024 65000
f) Enable SYN Cookies, when the SYN wait queue overflows, Enable cookies for processing.
net.ipv4.tcp_syncookies = 1
g) The backlog of the listen function in the web application will limit the net.core.somaxconn of the kernel parameter to 128 by default, while the NGX_LISTEN_BACKLOG defined by nginx defaults to 511, so it is necessary to adjust this value
net.core .somaxconn=262144
h) The timeout period required by the local end to close the socket determines the time it remains in the FIN-WAIT-2 state. The default value is 60 seconds.
net.ipv4.tcp_fin_timeout=5
i) It means that when keepalive is enabled, TCP sends Frequency of leepalive messages. The default is 2 hours, change to 10 minutes.
net.ipv4.tcp_keepalive_time=600
j) Indicates the length of the SYN queue, the default is 1024, and the increased queue length is 10240, which can accommodate more network connections waiting to be connected.
Net.ipv4.tcp_max_syn_backlog=10240
k) Indicates that the establishment of The number of SYN packets to send before connecting, the default value is 5.
net.ipv4.tcp_syn_retries=1
l) The value of the parameter determines the number of SYN+ACK packets sent by the kernel before giving up the connection. The default value is 5.
net.ipv4.tcp_synack_retries=1

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326224754&siteId=291194637