问题解决:psql: could not connect to server: No such file or directory Is the server running

CDH使用postgresql作为数据库,登陆postgresql数据库,没有成功,排查下问题

CDH5.5.1 postgresql路径
cd /var/lib/cloudera-scm-server-db/data/

[root@ambariserver pg_log]# service cloudera-scm-server-db restart
waiting for server to shut down............................................................... failed
pg_ctl: server does not shut down
Database is already running. Please stop it first., giving up

[root@ambariserver pg_log]# service cloudera-scm-server restart
Stopping cloudera-scm-server:                              [  OK  ]
Starting cloudera-scm-server:                              [  OK  ]

[root@ambariserver pg_log]# service cloudera-scm-server-db restart
waiting for server to shut down............................................................... failed
pg_ctl: server does not shut down
Database is already running. Please stop it first., giving up

[root@ambariserver pg_log]# service cloudera-scm-server-db stop
waiting for server to shut down............................................................... failed
pg_ctl: server does not shut down


[root@ambariserver pg_log]# service cloudera-scm-server-db status
pg_ctl: server is running (PID: 15487)
/usr/bin/postgres "-D" "/var/lib/cloudera-scm-server-db/data"

查看下日志,应该是端口服务器使用
[root@ambariserver pg_log]# cat /var/log/cloudera-scm-server/db.log|more
LOG:  could not bind IPv4 socket: Address already in use
HINT:  Is another postmaster already running on port 7432? If not, wait a few seconds and retry.
LOG:  could not bind IPv6 socket: Address already in use
HINT:  Is another postmaster already running on port 7432? If not, wait a few seconds and retry.
WARNING:  could not create listen socket for "*"
FATAL:  could not create any TCP/IP sockets
LOG:  could not bind IPv4 socket: Address already in use
HINT:  Is another postmaster already running on port 7432? If not, wait a few seconds and retry.
LOG:  could not bind IPv6 socket: Address already in use
HINT:  Is another postmaster already running on port 7432? If not, wait a few seconds and retry.
WARNING:  could not create listen socket for "*"
FATAL:  could not create any TCP/IP sockets

查看端口在用
netstat -lanp|grep 7432
ps -ef|grep postgres
498        673     1  0 10:50 ?        00:00:00 /usr/bin/postgres -D /var/lib/cloudera-scm-server-db/data

kill进程
kill -9 673

重启启动服务
service cloudera-scm-server-db start
service cloudera-scm-server-db status


[root@ambariserver pg_log]# service cloudera-scm-server restart
cloudera-scm-server is already stopped
Starting cloudera-scm-server:                              [  OK  ]


[root@ambariserver pg_log]# service cloudera-scm-server status
cloudera-scm-server (pid  915) is running...


su - prestogres

psql

错误提示:
psql: could not connect to server: No such file or directory
 Is the server running locally and accepting
 connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
 
出现该问题的很多,以下是目前碰到的几种情况,之后碰到继续补充:
 
1.删除了/tmp路径中的.s.PGSQL.5432 与.s.PGSQL.5432.lock文件或其它端口的文件
 
 解决:重启数据库 $sudo service postgresql restart
 
2.修改监听端口:
 之前用5432监听,后来改为7432,数据库启动,但是psql无法进入数据库,通过psql -p 7432可以进入。
CDH安装postgres用了7432端口

 解决:安装时配置了端口PGPORT。修改~/.bash_profile或/etc/profile文件中的端口指定。
 
3.修改了postgresql.conf 中的unix_socket_directories



引用其中:
"先来看看 socket 文件 "/tmp/.s.PGSQL.1921",其中 1921 是 pg 的端口号; socket 文件可以通过
 postgresql.conf 文件以下参数配置:
#unix_socket_directory = ''
#unix_socket_permissions = 0777
备注:其中参数 unix_socket_directory 用来配置 socket 文件的目录,默认是 /tmp 目录,参数
unix_socket_permissions 用来设置 socket 文件的权限。"

解决方法:指定host,用psql -h 连接


参考:

http://www.cnblogs.com/space-place/p/5257127.html
http://francs3.blog.163.com/blog/static/40576727201332594924829/
http://blog.csdn.net/huguangshanse00/article/details/40413549

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值