Primary database IP: 192.168.0.11
主库:目前的状态是我们没有关闭任何端口,
没有切换的时候,我们没有发现备库连接主库的动作。但是备库有主库连接的动作,表明主库LNS时刻准备着把REDO LOG传输给备库。
[root@mycos-p ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:63270 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:63577 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:13838 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:13840 ESTABLISHED
tcp 0 0 127.0.0.1:61296 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:57266 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:46582 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:3938 127.0.0.1:23364 TIME_WAIT
tcp 0 0 127.0.0.1:48428 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:42323 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:54262 127.0.0.1:1158 TIME_WAIT
tcp 0 0 192.168.0.11:22 192.168.0.1:1616 ESTABLISHED
tcp 0 0 127.0.0.1:37173 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:40226 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:30024 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:19767 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:13815 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.11:22 192.168.0.1:4558 ESTABLISHED
tcp 0 0 192.168.0.11:22 192.168.0.1:4303 ESTABLISHED
tcp 0 0 127.0.0.1:13838 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:13840 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.11:22 192.168.0.1:1730 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:13815 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:46579 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:46578 TIME_WAIT
standby database IP:192.168.0.12
[root@mycos-s ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:48730 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48750 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48748 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48749 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.12:22 192.168.0.1:1623 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48730 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:45153 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:48749 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48748 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48750 ESTABLISHED
tcp 0 0 127.0.0.1:34507 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:34508 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:25059 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.12:1521 192.168.0.11:35491 ESTABLISHED
tcp 0 0 127.0.0.1:3938 127.0.0.1:46526 TIME_WAIT
tcp 0 0 192.168.0.12:22 192.168.0.1:4559 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:34508 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:34507 ESTABLISHED
tcp 0 0 192.168.0.12:22 192.168.0.1:1731 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:25059 ESTABLISHED
主库在切换日志瞬间
我们切换的瞬间有了备库连接主库动作,为什么呢?因为要去主库检测API
[root@mycos-p ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:1521 127.0.0.1:13838 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:13840 ESTABLISHED
tcp 0 0 127.0.0.1:3938 127.0.0.1:9753 TIME_WAIT
tcp 0 0 127.0.0.1:60859 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:54801 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:56083 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:33617 TIME_WAIT
tcp 0 0 192.168.0.11:22 192.168.0.1:1616 ESTABLISHED
tcp 0 0 127.0.0.1:40934 127.0.0.1:1521 TIME_WAIT
tcp 0 0 192.168.0.11:35491 192.168.0.12:1521 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:26525 TIME_WAIT
tcp 0 0 127.0.0.1:6528 127.0.0.1:1158 TIME_WAIT
tcp 0 0 127.0.0.1:13815 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.11:22 192.168.0.1:4558 ESTABLISHED
tcp 0 0 192.168.0.11:22 192.168.0.1:4303 ESTABLISHED
tcp 0 0 127.0.0.1:13838 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:13840 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.11:22 192.168.0.1:1730 ESTABLISHED
tcp 0 0 127.0.0.1:10308 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:52713 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:13815 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:19195 TIME_WAIT
主库在切换日志瞬间
备库端口情况
[root@mycos-s ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:46786 127.0.0.1:1158 TIME_WAIT
tcp 0 0 127.0.0.1:48730 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48750 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48748 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48749 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.12:22 192.168.0.1:1623 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48730 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48749 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48748 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48750 ESTABLISHED
tcp 0 0 127.0.0.1:34507 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:34508 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:25059 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.12:1521 192.168.0.11:35491 ESTABLISHED
tcp 0 0 192.168.0.12:22 192.168.0.1:4559 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:34508 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:34507 ESTABLISHED
tcp 0 0 192.168.0.12:22 192.168.0.1:1731 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:25059 ESTABLISHED
tcp 0 0 192.168.0.12:1521 192.168.0.16:25320 ESTABLISHED
端口总结:首先主库,备库必须打开1521 端口,通信。 同时主库又打开了35491端口。现在测试一下这个端口是不是,不变化的呢。我们重启主库。
看下我们重启之后的状态:很明显主库,备库开启了 1521端口外,又开启了 13445,13444这2个端口。
[root@mycos-p ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:35794 127.0.0.1:1158 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:14623 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:45362 TIME_WAIT
tcp 0 0 192.168.0.11:22 192.168.0.1:1616 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:16223 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:25189 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:24678 TIME_WAIT
tcp 0 0 127.0.0.1:38595 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38598 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:38596 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38597 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38606 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38607 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38604 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38605 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38610 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38611 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38608 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38609 127.0.0.1:1521 TIME_WAIT
tcp 0 0 127.0.0.1:38614 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:38618 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:3938 127.0.0.1:43906 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:3749 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:19627 TIME_WAIT
tcp 0 0 192.168.0.11:13445 192.168.0.12:1521 ESTABLISHED
tcp 0 0 192.168.0.11:13444 192.168.0.12:1521 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:38598 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:38593 TIME_WAIT
tcp 0 0 192.168.0.11:22 192.168.0.1:4303 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:38594 TIME_WAIT
tcp 0 0 192.168.0.11:22 192.168.0.1:1730 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:38603 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:38602 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:38614 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:58322 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:38619 TIME_WAIT
tcp 0 0 127.0.0.1:1521 127.0.0.1:38618 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:4835 TIME_WAIT
[root@mycos-s ~]# netstat -n
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:48730 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48750 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48748 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:48749 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.12:22 192.168.0.1:1623 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48730 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48749 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48748 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:48750 ESTABLISHED
tcp 0 0 127.0.0.1:34507 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:34508 127.0.0.1:1521 ESTABLISHED
tcp 0 0 192.168.0.12:1521 192.168.0.11:13444 ESTABLISHED
tcp 0 0 192.168.0.12:1521 192.168.0.11:13445 ESTABLISHED
tcp 0 0 127.0.0.1:25059 127.0.0.1:1521 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:34508 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:34507 ESTABLISHED
tcp 0 132 192.168.0.12:22 192.168.0.1:1731 ESTABLISHED
tcp 0 0 127.0.0.1:1521 127.0.0.1:25059 ESTABLISHED
tcp 0 0 192.168.0.12:1521 192.168.0.16:25320 ESTABLISHED
tcp 0 0 127.0.0.1:3938 127.0.0.1:4350 TIME_WAIT
总结:通过我们对端口的追踪,可以发现如果我们主库,备库只开1521端口是远远不够的,而且主库会随机的开启端口,所以只开启1521端口,是不能保持DG通信的。我们这里只是简单的测试了一下重新主库,就开启了1521端口以外的端口。所以如果是业务DG还是开启所有端口比较好,安全层次的去上层做吧,不要在服务器端口这里想办法了,至少我们DG开启1521端口是不合适的。