当我尝试从主机系统上的PostgreSQL客户端连接到VirtualBox来宾系统上的PostgreSQL服务器时,收到“连接尝试失败”消息。
主机系统是Windows XP。我正在运行VirtualBox 3.1.2。来宾系统是带有PostgreSQL 8.4的Ubuntu 9.10 Karmic Koala。
我已经按照手册和这篇文章中的说明转发了VirtualBox中的端口5432 。当我运行时vboxmanage getextradata vmname enumerate,会得到以下条目(以及其他条目):
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/GuestPort, Value: 5432
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/HostPort, Value: 5432
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/pgsql/Protocol, Value: TCP
我在/etc/postgresql/8.4/main/pg_hba.conf中使用以下条目配置了PostgreSQL安全性:
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
host    all         all         192.168.1.0/24        md5
host    all         all         10.0.2.2/32        md5
然后我用重新加载了PostgreSQL sudo /etc/init.d/postgresql-8.4 reload。
仅出于诊断目的,我禁用了Windows防火墙和Ubuntu防火墙(sudo ufw disable)。
有人知道我错过了哪些步骤吗?
systemctl reload postgresql,systemctl restart postgresql终于为我做了。