Difference between revisions of "SUNScholar/Prepare Ubuntu/S06"

From Libopedia
Jump to navigation Jump to search
Line 3: Line 3:
  
 
==Step 6.1: Install PostgreSQL==
 
==Step 6.1: Install PostgreSQL==
  apt-get install postgresql-8.4 libpg-java
+
  sudo apt-get install postgresql-8.4 libpg-java
  
 
==Step 6.2: Setup PostgreSQL admin password==
 
==Step 6.2: Setup PostgreSQL admin password==
 
Change database user permissions to "trust" only.
 
Change database user permissions to "trust" only.
  sed -i 's/ident/trust/' /etc/postgresql/8.4/main/pg_hba.conf
+
  sudo sed -i 's/ident/trust/' /etc/postgresql/8.4/main/pg_hba.conf
  
  sed -i 's/md5/trust/' /etc/postgresql/8.4/main/pg_hba.conf
+
  sudo sed -i 's/md5/trust/' /etc/postgresql/8.4/main/pg_hba.conf
 
Restart database server.
 
Restart database server.
  /etc/init.d/postgresql-8.4 restart
+
  sudo /etc/init.d/postgresql-8.4 restart
 
Open a database shell...
 
Open a database shell...
  psql -U postgres
+
  sudo psql -U postgres
 
... and set the password:
 
... and set the password:
 
  alter role postgres with password 'dspace';
 
  alter role postgres with password 'dspace';
Line 23: Line 23:
 
==Step 6.3: Create the PostgreSQL 'dspace' user==
 
==Step 6.3: Create the PostgreSQL 'dspace' user==
 
First we become the postgres user
 
First we become the postgres user
  su - postgres
+
  sudo su - postgres
 
Create the "dspace" database user with full privileges.
 
Create the "dspace" database user with full privileges.
 
  createuser -U postgres -d -A -P dspace
 
  createuser -U postgres -d -A -P dspace
Line 39: Line 39:
 
==Step 6.5: Setup database host and user access permissions==
 
==Step 6.5: Setup database host and user access permissions==
 
Type the following:
 
Type the following:
  echo "## DSpace user access">> /etc/postgresql/8.4/main/pg_hba.conf
+
  sudo echo "## DSpace user access">> /etc/postgresql/8.4/main/pg_hba.conf
  
  echo "host    dspace      dspace      127.0.0.1/32        md5">> /etc/postgresql/8.4/main/pg_hba.conf
+
  sudo echo "host    dspace      dspace      127.0.0.1/32        md5">> /etc/postgresql/8.4/main/pg_hba.conf
  
 
==Step 6.6: Setup number of client connections==
 
==Step 6.6: Setup number of client connections==
 
Edit the postgresql config file:
 
Edit the postgresql config file:
  
  nano /etc/postgresql/8.4/main/postgresql.conf
+
  sudo nano /etc/postgresql/8.4/main/postgresql.conf
  
 
Change the number of "max_connections" to 300.
 
Change the number of "max_connections" to 300.
Line 55: Line 55:
 
Edit the "/etc/sysctl.conf" file:
 
Edit the "/etc/sysctl.conf" file:
  
  nano /etc/sysctl.conf
+
  sudo nano /etc/sysctl.conf
  
 
Copy and paste the following to the end of the file:
 
Copy and paste the following to the end of the file:
Line 73: Line 73:
 
Type the following:
 
Type the following:
  
  /etc/init.d/postgresql-8.4 restart
+
  sudo /etc/init.d/postgresql-8.4 restart
  
 
Below is a screenshot of the yearly DB connections.
 
Below is a screenshot of the yearly DB connections.

Revision as of 13:25, 4 August 2012

Step 6. Install PostgreSQL

DSpace uses the PostgreSQL database server for the main catalog database. The following procedure installs the PostgreSQL server and creates the "dspace" database and "dspace" database user with the default password.

Step 6.1: Install PostgreSQL

sudo apt-get install postgresql-8.4 libpg-java

Step 6.2: Setup PostgreSQL admin password

Change database user permissions to "trust" only.

sudo sed -i 's/ident/trust/' /etc/postgresql/8.4/main/pg_hba.conf
sudo sed -i 's/md5/trust/' /etc/postgresql/8.4/main/pg_hba.conf

Restart database server.

sudo /etc/init.d/postgresql-8.4 restart

Open a database shell...

sudo psql -U postgres

... and set the password:

alter role postgres with password 'dspace';

Note: Use your unique password for this on a production system !

Quit the database shell.

\q

Step 6.3: Create the PostgreSQL 'dspace' user

First we become the postgres user

sudo su - postgres

Create the "dspace" database user with full privileges.

createuser -U postgres -d -A -P dspace

If asked the following:

Shall the new role be allowed to create more new roles? (y/n) y

Answer "y" for yes.

Step 6.4: Create the PostgreSQL 'dspace' database

Create the "dspace" database with the "dspace" database user.

createdb -U dspace -E UNICODE dspace

Now we exit as the postgres user.

exit

Step 6.5: Setup database host and user access permissions

Type the following:

sudo echo "## DSpace user access">> /etc/postgresql/8.4/main/pg_hba.conf
sudo echo "host    dspace       dspace      127.0.0.1/32         md5">> /etc/postgresql/8.4/main/pg_hba.conf

Step 6.6: Setup number of client connections

Edit the postgresql config file:

sudo nano /etc/postgresql/8.4/main/postgresql.conf

Change the number of "max_connections" to 300.


NANO Editor Help
CTL+O = Save the file and then press Enter
CTL+X = Exit "nano"
CTL+K = Delete line
CTL+U = Undelete line
CTL+W = Search for %%string%%
CTL+\ = Search for %%string%% and replace with $$string$$
CTL+C = Show line numbers

More info = http://en.wikipedia.org/wiki/Nano_(text_editor)


Step 6.7: Increase the kernel shared memory for postgresql connections

Edit the "/etc/sysctl.conf" file:

sudo nano /etc/sysctl.conf

Copy and paste the following to the end of the file:

# Postgres connections
kernel.shmmax = 500000000
kernel.shmall = 500000000

NANO Editor Help
CTL+O = Save the file and then press Enter
CTL+X = Exit "nano"
CTL+K = Delete line
CTL+U = Undelete line
CTL+W = Search for %%string%%
CTL+\ = Search for %%string%% and replace with $$string$$
CTL+C = Show line numbers

More info = http://en.wikipedia.org/wiki/Nano_(text_editor)


Type the following in a terminal:

sysctl -p

Step 6.8: Restart the PostgreSQL server

Type the following:

sudo /etc/init.d/postgresql-8.4 restart

Below is a screenshot of the yearly DB connections.

Sunscholar-postgres connections db-year.png

 PREVIOUS
 NEXT