User:Dan Nessett/Sandboxes/Sandbox 4: Difference between revisions
imported>Dan Nessett |
imported>Dan Nessett |
||
Line 43: | Line 43: | ||
<pre>gedit .bash_profile &</pre> | <pre>gedit .bash_profile &</pre> | ||
In the edit window there should be a line starting with '''$PATH'''. At the end of this line add ''':/sbin''' (don't forget the colon at the beginning of this text | In the edit window there should be a line starting with '''$PATH'''. At the end of this line add ''':/sbin''' (don't forget the colon at the beginning of this text and there should be no space between the colon and the rest of the line). Then save the edit, exit the editor and type: | ||
<pre>source .bash_profile | <pre>source .bash_profile |
Revision as of 17:39, 10 December 2009
Installing postgres
The version of postgres we want is not available through the normal CentOS software repositories. So, we have to modify the repository information to direct yum (the CentOS software installation utility) to install the correct version. (Note: these instructions are based on those given at Yet Another Guide.
First find out what is the latest install package for postgres 8.3 (install packages for CentOS have the suffix rpm). Using a new tab or browser window, follow the link postgres rpms. Three files should display in the browser window. One of these will have the name pgdg-centos-8.3-x.noarch.rpm, where x will be a number, such as 6. Now download the appropriate yum repository configuration by entering the following at a terminal command prompt (replacing the x in the file name with the integer just discovered):
cd /tmp sudo wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-x.noarch.rpm
Then install this information using the following command (again changing the x to the appropriate integer):
sudo chmod +x pgdg-centos-8.3-x.noarch.rpm sudo rpm -ivf pgdg-centos-8.3-x.noarch.rpm
If you are working on a CentOS installation on which some other software has already been installed, it is possible that other repositories are indicated in the yum configuration files that may interfere with the installation of postgres 8.3. You can determine this as folows. Execute the following commands:
cd /etc/yum.repos.d sudo gedit CentOS-base.repo &
If this file is non-empty, then do the following. (If the file is empty, simply close it without making any changes). There are sections in the configuration file each headed by a word in square brackets. If there are two sections labeled [base] and [updates] then at the bottom of those sections add the line:
exclude=postgresql*
Click on the Save button at the top of the edit window and close it.
Now execute the following commands:
sudo yum install postgresql sudo yum install postgresql-server
For each command a bunch of text is displayed followed by a line that specifies the total download size. The next line is a prompt: Is this ok [y/N]:. You must type y. The default is N, which (of course) means no and taking it will abort the install.
The install of postgres on CentOS does not initialize the directory that postgres uses to store database information. So, the next step is to do this. Execute the following commands:
sudo /etc/rc.d/init.d/postgresql initdb
Installing postgres doesn't mean the server starts up when the system boots. We have to configure the system to do that. First, check that chkconfig is in your execution path. At a command prompt enter:
chkconfig
If the error bash: chkconfig: command not found is returned, you will have to add /sbin to $PATH. This requires editing .bash_profile:
gedit .bash_profile &
In the edit window there should be a line starting with $PATH. At the end of this line add :/sbin (don't forget the colon at the beginning of this text and there should be no space between the colon and the rest of the line). Then save the edit, exit the editor and type:
source .bash_profile chkconfig
This should result in an error message about usage. When chkconfig is working, enter the following commands:
sudo chkconfig --add postgresql sudo chkconfig postgresql on
Now reboot you system and when that completes open a terminal window. Type:
su su postgres psql
A welcome message should display, followed by hints on psql commands and then the prompt postgres=#. At this prompt type \q. The install of postgres is successful.