我有一个python脚本,它对postgresql数据库执行查询(RedShift。它在我的本地机器上运行得非常好:
Ubuntu 12.10,
python 2.7
psycog.__version__ = '2.5.3 (dt dec pq3 ext)'
但是当我在AWS
CentOS 6.5
Python 2.6
psycog.__version__ = '2.5.3 (dt dec pq3 ext)'
以下是代码:
import psycopg2
con = psycopg2.connect(**{<my_connection_params>}})
curs = con.cursor()
# This works perfectly fine on both machines !!!
curs.execute("""SELECT table_name FROM information_schema.tables
WHERE table_schema='public' AND table_type='BASE TABLE'""")
# This one hangs on AWS, but works fine from my laptop
curs.execute('select column_name from information_schema.columns')
当我连接到db
并运行查询以查看正在运行的进程时,我可以看到:
select pid, trim(user_name), starttime, substring(query,1,20)
from stv_recents
where status='Running';
我可以看到这个查询。
这是一个strace -p
:
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x3aaa00f710}, {0x3ab1027010, [], SA_RESTORER|SA_RESTART, 0x3aaa00f710}, 8) = 0
gettimeofday({1403280035, 826010}, NULL) = 0
rt_sigprocmask(SIG_BLOCK, [PIPE], [], 8) = 0
write(3, "\27\3\1\0 5\351Br$\331\30\00563\v\211f\325\367\210\331\331\253\300\310\240"..., 122) = 122
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
poll([{fd=3, events=POLLIN|POLLERR}], 1, -1) =
答案 0 :(得分:2)
事实证明:
Amazon EC2-Classic实例每个最多可处理1500个字节的数据 框架,而Amazon EC2-VPC实例最多可以处理9000个字节 每帧数据。在混合环境中,我们建议禁用TCP / IP 通过在Amazon EC2-VPC中将MTU设置为1500来实现巨型帧 实例;这样,两个实例最多使用1500个字节。这不是 如果客户端和集群实例都使用Amazon EC2-VPC,则必需。
http://docs.aws.amazon.com/redshift/latest/mgmt/connecting-drop-issues.html
所以这一行将解决它:
ip link set dev eth0 mtu 1500