[openresty] docker中部署openresty+火焰图,执行./ngx-sample-lua-bt -p 23571 --luajit20 -t 5报错: Cannot open /proc/23572/maps for reading: Permission denied

179 views
Skip to first unread message

_Xiangqian C

unread,
Sep 30, 2018, 2:15:12 AM9/30/18
to open...@googlegroups.com
在docker中部署好了openresty,然后想在docker中部署火焰图,全部安装完成后,执行命令,结果报错:Permission denied

[root@aliyun-core opt]# ps -ef | grep master

root     23571     1  0 02:41 ?        00:00:00 nginx: master process /usr/local/openresty/nginx/sbin/nginx -p /etc/openresty/video_recom -c conf/nginx.conf

root     23590     1  0 02:41 ?        00:00:00 grep master

[root@aliyun-core opt]# ./ngx-sample-lua-bt -p 23571 --luajit20 -t 5

Cannot open /proc/23572/maps for reading: Permission denied


查看对应文件属主和权限如下:

[root@aliyun-core opt]# ls -l /proc/23572 | grep maps

ls: cannot read symbolic link /proc/23572/cwd: Permission denied

ls: cannot read symbolic link /proc/23572/root: Permission denied

ls: cannot read symbolic link /proc/23572/exe: Permission denied

-r--r--r-- 1 nobody nobody 0 Sep 30 02:42 maps

-r--r--r-- 1 nobody nobody 0 Sep 30 02:42 numa_maps

-r--r--r-- 1 nobody nobody 0 Sep 30 02:42 smaps


文件属主nobody,可读,但是读操作时却提示没有权限:

[root@aliyun-core opt]# cat /proc/23572/maps

cat: /proc/23572/maps: Permission denied



docker中当前用户为root,并且docker中的root/nobody用户和centos中的root/nobody id是相同的

[root@aliyun-core opt]# cat /etc/passwd | grep -E "^root"

root:x:0:0:root:/root:/bin/bash

[root@aliyun-core opt]# cat /etc/passwd | grep -E "^nobody"

nobody:x:99:99:Nobody:/:/sbin/nologin

###centos 用户id

chengxq@aliyun trunk$ cat /etc/passwd | grep -E "^root"

root:x:0:0:root:/root:/bin/bash

chengxq@aliyun trunk$ cat /etc/passwd | grep -E "^nobody"

nobody:x:99:99:Nobody:/:/sbin/nologin

chengxq@aliyun trunk$ 




直接部署在centos中的openresty+火焰图是可以正常运行的,但是部署到docker中之后就会出现此 Permission denied 问题,有认知道具体是什么原因吗?


 


tokers

unread,
Sep 30, 2018, 3:21:27 AM9/30/18
to openresty
Hello!
注意 docker run 加上 --priviledged  --pid=host 选项以及把必要的目录映射进去,比如 /lib/modules/`uname -r`。

_Xiangqian C

unread,
Nov 10, 2018, 12:17:18 AM11/10/18
to open...@googlegroups.com

[root@85-132-83-aliyun-core /]# stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}'

Pass 1: parsed user script and 470 library scripts using 126068virt/41064res/3312shr/37828data kb, in 370usr/30sys/392real ms.

WARNING: cannot find module nfs debuginfo: No DWARF information found [man warning::debuginfo]

WARNING: cannot find module sunrpc debuginfo: No DWARF information found [man warning::debuginfo]

WARNING: cannot find module nfs debuginfo: No DWARF information found [man warning::debuginfo]

Pass 2: analyzed script: 1 probe, 1 function, 7 embeds, 0 globals using 257340virt/173152res/6216shr/167000data kb, in 2160usr/350sys/2520real ms.

Pass 3: using cached /root/.systemtap/cache/7c/stap_7c0bb936c8056e80320a86692159019e_2696.c

Pass 4: using cached /root/.systemtap/cache/7c/stap_7c0bb936c8056e80320a86692159019e_2696.ko

Pass 5: starting run.

ERROR: module version mismatch (#1 SMP Tue Jul 4 13:29:22 UTC 2017 vs #1 SMP Tue Jul 4 15:04:05 UTC 2017), release 3.10.0-514.26.2.el7.x86_64

WARNING: /usr/bin/staprun exited with status: 1

Pass 5: run completed in 0usr/20sys/47real ms.

Pass 5: run failed.  [man error::pass5]

[root@85-132-83-aliyun-core /]# 


目前执行stap 命令报错:module version mismatch



docker 里的版本信息:

[root@85-132-83-aliyun-core /]# cat /etc/redhat-release 

CentOS Linux release 7.5.1804 (Core) 

[root@85-132-83-aliyun-core /]# uname -r

3.10.0-514.26.2.el7.x86_64

[root@85-132-83-aliyun-core /]# 



宿主机的版本信息:

[root@85-132-83-aliyun-core XX]# cat /etc/redhat-release 

CentOS Linux release 7.5.1804 (Core) 

[root@85-132-83-aliyun-core XX]# uname -r

3.10.0-514.26.2.el7.x86_64

[root@85-132-83-aliyun-core XX]# 



内核开发调试包也都是3.10.0-514.26.2.el7.x86_64对应的rpm,这个是哪里的问题




tokers <zcha...@gmail.com> 于2018年9月30日周日 下午3:21写道:
Hello!
注意 docker run 加上 --priviledged  --pid=host 选项以及把必要的目录映射进去,比如 /lib/modules/`uname -r`。

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

_Xiangqian C

unread,
Nov 12, 2018, 12:54:41 AM11/12/18
to open...@googlegroups.com
docker中报module version mismatch问题已经解决,原因是安装的kernel-devel*rpm 的UTS_VERSION与系统不一致,重新下载一个UTS_VERSION相同的rpm即可,查看方式/usr/src/kernels/3.10.0-514.26.2.el7.x86_64/include/generated/compile.h

但是遇到了一个新问题,docker 中再次执行  stap -v -e 'probe vfs.read {printf("read performed\n"); exit()}' 报错:

ERROR: Couldn't mount /sys/kernel/debug: Operation not permitted


不知道这个错误怎么解决,是要在运行docker时增加什么参数或者映射目录吗?

_Xiangqian C <keky...@gmail.com> 于2018年11月10日周六 下午1:17写道:
Reply all
Reply to author
Forward
0 new messages