方法一:
远程导出需要开放的端口
gbase远程导出时,由于是各计算节点并行向发起导出指令的远程客户端所在文件系统写入数据,因此远程客户端需要和每个计算节点(data)节点建立连接,且需要通过集群互联IP地址(私网IP地址)来建立连接,每个计算节点要与gbase远程客户端通信,远程客户端用的端口为16066~16166。
示例:
假设集群2节点,IP地址为192.168.56.191和192.168.56.192,远程客户端的IP地址为192.168.56.123,则运行rmt远程导出时的端口通信情况如下:
执行导出sql:
gccli -uroot -h192.168.56.191
rmt:select * from test.diis_sd_deposit_normal_data_202003_new into outfile '/home/gbase/diis_sd_deposit_normal_data_202003.txt' fields terminated by ',' WRITEMODE BY OVERWRITES;假设集群2节点,IP地址为192.168.56.191和192.168.56.192,远程客户端的IP地址为192.168.56.123,则运行rmt远程导出时的端口通信情况如下:
执行导出sql:
gccli -uroot -h192.168.56.191
rmt:select * from test.diis_sd_deposit_normal_data_202003_new into outfile '/home/gbase/diis_sd_deposit_normal_data_202003.txt' fields terminated by ',' WRITEMODE BY OVERWRITES;
192.168.56.191上远程导出时TCP连接:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.56.191:39044 192.168.56.123:16066 ESTABLISHED 3004/gbased -- 远程导出TCP连接
tcp6 0 0 192.168.56.191:5258 192.168.56.123:40924 ESTABLISHED 2994/gclusterd
192.168.56.192上远程导出时TCP连接:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.56.191:39044 192.168.56.123:16066 ESTABLISHED 3004/gbased -- 远程导出TCP连接
tcp6 0 0 192.168.56.191:5258 192.168.56.123:40924 ESTABLISHED 2994/gclusterd
因此如果使用rmt远程导出功能,需要开通的端口如下:
远程客户端服务器需要开通16066-16166端口,并保证集群侧每个计算节点能够连接远程导出客户端服务器的16066~16166端口。
远程导出具体的网络连接如下图所示:
方法二:
除上述远程导出方式外,还可以使用gbase通过sftp或者ftp协议将数据导出的远程服务器上的方式,具体方式如下:
gccli -uroot -h192.168.56.191
select * from test.diis_sd_deposit_normal_data_202003_new into outfile 'sftp://gbase:gbase@192.168.56.123/home/gbase/diis_sd_deposit_normal_data_202003.txt' fields terminated by ',' WRITEMODE BY OVERWRITES;
采用这种方式,相当于导出到指定服务器上,通过sftp协议(走22端口)或者ftp协议(走21端口),走sftp协议导出具体的连接方式如下:
192.168.56.191:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.56.191:44904 192.168.56.123:22 TIME_WAIT -
tcp 0 0 192.168.56.191:44916 192.168.56.123:22 ESTABLISHED 3004/gbased -- sftp导出TCP连接
tcp6 0 0 192.168.56.191:5258 192.168.56.123:40924 ESTABLISHED 2994/gclusterd
采用sftp协议方式导出时,不需要远程客户端所在服务器开任何端口,只需要保证集群侧计算节点能够连接远程客户端所在服务器的22端口即可。
ftp协议导出指令如下:
gccli -uroot -h192.168.56.191
select * from test.diis_sd_deposit_normal_data_202003_new into outfile 'ftp://gbase:gbase@192.168.56.123/ diis_sd_deposit_normal_data_202003.txt' fields terminated by ',' WRITEMODE BY OVERWRITES;
走ftp协议导出具体的连接方式如下:
192.168.56.191:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.56.191:47034 192.168.56.123:20130 TIME_WAIT -
tcp 0 0 192.168.56.191:56574 192.168.56.123:40906 TIME_WAIT -
tcp 0 0 192.168.56.191:53624 192.168.56.123:20983 TIME_WAIT -
tcp 0 0 192.168.56.191:39306 192.168.56.123:50564 TIME_WAIT -
tcp 0 0 192.168.56.191:59850 192.168.56.123:19084 TIME_WAIT -
tcp 0 0 192.168.56.191:47580 192.168.56.123:6181 TIME_WAIT -
tcp 0 0 192.168.56.191:49582 192.168.56.123:25606 TIME_WAIT -
tcp 0 0 192.168.56.191:39796 192.168.56.123:17410 TIME_WAIT -
tcp 0 0 192.168.56.191:52842 192.168.56.123:21 ESTABLISHED 3004/gbased -- ftp导出TCP连接
tcp 0 0 192.168.56.191:47526 192.168.56.123:33155 TIME_WAIT -
tcp 0 0 192.168.56.191:47542 192.168.56.123:48554 TIME_WAIT -
tcp6 0 0 192.168.56.191:5258 192.168.56.123:40924 ESTABLISHED 2994/gclusterd
采用ftp协议方式导出时,不需要远程客户端所在服务器开任何端口,只需要保证集群侧计算节点能够连接远程客户端所在服务器的21(ftp服务)端口即可,同时需要开启远程客户端所在服务器的ftp服务。