[20241014]strace使用小技巧参数y.txt --//昨天测试sqlplus spool的相关问题,想起应该使用strace跟踪看看,了解一些操作细节。 --//我以前看Franck Pachot的blog,好像strace有1个参数启动可以看到打开的文件句柄带上真实的文件名,这样比较直观。 --//我当时测试服务器是oracle kennel 5.9版本,strace版本很低,没有这个功能,记忆有点混乱,我现在使用centos 7.3, --//看看该机器带的strace是否支持这个功能,我连参数名都有点忘记了,看看相关文档顺便写一篇文章。 $ man strace ... -y Print paths associated with file descriptor arguments. --//参数y支持这个特性,测试看看。 1.环境: SCOTT@book01p> @ ver2 ============================== PORT_STRING : x86_64/Linux 2.4.xx VERSION : 21.0.0.0.0 BANNER : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production BANNER_FULL : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production Version 21.3.0.0.0 BANNER_LEGACY : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production CON_ID : 0 PL/SQL procedure successfully completed. $ cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) $ echo -e "$SQLPATH\n$ORACLE_PATH" /home/oracle/sqllaji:/home/oracle/sqllaji/tpt /home/oracle/sqllaji:/home/oracle/sqllaji/tpt 2.测试: --//session 1: SCOTT@book01p> @ spid SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50 ---------- ---------- ------------------------ --------- ------------------------------ ------- ---------- -------------------------------------------------- 142 58300 4673 DEDICATED 4675 65 4 alter system kill session '142,58300' immediate; SCOTT@book01p> host pwd /home/oracle/study/202410 SCOTT@book01p> host touch /home/oracle/study/202410/tmp123.txt SCOTT@book01p> host touch /home/oracle/sqllaji/tmp123.txt SCOTT@book01p> host touch /home/oracle/sqllaji/tpt/tmp123.txt --//window 1: $ strace -f -p 4673 -y Process 4673 attached --//注意跟踪进程号4673。 --//session 1: SCOTT@book01p> spool ./tmp123.txt --//window 1: $ strace -f -p 4673 -y Process 4673 attached read(0</dev/pts/8>, "spool ./tmp123.txt\n", 1024) = 19 access("/home/oracle/sqllaji/./tmp123.txt", F_OK) = 0 access("/home/oracle/sqllaji/./tmp123.txt", F_OK) = 0 stat("/home/oracle/sqllaji/./tmp123.txt", {st_mode=S_IFREG|0644, st_size=25, ...}) = 0 stat("/home/oracle/sqllaji/./", {st_mode=S_IFDIR|0755, st_size=16384, ...}) = 0 open("/home/oracle/sqllaji/./tmp123.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 10 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fcntl(10</home/oracle/sqllaji/tmp123.txt>, F_SETFD, FD_CLOEXEC) = 0 fstat(10</home/oracle/sqllaji/tmp123.txt>, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f14a33f8000 write(1</dev/pts/8>, "SCOTT@book01p> ", 15) = 15 read(0</dev/pts/8>, --//这样优先打开open("/home/oracle/sqllaji/./tmp123.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 10 --//open对应句柄10,这样显示的内容句柄号跟着文件名就比较直观. --//session 1: SCOTT@book01p> spool off SCOTT@book01p> host rm /home/oracle/study/202410/tmp123.txt SCOTT@book01p> host rm home/oracle/sqllaji/tmp123.txt SCOTT@book01p> host rm /home/oracle/sqllaji/tpt/tmp123.txt SCOTT@book01p> spool ./tmp123.txt --//window 1: $ strace -f -p 4673 -y Process 4673 attached read(0</dev/pts/8>, "spool ./tmp123.txt\n", 1024) = 19 access("/home/oracle/sqllaji/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) access("/home/oracle/sqllaji/tpt/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) access("/home/oracle/sqllaji/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) access("/home/oracle/sqllaji/tpt/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) access("/home/oracle/sqllaji/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) access("/home/oracle/sqllaji/tpt/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) access("/home/oracle/sqllaji/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) access("/home/oracle/sqllaji/tpt/./tmp123.txt", F_OK) = -1 ENOENT (No such file or directory) --//使用access分别尝试4次,不存在。 stat("./tmp123.txt", 0x7ffc62357980) = -1 ENOENT (No such file or directory) stat("./", {st_mode=S_IFDIR|0755, st_size=39, ...}) = 0 open("./tmp123.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 10 --//返回看看本地是否存在,使用stat。 fcntl(10</home/oracle/study/202410/tmp123.txt>, F_SETFD, FD_CLOEXEC) = 0 fstat(10</home/oracle/study/202410/tmp123.txt>, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f14a33f8000 write(1</dev/pts/8>, "SCOTT@book01p> ", 15) = 15 read(0</dev/pts/8>,
[20241014]strace使用小技巧参数y.txt
来源:这里教程网
时间:2026-03-03 20:42:04
作者:
编辑推荐:
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 达梦数据库安装与配置
达梦数据库安装与配置
26-03-03 - 数据库管理-第248期 23ai:全球分布式数据库-分片数据分布方法(20241006)
- Oracle这款免费的代码平台,铁了心砸掉程序员饭碗!
Oracle这款免费的代码平台,铁了心砸掉程序员饭碗!
26-03-03 - 使用Oracle 19c,必须要注意这个Bug
使用Oracle 19c,必须要注意这个Bug
26-03-03 - 数据库管理-第249期 23ai:全球分布式数据库-请求路由与查询过程(20241008)
- 推荐几本学习Oracle初期阅读的书
推荐几本学习Oracle初期阅读的书
26-03-03 - oracle数据坏块处理(一)-通过rman备份修复
oracle数据坏块处理(一)-通过rman备份修复
26-03-03 - golden gate目录从standby端迁移到primary端
golden gate目录从standby端迁移到primary端
26-03-03 - Oracle数据恢复—异常断电导致Oracle数据库数据库打不开的数据恢复案例
- 数据库管理-第244期 一次无法switchover的故障处理(20240928)
