A database is required by some of the Software Component Services. Currently, the OMII Stack Installer offers a choice of PostgreSQL databases for installation.
Though the installer will install the database, create tables and users etc automatically for you, you may encounter problems subsequently and this topic aims to provide you with some self-help information.
Type the following at the shell prompt (assumes that pg_ctl is on your path):
pg_ctl --version
pg_ctl typically installs into /usr/bin. This should return the version of PostgreSQL which has been installed (if at all). If this is not the case, please install PostgreSQL before moving onto the next step.
If you install the database using the OMII Stack Installer and then reboot the machine, you will have to start the database manually before going on to install the OMII server stack. The recommended method is via the OMII database service script (you do not need to be the postgres user):
[root user] ./database_service start
[non-root user] ./database_service start /home/user/database/postgres
The database_service.pl script can be found in /var/lib/pgsql for the root user.
To stop the database, use:
[root user] ./database_service stop
[non-root user] ./database_service stop /home/user/database/postgres
The database_service.pl script can be found alongside the database for the non-root user.
To find out if PostgreSQL is already running, use the following:
[root user only] ./database_service.pl status
or
ps -ef|grep postmaster
You should only attempt to kill processes manually if you are sure you know what you are doing and that you will not impact other users! If in doubt, do not attempt this - contact your System Administrator instead.
If you have established that PostgreSQL is running and it will not stop using the database_service.pl script, you may wish to manually kill it. Use:
ps -ef|grep postmaster
and note the process id. Then use:
kill -9 pid
Rerun the ps command afterwards to ensure that the process is no longer present. You should be aware that killing a running PostgreSQL server may result in residual lock files which prohibit the server restarting.
You should only attempt to remove lock files if you are sure you know what you are doing and that you will not impact other users! If in doubt, do not attempt this - contact your System Administrator instead.
If you are installing a database and it gets to a point where the output states "Starting Database" and it stays there for several minutes, you may have an old lock file left over from a manual process kill.
To check if you have any PostgreSQL lock files, do:
ls -la /tmp
and check for files called eg. ".s.PGSQL.5432.lock". The port number of the database is part of the lock file name and should help you identify which is yours. Remove this file and you should see you should be able to start your database.
If you get in a mess, particularly with multiple databases on one machine, you may wish to 'clean' the machine down and remove all traces of PostgreSQL so you can start again. There are a series of steps for this:
Ensure PostgreSQL is not running - check to see if it is running and if it is, stop it or as a last resort, kill the process.
[root user] Next we have to remove the RPMs and the files from /var/lib/pgsql and you will need to be the root user to do this.
rpm -qa|grep postgres (lists your installed PostgreSQL packages)
rpm -e docs jdbc server mainrpm libs (if you remove all RPMs in one command like this, the order is irrelevant. If you remove them one at a time, you need to remove them in the order shown with docs first in order to avoid dependency problems).
rm -rf backups data logfile (removes two database related directories and the logfile)
[non-root user] If you installed your database as a non-root user, you need to do the following:
Stop the postmaster process using the database_service.pl script.
rm -rf the postgres directory (this will remove both the database and the datafiles).