# 数据迁移上云优化之 - 带宽压缩加速

ssh -C -L 6666:127.0.0.1:1921 postgres@remote_ip  

postgres@db-172-16-3-33-> date +%F%T;psql -h 127.0.0.1 -p 6666 -U postgres db_remote -c "copy schema.tbl_log to stdout" >./tbl_log.dmp;date +%F%T
2011-06-2717:16:50
2011-06-2717:17:08  

postgres@db-172-16-3-33-> date +%F%T;psql -h remote_ip -p 1921 -U schema db_remote -c "copy schema.tbl_log to stdout" >./tbl_log2.dmp;date +%F%T
2011-06-2717:20:06
2011-06-2717:22:29  

man ssh
Specifies that the given port on the local (client) host is to be forwarded to the given host and port on
the remote side.  This works by allocating a socket to listen to port on the local side, optionally bound
to the specified bind_address.  Whenever a connection is made to this port, the connection is forwarded
over the secure channel, and a connection is made to host port hostport from the remote machine.  Port
forwardings can also be specified in the configuration file.  IPv6 addresses can be specified with an
Only the superuser can forward privileged ports.  By default, the local port is bound in accordance with
the GatewayPorts setting.  However, an explicit bind_address may be used to bind the connection to a spe-
cific address.  The bind_address of “localhost” indicates that the listening port be bound for local use
only, while an empty address or ‘*’ indicates that the port should be available from all interfaces.

-C      Requests compression of all data (including stdin, stdout, stderr, and data for forwarded X11 and TCP
connections).  The compression algorithm is the same used by gzip(1), and the “level” can be controlled
by the CompressionLevel option for protocol version 1.  Compression is desirable on modem lines and other
slow connections, but will only slow down things on fast networks.  The default value can be set on a
host-by-host basis in the configuration files; see the Compression option.  

+ 订阅