bcc安装过程以及遇到的问题

您所在的位置:网站首页 bcc安装路径 bcc安装过程以及遇到的问题

bcc安装过程以及遇到的问题

2024-07-09 03:39| 来源: 网络整理| 查看: 265

对于5.15版本的安装

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4052245BD4284CDD Executing: /tmp/apt-key-gpghome.yKCApS0t8A/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 4052245BD4284CDD gpg: 密钥 4052245BD4284CDD:公钥 “Brenden Blanco ” 已导入 gpg: 处理的总数:1 gpg: 已导入:1 $ echo "deb https://repo.iovisor.org/apt/xenial xenial main" | sudo tee /etc/apt/sources.list.d/iovisor.list deb https://repo.iovisor.org/apt/xenial xenial main $ sudo apt-get update 命中:1 http://packages.microsoft.com/repos/code stable InRelease 命中:2 http://dl.google.com/linux/chrome/deb stable InRelease 命中:3 http://security.ubuntu.com/ubuntu focal-security InRelease 命中:4 http://cn.archive.ubuntu.com/ubuntu focal InRelease 命中:5 http://cn.archive.ubuntu.com/ubuntu focal-updates InRelease 命中:6 http://cn.archive.ubuntu.com/ubuntu focal-backports InRelease 获取:7 https://repo.iovisor.org/apt/xenial xenial InRelease [2,419 B] 命中:8 http://lenovo.archive.canonical.com focal InRelease 获取:9 https://repo.iovisor.org/apt/xenial xenial/main i386 Packages [1,062 B] 获取:10 https://repo.iovisor.org/apt/xenial xenial/main amd64 Packages [1,197 B] 已下载 2,259 B,耗时 2秒 (1,050 B/s) 正在读取软件包列表... 完成 $ sudo apt-get install -y bcc-tools libbcc-examples linux-headers-$(uname -r) 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 linux-headers-5.15.0-46-generic 已经是最新版 (5.15.0-46.49~20.04.1)。 linux-headers-5.15.0-46-generic 已设置为手动安装。 将会同时安装下列软件: libbcc python-bcc 下列【新】软件包将被安装: bcc-tools libbcc libbcc-examples python-bcc 升级了 0 个软件包,新安装了 4 个软件包,要卸载 0 个软件包,有 29 个软件包未被升级。 需要下载 12.6 MB 的归档。 解压缩后会消耗 45.2 MB 的额外空间。 获取:1 https://repo.iovisor.org/apt/xenial xenial/main amd64 libbcc all 0.10.0-1 [11.9 MB] 获取:2 https://repo.iovisor.org/apt/xenial xenial/main amd64 python-bcc all 0.10.0-1 [30.8 kB] 获取:3 https://repo.iovisor.org/apt/xenial xenial/main amd64 bcc-tools all 0.10.0-1 [356 kB] 获取:4 https://repo.iovisor.org/apt/xenial xenial/main amd64 libbcc-examples amd64 0.10.0-1 [278 kB] 已下载 12.6 MB,耗时 4分 15秒 (49.3 kB/s) 正在选中未选择的软件包 libbcc。 (正在读取数据库 ... 系统当前共安装有 279008 个文件和目录。) 准备解压 .../libbcc_0.10.0-1_all.deb ... 正在解压 libbcc (0.10.0-1) ... 正在选中未选择的软件包 python-bcc。 准备解压 .../python-bcc_0.10.0-1_all.deb ... 正在解压 python-bcc (0.10.0-1) ... 正在选中未选择的软件包 bcc-tools。 准备解压 .../bcc-tools_0.10.0-1_all.deb ... 正在解压 bcc-tools (0.10.0-1) ... 正在选中未选择的软件包 libbcc-examples。 准备解压 .../libbcc-examples_0.10.0-1_amd64.deb ... 正在解压 libbcc-examples (0.10.0-1) ... 正在设置 libbcc (0.10.0-1) ... 正在设置 python-bcc (0.10.0-1) ... 正在设置 libbcc-examples (0.10.0-1) ... 正在设置 bcc-tools (0.10.0-1) ... 正在处理用于 libc-bin (2.31-0ubuntu9.9) 的触发器 ... $ bcc Command 'bcc' not found, but can be installed with: sudo apt install bcc $ cachestat Command 'cachestat' not found, did you mean: command 'cachestats' from deb nocache (1.1-1) Try: sudo apt install $ export PATH=$PATH:/usr/share/bcc/tools $ cachestat Traceback (most recent call last): File "/usr/share/bcc/tools/cachestat", line 21, in from bcc import BPF File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 27, in from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE File "/usr/lib/python2.7/dist-packages/bcc/libbcc.py", line 17, in lib = ct.CDLL("libbcc.so.0", use_errno=True) File "/usr/lib/python2.7/ctypes/__init__.py", line 366, in __init__ self._handle = _dlopen(self._name, mode) OSError: libtinfo.so.5: cannot open shared object file: No such file or directory $ sudo -i ~# export PATH=$PATH:/usr/share/bcc/tools ~# cachestat Traceback (most recent call last): File "/usr/share/bcc/tools/cachestat", line 21, in from bcc import BPF File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 27, in from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE File "/usr/lib/python2.7/dist-packages/bcc/libbcc.py", line 17, in lib = ct.CDLL("libbcc.so.0", use_errno=True) File "/usr/lib/python2.7/ctypes/__init__.py", line 366, in __init__ self._handle = _dlopen(self._name, mode) OSError: libtinfo.so.5: cannot open shared object file: No such file or directory ~# cat /boot/ config-5.15.0-41-generic grub/ initrd.img-5.15.0-46-generic memtest86+.elf System.map-5.15.0-46-generic vmlinuz-5.15.0-46-generic config-5.15.0-46-generic initrd.img initrd.img.old memtest86+_multiboot.bin vmlinuz vmlinuz.old efi/ initrd.img-5.15.0-41-generic memtest86+.bin System.map-5.15.0-41-generic vmlinuz-5.15.0-41-generic ~# cat /boot/config-5.15.0-46-generic | grep BPF CONFIG_BPF=y CONFIG_HAVE_EBPF_JIT=y CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y # BPF subsystem CONFIG_BPF_SYSCALL=y CONFIG_BPF_JIT=y CONFIG_BPF_JIT_ALWAYS_ON=y CONFIG_BPF_JIT_DEFAULT_ON=y CONFIG_BPF_UNPRIV_DEFAULT_OFF=y # CONFIG_BPF_PRELOAD is not set CONFIG_BPF_LSM=y # end of BPF subsystem CONFIG_CGROUP_BPF=y CONFIG_IPV6_SEG6_BPF=y CONFIG_NETFILTER_XT_MATCH_BPF=m CONFIG_BPFILTER=y CONFIG_BPFILTER_UMH=m CONFIG_NET_CLS_BPF=m CONFIG_NET_ACT_BPF=m CONFIG_BPF_STREAM_PARSER=y CONFIG_LWTUNNEL_BPF=y CONFIG_BPF_EVENTS=y CONFIG_BPF_KPROBE_OVERRIDE=y CONFIG_TEST_BPF=m ~# cachestat 1 3 Traceback (most recent call last): File "/usr/share/bcc/tools/cachestat", line 21, in from bcc import BPF File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 27, in from .libbcc import lib, bcc_symbol, bcc_symbol_option, bcc_stacktrace_build_id, _SYM_CB_TYPE File "/usr/lib/python2.7/dist-packages/bcc/libbcc.py", line 17, in lib = ct.CDLL("libbcc.so.0", use_errno=True) File "/usr/lib/python2.7/ctypes/__init__.py", line 366, in __init__ self._handle = _dlopen(self._name, mode) OSError: libtinfo.so.5: cannot open shared object file: No such file or directory ~#

解决方法

~# ls /usr/libtinfo* ls: 无法访问 '/usr/libtinfo*': 没有那个文件或目录 ~# exit 注销 $ sudo apt-get install libncurses5 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 将会同时安装下列软件: libtinfo5 下列【新】软件包将被安装: libncurses5 libtinfo5 升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 29 个软件包未被升级。 需要下载 180 kB 的归档。 解压缩后会消耗 864 kB 的额外空间。 您希望继续执行吗? [Y/n] y 获取:1 http://cn.archive.ubuntu.com/ubuntu focal/universe amd64 libtinfo5 amd64 6.2-0ubuntu2 [83.0 kB] 获取:2 http://cn.archive.ubuntu.com/ubuntu focal/universe amd64 libncurses5 amd64 6.2-0ubuntu2 [96.9 kB] 已下载 180 kB,耗时 1秒 (123 kB/s) 正在选中未选择的软件包 libtinfo5:amd64。 (正在读取数据库 ... 系统当前共安装有 279539 个文件和目录。) 准备解压 .../libtinfo5_6.2-0ubuntu2_amd64.deb ... 正在解压 libtinfo5:amd64 (6.2-0ubuntu2) ... 正在选中未选择的软件包 libncurses5:amd64。 准备解压 .../libncurses5_6.2-0ubuntu2_amd64.deb ... 正在解压 libncurses5:amd64 (6.2-0ubuntu2) ... 正在设置 libtinfo5:amd64 (6.2-0ubuntu2) ... 正在设置 libncurses5:amd64 (6.2-0ubuntu2) ... 正在处理用于 libc-bin (2.31-0ubuntu9.9) 的触发器 ... $ cachestat In file included from :317: In file included from :7: In file included from /virtual/include/bcc/bpf.h:12: In file included from include/linux/types.h:6: In file included from include/uapi/linux/types.h:14: In file included from ./include/uapi/linux/posix_types.h:5: In file included from include/linux/stddef.h:5: In file included from include/uapi/linux/stddef.h:2: In file included from include/linux/compiler_types.h:80: include/linux/compiler-clang.h:41:9: warning: '__HAVE_BUILTIN_BSWAP32__' macro redefined [-Wmacro-redefined] #define __HAVE_BUILTIN_BSWAP32__ ^ :4:9: note: previous definition is here #define __HAVE_BUILTIN_BSWAP32__ 1 ^ In file included from :317: In file included from :7: In file included from /virtual/include/bcc/bpf.h:12: In file included from include/linux/types.h:6: In file included from include/uapi/linux/types.h:14: In file included from ./include/uapi/linux/posix_types.h:5: In file included from include/linux/stddef.h:5: In file included from include/uapi/linux/stddef.h:2: In file included from include/linux/compiler_types.h:80: include/linux/compiler-clang.h:42:9: warning: '__HAVE_BUILTIN_BSWAP64__' macro redefined [-Wmacro-redefined] #define __HAVE_BUILTIN_BSWAP64__ ^ :5:9: note: previous definition is here #define __HAVE_BUILTIN_BSWAP64__ 1 ^ In file included from :317: In file included from :7: In file included from /virtual/include/bcc/bpf.h:12: In file included from include/linux/types.h:6: In file included from include/uapi/linux/types.h:14: In file included from ./include/uapi/linux/posix_types.h:5: In file included from include/linux/stddef.h:5: In file included from include/uapi/linux/stddef.h:2: In file included from include/linux/compiler_types.h:80: include/linux/compiler-clang.h:43:9: warning: '__HAVE_BUILTIN_BSWAP16__' macro redefined [-Wmacro-redefined] #define __HAVE_BUILTIN_BSWAP16__ ^ :3:9: note: previous definition is here #define __HAVE_BUILTIN_BSWAP16__ 1 ^ In file included from /virtual/main.c:2: In file included from include/uapi/linux/ptrace.h:153: In file included from ./arch/x86/include/asm/ptrace.h:5: ./arch/x86/include/asm/segment.h:255:2: error: expected '(' after 'asm' alternative_io ("lsl %[seg],%[p]", ^ ./arch/x86/include/asm/alternative.h:248:2: note: expanded from macro 'alternative_io' asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ ^ include/linux/compiler_types.h:258:24: note: expanded from macro 'asm_inline' #define asm_inline asm __inline ^ 3 warnings and 1 error generated. Traceback (most recent call last): File "/usr/share/bcc/tools/cachestat", line 96, in b = BPF(text=bpf_text) File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 325, in __init__ raise Exception("Failed to compile BPF text") Exception: Failed to compile BPF text

对于4.19版本的安装

rlk@ubuntu:~$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4052245BD4284CDD [sudo] password for rlk: Executing: /tmp/apt-key-gpghome.mIpNWGNyeE/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 4052245BD4284CDD gpg: key 4052245BD4284CDD: "Brenden Blanco " not changed gpg: Total number processed: 1 gpg: unchanged: 1 rlk@ubuntu:~$ cat /etc/apt/sources.list.d/iovisor.list deb https://repo.iovisor.org/apt/xenial xenial main rlk@ubuntu:~$ rlk@ubuntu:~$ sudo apt-get update Hit:1 http://mirrors.cn99.com/ubuntu bionic InRelease Hit:2 http://mirrors.cn99.com/ubuntu bionic-updates InRelease Hit:3 http://mirrors.cn99.com/ubuntu bionic-backports InRelease Hit:4 http://mirrors.cn99.com/ubuntu bionic-security InRelease Ign:5 https://repo.iovisor.org/apt/xenial xenial InRelease Err:6 https://repo.iovisor.org/apt/xenial xenial Release Certificate verification failed: The certificate is NOT trusted. The certificate chain uses expired certificate. Could not handshake: Error in the certificate verification. [IP: 104.199.116.191 443] Err:7 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease Could not connect to archive.ubuntukylin.com:10006 (124.126.103.228). - connect (111: Connection refused) Err:8 http://archive.ubuntukylin.com:10006/ubuntukylin bionic InRelease Unable to connect to archive.ubuntukylin.com:10006: Reading package lists... Done E: The repository 'https://repo.iovisor.org/apt/xenial xenial Release' does not have a Release file. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.

解决方法

将 https://repo.iovisor.org/apt/xenial xenial InRelease的https 修改为 http

去掉 http://archive.ubuntukylin.com:10006/ubuntukylin

再来一遍

root@ubuntu:apt# apt update Hit:1 http://mirrors.cn99.com/ubuntu bionic InRelease Hit:2 http://mirrors.cn99.com/ubuntu bionic-updates InRelease Hit:3 http://mirrors.cn99.com/ubuntu bionic-backports InRelease Hit:4 http://mirrors.cn99.com/ubuntu bionic-security InRelease Hit:5 http://repo.iovisor.org/apt/xenial xenial InRelease Reading package lists... Done Building dependency tree Reading state information... Done 723 packages can be upgraded. Run 'apt list --upgradable' to see them. root@ubuntu:apt# apt-get install -y bcc-tools libbcc-examples Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libbcc python-bcc The following NEW packages will be installed: bcc-tools libbcc libbcc-examples python-bcc 0 upgraded, 4 newly installed, 0 to remove and 723 not upgraded. Need to get 12.6 MB of archives. After this operation, 45.2 MB of additional disk space will be used. Get:1 http://repo.iovisor.org/apt/xenial xenial/main amd64 libbcc all 0.10.0-1 [11.9 MB] Get:2 http://repo.iovisor.org/apt/xenial xenial/main amd64 python-bcc all 0.10.0-1 [30.8 kB] Get:3 http://repo.iovisor.org/apt/xenial xenial/main amd64 bcc-tools all 0.10.0-1 [356 kB] Get:4 http://repo.iovisor.org/apt/xenial xenial/main amd64 libbcc-examples amd64 0.10.0-1 [278 kB] Fetched 12.6 MB in 32s (398 kB/s) Selecting previously unselected package libbcc. (Reading database ... 275684 files and directories currently installed.) Preparing to unpack .../libbcc_0.10.0-1_all.deb ... Unpacking libbcc (0.10.0-1) ... Selecting previously unselected package python-bcc. Preparing to unpack .../python-bcc_0.10.0-1_all.deb ... Unpacking python-bcc (0.10.0-1) ... Selecting previously unselected package bcc-tools. Preparing to unpack .../bcc-tools_0.10.0-1_all.deb ... Unpacking bcc-tools (0.10.0-1) ... Selecting previously unselected package libbcc-examples. Preparing to unpack .../libbcc-examples_0.10.0-1_amd64.deb ... Unpacking libbcc-examples (0.10.0-1) ... Setting up libbcc (0.10.0-1) ... Setting up python-bcc (0.10.0-1) ... Setting up bcc-tools (0.10.0-1) ... Setting up libbcc-examples (0.10.0-1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ...

4.19版本也遇到如下问题的话

rlk@ubuntu:~$ /usr/share/bcc/tools/cachestat Traceback (most recent call last): File "/usr/share/bcc/tools/cachestat", line 21, in from bcc import BPF ImportError: No module named bcc

解决方法

root@ubuntu:apt# uname -a Linux ubuntu 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux root@ubuntu:apt# rlk@ubuntu:~$ ls /usr/src/ linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic rlk@ubuntu:~$ ls /usr/src/ -l total 8 drwxr-xr-x 27 root root 4096 Jul 24 2018 linux-headers-4.15.0-29 drwxr-xr-x 8 root root 4096 Jul 24 2018 linux-headers-4.15.0-29-generic rlk@ubuntu:~$ uname -a Linux ubuntu 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux rlk@ubuntu:~$ sudo -i root@ubuntu:~# mkdir /usr/src/kernel root@ubuntu:~# mkdir /usr/src/kernels root@ubuntu:~# rm -rf /usr/src/kernel root@ubuntu:~# ln -s /usr/src/linux-headers-4.15.0-29-generic /usr/src/kernels/linux-headers-4.15.0-29-generic root@ubuntu:~# ls /usr/src/kernels/ linux-headers-4.15.0-29-generic root@ubuntu:~# /usr/share/bcc/tools/cachestat

开始运行

root@ubuntu:apt# usr/share/bcc/tools/cachestat -bash: usr/share/bcc/tools/cachestat: No such file or directory root@ubuntu:apt# /usr/share/bcc/tools/cachestat HITS MISSES DIRTIES HITRATIO BUFFERS_MB CACHED_MB 11632 0 837 100.00% 56 1148 4549 0 809 100.00% 56 1148 46702 0 5 100.00% 56 1148 3 0 0 100.00% 56 1148 0 0 8 0.00% 56 1148 3 0 0 100.00% 56 1148 3 0 0 100.00% 56 1148 3 0 0 100.00% 56 1148 3 0 0 100.00% 56 1148

ubuntu 缺少 libtinfo.so.5 问题 https://blog.csdn.net/lsqtzj/article/details/108553576

执行/usr/share/bcc/tools/filetop -C报错Exception: Failed to compile BPF module  https://blog.csdn.net/liuqiuxiu/article/details/108421958

Could not connect to archive.ubuntukylin.com:10006 (120.240.95.35), connection timed out https://blog.csdn.net/shanpenghui/article/details/108552367

ImportError: No module named 通用解决方法 https://blog.csdn.net/jdbc/article/details/80351833



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3