linux服务器重启之后postgresql 无法启动

2015-01-27

postgresql 重新启动 linux 先找到安装目录(使用编译安装) 然后在postgre账户下面

./pg_ctl start -D /user/local/pgsql/data

此时应该可以成功登陆了

但是我的提示

postgres@AY140721213320376387Z:/usr/loca/pgsql/bin$ ./pg_ctl start -D /usr/local/pgsql/data
server starting
postgres@AY140721213320376387Z:/usr/loca/pgsql/bin$ LOG:  could not     bind IPv4 socket: Address already in use
HINT:  Is another postmaster already running on port 5432? If not,  wait a few seconds and retry.
LOG:  database system was shut down at 2015-01-27 11:53:59 CST
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started

说是我的5432端口被占用,查看被谁占用

ostgres@AY140721213320376387Z:/usr/loca/pgsql/bin$ lsof -i
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postgres 2214 postgres    3u  IPv6  14552      0t0  TCP     *:postgresql (LISTEN)
postgres 2214 postgres    7u  IPv4  14562      0t0  UDP localhost:  46020->localhost:46020
postgres 2216 postgres    7u  IPv4  14562      0t0  UDP localhost:  46020->localhost:46020
postgres 2217 postgres    7u  IPv4  14562      0t0  UDP localhost:  46020->localhost:46020
postgres 2218 postgres    7u  IPv4  14562      0t0  UDP localhost:  46020->localhost:46020
postgres 2219 postgres    7u  IPv4  14562      0t0  UDP localhost:  46020->localhost:46020
postgres 2220 postgres    7u  IPv4  14562      0t0  UDP localhost:  46020->localhost:46020

还是没有发现,切换到具有sudo权限的账号执行:

sudo lsof -i:5432
COMMAND   PID        USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postgres 1266 postgres-xc    3u  IPv4  10239      0t0  TCP  localhost:postgresql (LISTEN)
postgres 1266 postgres-xc    4u  IPv4  10240      0t0  TCP  localhost.localdomain:postgresql (LISTEN)

发现问题,postgres-xc 这个账户占领了5432

postgres-xc@AY140721213320376387Z:/usr/loca/pgsql/bin$ lsof -i:5432
COMMAND   PID        USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postgres 1266 postgres-xc    3u  IPv4  10239      0t0  TCP localhost:postgresql (LISTEN)
postgres 1266 postgres-xc    4u  IPv4  10240      0t0  TCP localhost.localdomain:postgresql (LISTEN)

杀到他。

postgres-xc@AY140721213320376387Z:/usr/loca/pgsql/bin$ kill 1266

然后

postgres@AY140721213320376387Z:/usr/loca/pgsql/bin$ ./pg_ctl start -D /usr/local/pgsql/data

server starting
postgres@AY140721213320376387Z:/usr/loca/pgsql/bin$ LOG:  database system was shut down at 2015-01-27 11:58:33 CST
LOG:  database system is ready to accept connections
LOG:  autovacuum launcher started