1. Generate dump file
jmap -dump:live,format=b,file=heap-dump-1829.bin 32171
2. Check the disk space usage of subfolders
du -sh *
3. Monitor gc status in real time:
jstat -gcutil pid interval(ms)
4. Enable jmx remote monitoring:
Execute the foo.jar startup command
java -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar foo.jar
5. Create a class histogram
jcmd 32171 GC.class_histogram
6. Check tcpnumber of connections
netstat -nat|grep -i "80"|wc -l
7. Query process number
ps -ef | grep tomcat8
1. Sometimes you need to know which java applications are running on the linux server. You can search them with commands
View all java processes ps -ef|grep java
View the project process of the specified jar package ps -ef|grep xxx.jar
If you don’t want to stop it through the java stop command, you can directly use the Linux command to end the process kill - 9 4382 (This is the process number, which can be obtained by using the above view command)
You can also use the Linux cd command to switch to the path of the jar package, and then use java -jar xxx.jar & (adding the ampersand is If you want it to run in the background, it will be displayed if you don’t add it)
Search the file directory to find / -name xxx.jar, "/" specifies to search in the root directory, you can also specify the directory yourself, such as find /A -name xxx.jar Find in the A directory
Search directory find / aaa, which means searching for the folder name plus aaa in the root directory
2. Server Start Java projects on
springboot projects are all in jar form. You can execute the following command to start the project on the server (you can execute the command in the current directory of the jar, or you can execute the command at any location. When executing at any location Remember to write the complete jar package path)
1. java -jar xxx.jar You can start the project by pressing Enter, but when you press ctrl z to exit the command line, the Java process will also be closed and the project will be stopped.
2. nohup java -jar xxx.jar & , in this way the Java process will run in the background, and exiting the command line will not affect the project.
3. nohup java -Dspring.profiles.active=prod -jar xxx.jar & , formal projects generally have different configurations in different environments. You can specify which environment's configuration file to use in the command.
"=prod" is the naming rule for the application.yml configuration file in springboot,
General application-dev.yml development environment, application-prod.yml online environment
The above is the detailed content of What are the knowledge points of the Java project operation and maintenance manual?. For more information, please follow other related articles on the PHP Chinese website!