Saturday, December 11, 2004
Creating the “postgres” User
Create a UNIX user account to own and manage the PostgreSQL database files. Typically, this user is named postgres, but it can be named anything that you choose.
You will need to have root privileges to create the PostgreSQL superuser. You can use the command shown to add the postgres user.
su - -c "useradd postgres"
tar xvfz postgresql-7.3.4.tar.gz
then logoff and login as the postgres user (this wont work if your java and ant environment variables and path additions are not setup properly)
./configure --with-tcl --with-java
su -c "gmake install"
su -c "chown -R postgres.postgres /usr/local/pgsql"
Setting Environment Variables
The use of the PostgreSQL environment variables is not required. However, they are helpful when performing tasks within PostgreSQL, including starting and shutting down the postmaster processes.
The environment variables that should be set are for the man pages and the bin directory. You can do so by adding the following statements into the /etc/profile file.
export PATH MANPATH
Initializing and Starting PostgreSQL
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
Running postmaster in the background
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l /tmp/pgsql.log start
Configuring the PostgreSQL SysV Script
The SysV script will allow the graceful control of the PostgreSQL database through the use of the SysV runlevel system. The SysV script can be used for starting, stopping, and status-checking of PostgreSQL. It is known to work with most Red Hat based versions of Linux, including Mandrake; however, it should work with other SysV systems (e.g., UnixWare, Solaris, etc.) with little modification. The script is named linux. To use it, you will first need to copy the linux script to your init.d directory. You may require root access to do this.
First, change to the directory where you unpacked the PostgreSQL source. eg /usr/local/src/postgresql-7.1.3/. Then, issue a cp command to copy the script from contrib/start-scripts into the init.d
Copying the linux script
su -c "cp contrib/start-scripts/linux /etc/rc.d/init.d/postgresql"
Making the linux script executable
su -c "chmod a+x /etc/rc.d/init.d/postgresql"
There are no additional requirements to use the SysV script with Red Hat, if you do not intend on using it to start PostgreSQL automatically (i.e., if you wish to use the script manually). However, if you do wish for the script to startup PostgreSQL automatically when the machine boots up (or changes runlevels), you will need to have the chkconfig program installed. If chkconfig is installed, you will also need to add the following two lines, including the hash (#) symbol, at the beginning of the /etc/rc.d/init.d/postgresql file:
# chkconfig: 345 85 15
# description: PostgreSQL RDBMS
Starting PostgreSQL with the SysV script:
service postgresql start
Starting PostgreSQL: ok
service postgresql stop
Stopping PostgreSQL: ok
The next step will be to create a new database. This will be a simple test database. We do not recommend using the default template1 database for testing purposes. As you have not created any users with database-creation rights, you will want to make sure that you are logged in as the postgres user when adding a new database.
To create a new database named testdb, enter the command shown:
You can now start entering SQL commands (e.g., such as SELECT) at the psql prompt
To verify that the database is working correctly, you can issue the command shown in which should give you a listing of the languages installed in the database
SELECT * FROM pg_language;
lanname lanispl lanpltrusted lanplcallfoid lancompiler
internal f f 0 n/a
C f f 0 /bin/cc
sql f f 0 postgres
- Journaling for Performance
- AS400 PRTF - Report Layout Utility
- RIAA sues the dead | The Register
- AS400 / ISeries Freeware / Shareware
- ibm as400 manuals v5r4
- Javalobby - Java J2EE Programming Forums - Coldtags suite 2.1: 210+ custom JSP tags
- Creating an as400 Query
- as400 Iseries Tips
- AS400 APIs
- AS400 API - QCMDEXC - Execute Command