In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to generate the flame diagram in the container". In the daily operation, I believe that many people have doubts about how to generate the flame diagram in the container. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to generate a flame diagram in a container"! Next, please follow the editor to study!
Arthas (Alsace) is Alibaba's open source Java diagnostic tool, which is deeply loved by developers.
Arthas can help you solve problems like the following when you are at a loss as to what to do:
From which jar package was this class loaded? Why are all kinds of related Exception reported?
Why didn't the code I changed be executed? Is it because I don't have commit? Is the branch wrong?
If you can't debug online if you encounter a problem, can you only republish it by adding a log?
Online encounter a user's data processing problems, but online also can not debug, offline can not be reproduced!
Is there a global perspective to view the health of the system?
Is there any way to monitor the real-time running status of JVM?
I. background
Someone in arthas's github warehouse once mentioned such an issue. The error message is as follows:
Perf events unavailable. See stderr of the target process.
Why am I writing this blog? the author found in the official arthas warehouse that the official reply only points to the official address of async-profiler, and many people may be very confused when they go to the official async-profiler document along the given address. And the async-profiler description does not necessarily find a good solution. Therefore, the purpose of writing this blog is to help you have another solution to solve this problem later. Below, the author will take you step by step to solve the problem that arthas generates a fire diagram error in the container.
2. Generate flame image in alpine container image
How to add arthas to your image, please read the official website directly. If you don't know how to use arthas, please go to the official website to read the materials first.
Generate a flame diagram:
[arthas@1] $profiler startAsyncProfiler error: / opt/arthas/async-profiler/libasyncProfiler-linux-x64.so: libstdc++.so.6: cannot open shared object file or directory
After executing the command, it is found that there is a lack of libstdc++.so.6 library in the alpine basic image. Don't panic if anything happens, install libstdc++ now.
[root@node-znjj-131-146testYaml] # kubectl exec-it springboot-tomcat-deployment-7577ccdd9d-4rpc4 / bin/bashbash-4.4# apk add libstdc++fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gzfetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz(1/1) Installing libstdc++ (8.3.0-r0) Executing glibc-bin-2.29-r0.triggerOK: 32 MiB in 39 packages
After the installation is complete, execute the command to generate the flame diagram of arthas.
[arthas@1] $profiler startPerf events unavailable. See stderr of the target process.
No, there's a new problem. This problem usually occurs in a container environment. Arthus is actually done using async-profiler. The problem of modification is mentioned in the README of the official address of async-profiler.
Perf events unavailble. See stderr of the target process.
Perf_event_open () syscall has failed. The error message is printed to the error stream of the target JVM.
Typical reasons include:
/ proc/sys/kernel/perf_event_paranoid is set to restricted mode (> = 2). / proc/sys/kernel/perf_event_paranoid is set to restricted mode (> = 2)
Seccomp disables perf_event_open API in a container (seccomp disables perf_event_open API in the container.) .
OS runs under a hypervisor that does not virtualize performance counters. (the operating system runs under a hypervisor that does not virtualize performance counters.)
Perf_event_open API is not supported on this system, e.g. WSL. (the system does not support perf_event_open API, such as WSL.)
Let's take a look at the / proc/sys/kernel/perf_event_paranoid configuration item of the system.
Bash-4.4# cat / proc/sys/kernel/perf_event_paranoid2
It is found that the value of the system configuration parameter is indeed greater than or equal to 2. According to the official documentation. Try setting the value of / proc/sys/kernel/perf_event_paranoid to 1.
Bash-4.4# echo 1 > / proc/sys/kernel/perf_event_paranoidbash-4.4# bash: / proc/sys/kernel/perf_event_paranoid: Read-only file system
Indicates insufficient permissions. Then the problem arises again. Usually, the basic image is based on non-root permissions. If we insist on modifying this configuration item, the first thing that comes to mind may be to rebuild the image. Modify the user of the underlying image when building the image, and then set the system parameters.
This leads to new problems:
The change of the new basic image brings about security problems.
All necessary attempts to generate a changed base image of the flame image.
After a little thinking, we find that both kubernetes and docker allow us to change the permissions of the container.
You can specify it in docker using the-- cap-add SYS_ADMIN command option.
Docker run-- cap-add=SYS_ADMIN {container}
In kubernetes, you can set it through securityContext. To modify your deployment deployment file, refer to the configuration below.
Containers:-name: springboot-tomcat image: registry.cn-shanghai.aliyuncs.com/shalousun/springboot:2.3.4-tomcat imagePullPolicy: Always securityContext: capabilities: add: ["SYS_ADMIN"]
Just redeploy it in kubernetes after it has been configured. Once deployed, you can re-enter the container and follow the arthas official command normally.
[arthas@1] $profiler startStarted [cpu] profiling [arthas@1] $profiler getSamples3 [arthas@1] $profiler status [perf] profiling is running for 28 seconds [arthas@1] $profiler stopOKprofiler output file: / arthas-output/20201109-181906.svg at this point, the study on "how to generate a flame diagram in a container" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.