Instalacja postgres

root@asl24:~# apt-get install postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libpq5 postgresql-8.4 postgresql-client-8.4 postgresql-client-common postgresql-common ssl-cert
Suggested packages:
  oidentd ident-server postgresql-doc-8.4 openssl-blacklist
The following NEW packages will be installed:
  libpq5 postgresql postgresql-8.4 postgresql-client-8.4 postgresql-client-common postgresql-common ssl-cert
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,420 kB of archives.
After this operation, 25.8 MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://ftp.man.poznan.pl/pub/linux/debian/debian/ squeeze/main postgresql-client-common all 113 [56.9 kB]
Get:2 http://security.debian.org/ squeeze/updates/main libpq5 amd64 8.4.11-0squeeze1 [168 kB]
Get:3 http://security.debian.org/ squeeze/updates/main postgresql-client-8.4 amd64 8.4.11-0squeeze1 [1,537 kB]
Get:4 http://ftp.man.poznan.pl/pub/linux/debian/debian/ squeeze/main ssl-cert all 1.0.28 [14.8 kB]
Get:5 http://ftp.man.poznan.pl/pub/linux/debian/debian/ squeeze/main postgresql-common all 113 [127 kB]
Get:6 http://security.debian.org/ squeeze/updates/main postgresql-8.4 amd64 8.4.11-0squeeze1 [5,488 kB]
Get:7 http://security.debian.org/ squeeze/updates/main postgresql all 8.4.11-0squeeze1 [28.1 kB]
Fetched 7,420 kB in 6s (1,091 kB/s)
Preconfiguring packages ...
Selecting previously deselected package libpq5.
(Reading database ... 22803 files and directories currently installed.)
Unpacking libpq5 (from .../libpq5_8.4.11-0squeeze1_amd64.deb) ...
Selecting previously deselected package postgresql-client-common.
Unpacking postgresql-client-common (from .../postgresql-client-common_113_all.deb) ...
Selecting previously deselected package postgresql-client-8.4.
Unpacking postgresql-client-8.4 (from .../postgresql-client-8.4_8.4.11-0squeeze1_amd64.deb) ...
Selecting previously deselected package ssl-cert.
Unpacking ssl-cert (from .../ssl-cert_1.0.28_all.deb) ...
Selecting previously deselected package postgresql-common.
Unpacking postgresql-common (from .../postgresql-common_113_all.deb) ...
Selecting previously deselected package postgresql-8.4.
Unpacking postgresql-8.4 (from .../postgresql-8.4_8.4.11-0squeeze1_amd64.deb) ...
Selecting previously deselected package postgresql.
Unpacking postgresql (from .../postgresql_8.4.11-0squeeze1_all.deb) ...
Processing triggers for man-db ...
Setting up libpq5 (8.4.11-0squeeze1) ...
Setting up postgresql-client-common (113) ...
Setting up postgresql-client-8.4 (8.4.11-0squeeze1) ...
update-alternatives: using /usr/share/postgresql/8.4/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode.
Setting up ssl-cert (1.0.28) ...
Setting up postgresql-common (113) ...
Adding user postgres to group ssl-cert
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Setting up postgresql-8.4 (8.4.11-0squeeze1) ...
Creating new cluster (configuration: /etc/postgresql/8.4/main, data: /var/lib/postgresql/8.4/main)...
Moving configuration file /var/lib/postgresql/8.4/main/postgresql.conf to /etc/postgresql/8.4/main...
Moving configuration file /var/lib/postgresql/8.4/main/pg_hba.conf to /etc/postgresql/8.4/main...
Moving configuration file /var/lib/postgresql/8.4/main/pg_ident.conf to /etc/postgresql/8.4/main...
Configuring postgresql.conf to use port 5432...
update-alternatives: using /usr/share/postgresql/8.4/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.
Starting PostgreSQL 8.4 database server: main.
Setting up postgresql (8.4.11-0squeeze1) ...
root@asl24:~#
Domyślne uwierzytelnianie automatyczne dla użytkownika systemowego postgres:
root@asl24:~# su - postgres
postgres@asl24:~$ psql
psql (8.4.11)
Type "help" for help.

postgres=# \l
                                  List of databases
  Name    |  Owner   | Encoding |  Collation  |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                            : postgres=CTc/postgres
template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
                                                            : postgres=CTc/postgres
(3 rows)
postgres=#
postgres=# SELECT version();
                                                version
-------------------------------------------------------------------------------------------------------
PostgreSQL 8.4.11 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 64-bit
(1 row)

postgres=#

Postgres domyślnie słucha na porcie 5432:
postgres@asl24:~$ telnet localhost 5432
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
postgres@asl24:~$

Utworzenie konta kalkos, bazy danych baza1
postgres@asl24:~$ createuser kalkos
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) n
Shall the new role be allowed to create more new roles? (y/n) n
postgres@asl24:~$ createdb baza1
postgres@asl24:~$
oraz przydzielenie odpowiednich uprawnień.
postgres@asl24:~$ vi /etc/postgresql/8.4/main/pg_hba.conf
Utworzneie klastra bazy:
root# mkdir /usr/local/pgsql/data
root# chown postgres /usr/local/pgsql/data
root# su postgres
postgres$ initdb -D /usr/local/pgsql/data