1.问题:服务器突然断电,连接数据库报错。计划重启,发现postgresql重启失败。
psql: error: could not connect to server: 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"?
执行:service postgresql restart显示failed
2.查看/tmp目录下并没有.s.PGSQL.5432;尝试删除postmaster.pid,重启postgresql依然失败,所以猜测不是删除/tmp/.s.PGSQL.5432和postmaster.pid能解决的
3.尝试切换到pgadmin用户,执行su - pgadmin失败,查看cat /etc/passwd,发现pgadmin:x:500:500::/home/pgadmin:/sbin/nologin,用户pgadmin无法登录。
4.解决方法:执行usermod -s /bin/bash pgadmin,允许pgadmin用户登录,重新启动psql成功。