一、连接的整个流程
1、A.客户端:(1)A-->B 发起连接 (9)与Server Process交互,完成连接
2、B.监听进程:(2)B-->C fork子进程并等待 (7)B-->D 传送客户端信息
3、C.监听子进程1:(3) C-->D fork子进程 (4)C-->B 子进程结束
4、D.子进程2(Server Process) (5)D-->D exec Oracle (6)D-->B 监听传送数据 (8)D-->A 与客户端交互
二、整个监听过程的处理流程如下几步:
利用操作系统工具跟踪:
strace -rf-o /gyj/lsnr.log -p 4913
1、监听接受客户端的TCP连接,并获取客户端发过来的TNS数据包
4926 0.000053 getsockname(8, {sa_family=AF_INET6, sin6_port=htons(1521),inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0,sin6_scope_id=0}, [9169787475114065948]) = 0
4926 0.000226 getpeername(8, 0x7fff2c68e5f8, [9169787475114065948]) = -1ENOTCONN (Transport endpoint is not connected)
4926 0.000055 accept(8, {sa_family=AF_INET6, sin6_port=htons(42055),inet_pton(AF_INET6, "::ffff:192.168.0.103", &sin6_addr),sin6_flowinfo=0, sin6_scope_id=0}, [120259084316]) = 12
4926 0.000063 getsockname(12, {sa_family=AF_INET6, sin6_port=htons(1521),inet_pton(AF_INET6, "::ffff:192.168.0.103", &sin6_addr),sin6_flowinfo=0, sin6_scope_id=0}, [120259084316]) = 0
4926 0.000051 fcntl(12, F_SETFL,O_RDONLY|O_NONBLOCK) = 0
4926 0.000034 getsockopt(12, SOL_SOCKET, SO_SNDBUF, [3200064202492396996],[4]) = 0
4926 0.000033 getsockopt(12, SOL_SOCKET, SO_RCVBUF, [3200064202492433792],[4]) = 0
4926 0.000036 setsockopt(12, SOL_TCP, TCP_NODELAY, [1], 4) = 0
4926 0.000087 fcntl(12, F_SETFD, FD_CLOEXEC) = 0
2、监听进程打开用于与子进程通信的管道,同时fork一个子进程,也就是前面我们称为“监听子进程1”的子进程,这里进程号为10209。然后监听进程一直等待,直到这个子进程10209结束
4926 0.000053 pipe([13, 14]) = 0
4926 0.000037 pipe([15, 16]) = 0
4926 0.000042 clone(child_stack=0,flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD,child_tidptr=0x2b3d814b1320) =10209
4926 0.000765 wait4(10209, <unfinished ...>