(一)openEuler bcc/python环境搭建

2024-05-16  本文已影响0人  海棠依旧_6c54

bcc编译

yum install git cmake -y
yum install  llvm-devel clang-devel netperf iperf -y
git clone --recurse-submodules  https://gitcode.com/iovisor/bcc.git
cd bcc && mkdir build && cd build
cmake ../ -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_LLVM_SHARED=1

主要是里边的daemon ,建议大家编一下

直接安装

环境

[root@oe2203sp1-lts ~]# cat /etc/openEuler-latest
openeulerversion=openEuler-22.03-LTS-SP1
compiletime=2022-12-27-22-15-04
gccversion=10.3.1-20
kernelversion=5.10.0-136.12.0.86.oe2203sp1
openjdkversion=1.8.0.352.b08-3.oe2203sp1

安装bcc

yum install bcc -y

先配置下pip源

cat /etc/pip.conf
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
timeout = 120

安装ipython

pip install ipython

验证下

[root@oe2203sp1-lts ~]# ipython
Python 3.9.9 (main, Dec 27 2022, 17:54:38)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.18.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from bpfcc import BPF
   ...:

In [2]:
没报错即为ok 注意这里是bpfbcc 不是官网的bcc

安装 [Jupyter]与 JupyterLab

pip3 install jupyter jupyterlab

配置配置 Jupyter

jupyter notebook --generate-config

配置文件
 /root/.jupyter/jupyter_notebook_config.py

设置绑定的ip
#  Default: 'localhost'
c.ServerApp.ip = '172.18.78.107.'
root用户可以访问,没有设置该项之后启动时需要jupyter lab后加 --allow-root
c.ServerApp.allow_root = True
可以选择更改jupterlab默认启动路径(此步可忽略)
c.ServerApp.notebook_dir = '/root/bcc_bpf'

配置代码补全功能

pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user --skip-running-check

会报错
 File "/usr/local/lib/python3.9/site-packages/jupyter_contrib_nbextensions/__init__.py", line 5, in <module>
    import jupyter_nbextensions_configurator
  File "/usr/local/lib/python3.9/site-packages/jupyter_nbextensions_configurator/__init__.py", line 18, in <module>
    from notebook.base.handlers import APIHandler, IPythonHandler
ModuleNotFoundError: No module named 'notebook.base'

解决方案指定notebook版本
pip install notebook==6.5.1

汉化插件支持

pip install jupyterlab-language-pack-zh-CN

启动

systemctl stop firewalld.service
setenforce 0
jupyter lab

会先回有一条url
http://172.18.78.107.:8888/lab?token=b3e301c625bcc0ea0dccffb5433d034a2825921b17dc2e1a

web登录


上一篇下一篇

猜你喜欢

热点阅读