安装bpftrace遇到的坑

与时俱进,因为很多高级特性其实是内核提供的,而非某语言或框架

前提先按我的文章:在centos7上升级linux kernel到5系列 https://blog.csdn.net/dong19891210/article/details/113750557, 升级下内核。

工作久了,想看看内核级的性能分析监控,至于它是什么,请详看https://github.com/iovisor/bpftrace,想必这是最早的钩子了(和spring aop或java agent不一样),感谢linux生态,其实很多公司的服务也是在它上面跑的, 比如云服务器,ecs,不一一举例了。

现象:  先安装bcc过程中,出现了以下级联错误,如图示

安装bpftrace遇到的坑_第1张图片

,既然这样的错误,那我就安装llvm

安装bpftrace遇到的坑_第2张图片

又出现gcc版本低的bug

安装bpftrace遇到的坑_第3张图片

 

1.  先升级gcc版本

安装bpftrace遇到的坑_第4张图片

注意,没升级之前是4.8.5

2. 依赖库

安装bpftrace遇到的坑_第5张图片

安装bpftrace遇到的坑_第6张图片

安装bpftrace遇到的坑_第7张图片

注意内存和空间也要大,要不然会出现以下内存溢出或存储空间不足的错误。

安装bpftrace遇到的坑_第8张图片

安装bpftrace遇到的坑_第9张图片

安装bpftrace遇到的坑_第10张图片

 

安装完毕后,就以最基本的hello world演示

安装bpftrace遇到的坑_第11张图片

 

文献:

  1. 7 tools for analyzing performance in Linux with bcc/BPF https://opensource.com/article/17/11/bccbpf-performance

  2. 「云原生技术研究」从BPFTRACE看如何利用EBPF实现内核追踪 http://blog.nsfocus.net/bpftrace-dynamic-tracing-0828/

  3. 强劲的Linux Trace工具:bpftrace (DTrace 2.0) for Linux 2018 https://cloud.tencent.com/developer/article/1442285

  4. LWN:简单又高效!利用bpftrace分析kernel行为 https://mp.weixin.qq.com/s/_69gYlpqqtP_wC044grgNA

  5. 用CMAKE的方始來編譯LLVM的KALEIDOSCOPE範例 https://hamisme.blogspot.com/2014/01/cmakellvmkaleidoscope.html

  6. https://goodtogreate.tistory.com/entry/LLVM-800-%EC%86%8C%EC%8A%A4%EC%BD%94%EB%93%9C%EB%A5%BC-%EB%B9%8C%EB%93%9C%ED%95%B4%EC%84%9C-%EC%84%A4%EC%B9%98%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95
  7. https://me.tryblockchain.org/eos-howtobuild.html
  8. How To Install GCC on CentOS 7  https://linuxhostsupport.com/blog/how-to-install-gcc-on-centos-7/

  9. Building GCC 9.2.0 on CentOS 7

    https://gist.github.com/nchaigne/ad06bc867f911a3c0d32939f1e930a11

  10. How to install GCC/G++ 8 on CentOS

    https://stackoverflow.com/questions/55345373/how-to-install-gcc-g-8-on-centos

  11. How to install GCC 8 and Clang/LLVM 6 on Red Hat Enterprise Linux 7 https://developers.redhat.com/blog/2019/03/05/yum-install-gcc-8-clang-6/

  12. Where is My Linux GNU C or GCC Compilers Are Installed? https://www.cyberciti.biz/faq/locate-linux-gnu-c-or-gcc-compiler-location/

  13. How to choose the default gcc and g++ version? https://askubuntu.com/questions/26498/how-to-choose-the-default-gcc-and-g-version

  14. How to Install LLVM on CentOS7 https://linuxhint.com/install_llvm_centos7/

  15. A collection of out-of-tree LLVM passes for teaching and learning https://awesomeopensource.com/project/banach-space/llvm-tutor

  16. eBPF (bcc) on centos

    https://stackoverflow.com/questions/45800090/ebpf-bcc-on-centos/53735868#53735868

  17. How To Install elfutils-libelf-devel-0.176-2.el7.x86_64 on CentOS7 http://yuminstall.org/how-to-install-elfutils-libelf-devel-0-176-2-el7-x86_64-on-centos7/

  18.  

    I Need the Kernel Source https://wiki.centos.org/HowTos/I_need_the_Kernel_Source

  19.  

    CentOS LuaJIT Installation instructions

     https://itekblog.com/centos-luajit/
  20. How Can I Test Network Performance? https://support.huaweicloud.com/intl/en-us/ecs_faq/en-us_topic_0115820205.html

  21. Tutorial: Creating an LLVM Backend for the Cpu0 Architecture https://jonathan2251.github.io/lbd/install.html

  22. Lesson 6: LLVM  https://www.cs.cornell.edu/courses/cs6120/2020fa/lesson/6/

  23. Building an LLVM-based tool. Lessons learned - Low Level Bits https://lowlevelbits.org/building-an-llvm-based-tool.-lessons-learned/
  24. Full-system dynamic tracing on Linux using eBPF and bpftrace https://www.joyfulbikeshedding.com/blog/2019-01-31-full-system-dynamic-tracing-on-linux-using-ebpf-and-bpftrace.html

  25. [译]使用 bcc/BPF 分析 go 程序

    https://colobu.com/2017/09/22/golang-bcc-bpf-function-tracing/
  26. Linux Performance: bpftrace https://wrightrocket.blogspot.com/2019/07/linux-performance-tool-bpftrace.html

     

  27. GCC vs. Clang/LLVM: An In-Depth Comparison of C/C++ Compilershttps://www.alibabacloud.com/blog/gcc-vs--clangllvm-an-in-depth-comparison-of-cc%2B%2B-compilers_595309

  28. 2019 LLVM Developers’ Meeting: S. Haastregt & A. Stulova “An overview of Clang ”https://www.youtube.com/watch?v=5kkMpJpIGYU

  29. bpftrace, uprobe and containers https://kirshatrov.com/2020/10/06/bpf-docker-uprobe/

  30. eBPF and Dynamic Tracing for MariaDB DBAs  https://mariadb.org/wp-content/uploads/2020/02/eBPF-and-Dynamic-Tracing-for-MariaDB-DBAs-MariaDB-Day-During-FOSDEM-2020.pdf
  31. Monitoring MariaDB Server with bpftrace on Linux  https://fosdem.org/2021/schedule/event/mariadb_bpftrace/attachments/slides/4440/export/events/attachments/mariadb_bpftrace/slides/4440/Monitoring_MariaDB_Server_with_bpftrace_on_Linux_FOSDEM_2021.pdf
  32.  

你可能感兴趣的:(运维,centos,优化,linux,服务器,运维,centos)