Thursday, August 26, 2010

PostgreSQL Server Information

1. Check Server Status
a. Where is the Server?
$ locate postgresql-8.4 
/etc/init.d/postgresql-8.4
/etc/rc0.d/K21postgresql-8.4
/etc/rc1.d/K21postgresql-8.4
/etc/rc2.d/S19postgresql-8.4
/etc/rc3.d/S19postgresql-8.4
/etc/rc4.d/S19postgresql-8.4
/etc/rc5.d/S19postgresql-8.4
/etc/rc6.d/K21postgresql-8.4
/usr/share/doc/postgresql-8.4
/usr/share/doc/postgresql-8.4/README
/usr/share/doc/postgresql-8.4/README.Debian.gz
/usr/share/doc/postgresql-8.4/changelog.Debian.gz
/usr/share/doc/postgresql-8.4/copyright
/var/cache/apt/archives/postgresql-8.4_8.4.4-0ubuntu10.04_i386.deb
/var/lib/dpkg/info/postgresql-8.4.conffiles
/var/lib/dpkg/info/postgresql-8.4.list
/var/lib/dpkg/info/postgresql-8.4.md5sums
/var/lib/dpkg/info/postgresql-8.4.postinst
/var/lib/dpkg/info/postgresql-8.4.postrm
/var/lib/dpkg/info/postgresql-8.4.prerm
/var/lib/update-rc.d/postgresql-8.4
/var/log/postgresql/postgresql-8.4-main.log
b. Check its status
$ /etc/init.d/postgresql-8.4 --help
Usage: /etc/init.d/postgresql-8.4 {start|stop|restart|reload|force-reload
|status|autovac-start|autovac-stop|autovac-restart}
$ /etc/init.d/postgresql-8.4 status
Running clusters: 8.4/main 
OK, so we have our database cluster at: "8.4/main".
Since postgres home directory is "/var/lib/postgresql", our database cluster resides in
/var/lib/postgresql/8.4/main
2. Stop, Start, Restart Server
$ /etc/init.d/postgresql-8.4 stop
 * Stopping PostgreSQL 8.4 database server
 * Error: You must run this program as 
the cluster owner (postgres)                  [fail]
$ su postgres
$ /etc/init.d/postgresql-8.4 stop
 * Stopping PostgreSQL 8.4 database server    [ OK ] 
$ /etc/init.d/postgresql-8.4 status
Running clusters: 
$ /etc/init.d/postgresql-8.4 start
 * Starting PostgreSQL 8.4 database server    [ OK ] 
$ /etc/init.d/postgresql-8.4 status
Running clusters: 8.4/main 
$ /etc/init.d/postgresql-8.4 restart
 * Restarting PostgreSQL 8.4 database server  [ OK ] 
$ /etc/init.d/postgresql-8.4 status
Running clusters: 8.4/main 
$ exit
exit

No comments:

Post a Comment