关闭

添加cyclictest 库文件到docker

115人阅读 评论(0) 收藏 举报
分类:

将host目录挂载到docker container里后,运行cyclictest发现没有库文件

[root@31ac104a9281redapple]# cyclictest -c CLOCK

bash:cyclictest: command not found     //说明挂载过来的cyclictest并不在当前目录下

[root@31ac104a9281 redapple]# which cyclictest

bash: which: command not found

[root@31ac104a9281 redapple]# pwd

/opt/redapple

[root@31ac104a9281 redapple]# echo $PATH     //查看cyclictest存在哪个目录

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

[root@31ac104a9281redapple]# ./cyclictest -c CLOCK       //可以使用  ./cyclictest方式或者将cycilctest添加到 $PATH  目录下

./cyclictest:error while loading shared libraries: libnuma.so.1: cannot open shared objectfile: No such file or directory

 [root@31ac104a9281redapple]# ld

ld        ld.bfd    ld.gold  ldattach  ldconfig  ldd

[root@31ac104a9281 redapple]# ldd ./cyclictest  //ldd的作用是打印可执行档依赖的共享库文件

       linux-vdso.so.1 => (0x00007ffc7137c000)

        librt.so.1=> /lib64/librt.so.1 (0x00007f071f0e1000)

       libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f071eec5000)

        libnuma.so.1 => not found

        libc.so.6=> /lib64/libc.so.6 (0x00007f071eb03000)

       /lib64/ld-linux-x86-64.so.2 (0x00007f071f2e9000)

查询到host上的cyclictest库文件并没有挂载到dockercontainer中,需要在host上与docker共享的目录下新建文件夹LIB,将库文件拷贝到LIB下,然后在dockercontainer中添加相应环境变量LIB_LIBRARY_PATH,然后container就能引用其库文件。

[root@localhost rt-tests-1.0]# mkdir LIB

[root@localhost rt-tests-1.0]# cd LIB/

[root@localhost LIB]# cd ..

[root@localhost rt-tests-1.0]# ldd /usr/bin/cyclictest

       linux-vdso.so.1 => (0x00007ffe10d48000)

        librt.so.1=> /lib64/librt.so.1 (0x00007f15fba0a000)

       libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f15fb7ee000)

        libnuma.so.1=> /lib64/libnuma.so.1(0x00007f15fb5e2000)

        libc.so.6=> /lib64/libc.so.6 (0x00007f15fb220000)

       /lib64/ld-linux-x86-64.so.2 (0x00007f15fbc12000)

        libgcc_s.so.1=> /lib64/libgcc_s.so.1 (0x00007f15fb00a000)

 [root@localhostrt-tests-1.0]# cd LIB/

 [root@localhost LIB]#pwd

/root/daisy/RT_test/rt-tests-1.0/LIB

 [root@localhost LIB]#cp /lib64/libnuma.so.1 .  //将库文件拷贝到当前目录下

开始添加环境变量

[root@31ac104a9281 redapple]# ls

COPYING         bld           linux-3.12.66.tar.gz        rt-migrate-test

LIB              cyclictest     patch-3.12.66-rt88.patch.gz  sendme

MAINTAINERS     hackbench      pi_stress                    signaltest

Makefile        hwlatdetect    pip_stress                   sigwaittest

README.markdown libnuma.so.1   pmqtest                      src

RT_test         linux-3.12.66  ptsematest                   svsematest

[root@31ac104a9281 redapple]# echo $LD_LIBRARY_PATH

 

 [root@31ac104a9281redapple]# pwd

/opt/redapple

[root@31ac104a9281 redapple]# export  LD_LIBRARY_PATH=/opt/redapple/LIB//每次退出container再进去都需要export环境变量

[root@31ac104a9281 redapple]# cd LIB

[root@31ac104a9281 LIB]# ls

libnuma.so.1

[root@31ac104a9281 redapple]# ldd ./cyclictest

       linux-vdso.so.1 => (0x00007ffefa557000)

        librt.so.1=> /lib64/librt.so.1 (0x00007fae59382000)

       libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fae59166000)

        libnuma.so.1 =>/opt/redapple/LIB/libnuma.so.1 (0x00007fae58f5a000)

        libc.so.6=> /lib64/libc.so.6 (0x00007fae58b98000)

       /lib64/ld-linux-x86-64.so.2 (0x00007fae5958a000)

        libgcc_s.so.1=> /lib64/libgcc_s.so.1 (0x00007fae58982000)

[root@31ac104a9281 redapple]# ./cyclictest -c CLOCK 

Unable to change scheduling policy!

either run as root or join realtime group

安装完cyclictest在host上也会出现这个问题,打完patch就ok了,现在在docker上也出现这个问题需要解决。

解决方法为在创建container时就添加参数--cap-add=sys_nice

[root@localhost daisy_docker]#  dockerrun -it -d -P --cap-add=sys_nice  --nameweb3 -v /root/daisy/RT_test/rt-tests-1.0:/opt/goodred centos

创建容器名为web3,host目录/root/daisy/RT_test/rt-tests-1.0挂载到docker container目录/opt/goodred下,image为centos

[root@43640390f92bgoodred]# export LD_LIBRARY_PATH=/opt/goodred/LIB

[root@43640390f92b goodred]# ./cyclictest -t1 -p 99 -n -i 1000 -l 1800000

WARN: stat/dev/cpu_dma_latency failed: No such file or directory

policy: fifo:loadavg: 0.13 0.07 0.05 1/1775 20

 

T: 0 (   20) P:99 I:1000 C: 404874 Min:      3 Act:  60 Avg:   54 Max:     115







0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:6145次
    • 积分:369
    • 等级:
    • 排名:千里之外
    • 原创:32篇
    • 转载:2篇
    • 译文:0篇
    • 评论:0条
    文章分类