Environment: Operating System: Ubuntu server 10.10 PostgreSQL version: 8.4.51. Switch to the root account, create the softwares directory under the root directory, and grant the corresponding Permissions
2. Download PostgreSQL 8.4.5
Wget http://wwwmaster.postgresql.org/redir/391/f/source/v8.4.5/postgresql-8.4.5.tar.gz
Download the postgresql-8.4.5.tar.gz file in the current directory.
Then decompress the file using the tar command.
Tar vxf./postgresql-8.4.5.tar.gz
After decompression, you will see the postgresql-8.4.5 directory in the current directory, which has the following files
Before installation, you must make some settings. First, install two library files: libreadline5.dev and zlib1g. Dev.
Sudo apt-Get install libreadline5-dv sudo apt-Get install zlib1g-dev
After the PostgreSQL environment is compiled, execute the following commands in sequence:
./Configure -- prefix = $ define sqlpath make install
Note: $ postgresqlpath indicates the installation directory of your specified PostgreSQL, such as/softwares/PostgreSQL.
After a long compilation and installation, we will see the installation directory under the specified directory.
CD $ export sqlpath/bin
Go to the bin directory under the PostgreSQL installation directory, create a directory for storing database files named pgdata, and create a directory named S under this directory, create a user named S (specifically used to operate databases) and assign the owner of the Postgres directory to it.
After completing the preceding actions, switchPostgresThen go to the $ export sqlpath/bin directory and execute the following command to initialize the data directory:
./Initdb-D pgdata/Postgres
After initialization and creation, the following message is displayed:
You can run the following two commands in the prompt to start the database:
./Postgres-D pgdata/Postgres
By now, the database named as the user you created has been started. You can use pgsql to operate it. To enable the database to start when it is started, we can set it to start when it is started. First, we need to confirm the running level of the current ubuntu.RunlevelCommand
From this we can see that N 2 indicates that the running level of the current ut is 2. We need to set the startup Item in rc2.d under the etc directory.
Go to the rc2.d directory and see the list shown in. We need to add the PostgreSQL startup command in s03rc. Local. Here we need to explain the s03rc. Local file command: we can see that most of the file names in this directory areS + number + file nameComposition,SIndicates that the file is executed when it is started.KThe file at the beginning indicates that it is not running at startup, which is similar to starting or stopping a service in windows.NumberIndicates the running priority. The larger the number, the higher the priority. We use VI to edit s03rc. Local:
Add the following at the Arrow:Code:
Su-c "/softwares/PostgreSQL/bin/pg_ctl start-D/softwares/PostgreSQL/bin/pgdata/Postgres" Postgres
Save and exit file editing. Don't rush to restart the test. First, you need to change the Ubuntu shell settings. From Ubuntu 6.0 or above, shell is changed from the original Bash to a smaller dash, the latter is smaller and more efficient than the former, but some shells that previously supported bash cannot run in Dash. Therefore, we recommend that you switch it back to bash. The procedure is as follows:
Type: sudo dpkg-reconfigure dash
Select "no" on the above page. The following page is displayed:
We can find that Ubuntu deletes the link pointing to dash and adds the bash link and library.
Now we have configured PostgreSQL on Ubuntu.Shutdown-R nowRestart Ubuntu and try to start PostgreSQL.
Note: Ghost fragments are released in the Ubuntu source code to install PostgreSQL | cntechs. TK