psql命令不响应

时间:2018-08-07 15:55:45

标签: linux postgresql

当我单独运行psql命令时(没有参数,安装了postgres-10,从Debian Sid运行),它只是保持空白并永远运行。 我尝试使用systemctl status postgresql检查状态,并说服务器处于活动状态。通过将主机指定为localhost运行它,其作用相同。

这是我的postgresql.conf文件的连接设置部分:

 listen_addresses = '*' # what IP address(es) to listen on;
                # comma-separated list of addresses;
                # defaults to 'localhost'; use '*' for all
                # (change requires restart)
 port = 5432                # (change requires restart)
 max_connections = 100          # (change requires restart)
 # Note:  Increasing max_connections costs ~400 bytes of shared memory per
 # connection slot, plus lock space (see max_locks_per_transaction).
 #superuser_reserved_connections = 3    # (change requires restart)
 unix_socket_directories = '/var/run/postgresql'    # comma-separated list of directories
                # (change requires restart)
 #unix_socket_group = ''            # (change requires restart)
 #unix_socket_permissions = 0777        # begin with 0 to use octal notation
                # (change requires restart)
 #bonjour = off             # advertise server via Bonjour
                # (change requires restart)
 #bonjour = on # MJB                    
 #bonjour_name = ''         # defaults to the computer name
                # (change requires restart)

 # - Security and Authentication -

 #authentication_timeout = 1min     # 1s-600s
 ssl = true             # (change requires restart)
 #ssl_ciphers = 'HIGH:MEDIUM:+3DES:!aNULL' # allowed SSL ciphers
                # (change requires restart)
 #ssl_prefer_server_ciphers = on        # (change requires restart)
 #ssl_ecdh_curve = 'prime256v1'     # (change requires restart)
 #ssl_renegotiation_limit = 512MB   # amount of data between renegotiations
 ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'     # (change requires restart)
 ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'        # (change requires restart)
 #ssl_ca_file = ''          # (change requires restart)
 #ssl_crl_file = ''         # (change requires restart)
 #password_encryption = on
 #db_user_namespace = off

 # GSSAPI using Kerberos
 #krb_server_keyfile = ''
 #krb_caseins_users = off

 # - TCP Keepalives -
 # see "man 7 tcp" for details

 #tcp_keepalives_idle = 0       # TCP_KEEPIDLE, in seconds;
                # 0 selects the system default
 #tcp_keepalives_interval = 0       # TCP_KEEPINTVL, in seconds;
                # 0 selects the system default
 #tcp_keepalives_count = 0      # TCP_KEEPCNT;
                # 0 selects the system default

我应该在哪里寻找解决此问题的地方?

1 个答案:

答案 0 :(得分:0)

因此,我们可能需要更多信息。您要放置到终端上并运行psql吗?如果是这样,您是否在不带任何参数的情况下仅运行psql(即$ psql <enter>

单独运行psql命令时,它将尝试连接到套接字或127.0.0.1上的Postgres服务器。如果挂起,则可能是试图连接到127.0.0.1,并且防火墙正在丢弃数据包或没有任何响应,从而导致其挂起。如果等待足够长的时间,它将超时。

也许更好的问题是“您期望发生什么?”是否在与终端相同的机器上运行Postgres服务器?您确定它正在运行吗?是否安装了服务?如果是,sudo systemctl status postgresql-10是否表示它正在运行?如果运行psql -h 127.0.0.1,会发生什么? Postgres是否配置为在网络接口上侦听?是否有防火墙阻止端口5432? Postgres是否在5432端口上运行?

...然后继续列出潜在问题。尝试确定以上问题的答案。您的问题是SO等同于“我的车不工作-怎么了?”;我们需要更多信息以帮助您。 :)