install
As
root
%CODE{"bash"}%
zypper install postgresql postgresql-jdbc postgresql-server
%ENDCODE%
Results in ...
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 7 NEW packages are going to be installed:
libpq5 postgresql postgresql94 postgresql94-server postgresql-init postgresql-jdbc postgresql-server
7 new packages to install.
Overall download size: 5.2 MiB. Already cached: 0 B. After the operation, additional 21.8 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package postgresql jdbc-9.4-3.2.noarch (1/7), 587.9 KiB (617.4 KiB unpacked)
Retrieving: postgresql-jdbc-9.4-3.2.noarch.rpm ......................................................[done]
Retrieving package libpq5-9.4.6-4.1.x86_64 (2/7), 159.5 KiB (464.6 KiB unpacked)
Retrieving: libpq5-9.4.6-4.1.x86_64.rpm .................................................[done (3.2 MiB/s)]
Retrieving package postgresql-init-9.4-6.1.noarch (3/7), 11.0 KiB ( 7.5 KiB unpacked)
Retrieving: postgresql-init-9.4-6.1.noarch.rpm ......................................................[done]
Retrieving package postgresql94-9.4.6-4.1.x86_64 (4/7), 1.1 MiB ( 4.2 MiB unpacked)
Retrieving: postgresql94-9.4.6-4.1.x86_64.rpm .......................................................[done]
Retrieving package postgresql94-server-9.4.6-4.1.x86_64 (5/7), 3.4 MiB ( 16.6 MiB unpacked)
Retrieving: postgresql94-server-9.4.6-4.1.x86_64.rpm ....................................[done (6.6 MiB/s)]
Retrieving package postgresql-9.4-1.1.noarch (6/7), 3.8 KiB ( 83 B unpacked)
Retrieving: postgresql-9.4-1.1.noarch.rpm ...........................................................[done]
Retrieving package postgresql-server-9.4-1.1.noarch (7/7), 3.8 KiB ( 83 B unpacked)
Retrieving: postgresql-server-9.4-1.1.noarch.rpm ....................................................[done]
Checking for file conflicts: ........................................................................[done]
(1/7) Installing: postgresql-jdbc-9.4-3.2.noarch ....................................................[done]
(2/7) Installing: libpq5-9.4.6-4.1.x86_64 ...........................................................[done]
(3/7) Installing: postgresql-init-9.4-6.1.noarch ....................................................[done]
Additional rpm output:
Updating /etc/sysconfig/postgresql...
(4/7) Installing: postgresql94-9.4.6-4.1.x86_64 .....................................................[done]
(5/7) Installing: postgresql94-server-9.4.6-4.1.x86_64 ..............................................[done]
(6/7) Installing: postgresql-9.4-1.1.noarch .........................................................[done]
(7/7) Installing: postgresql-server-9.4-1.1.noarch ..................................................[done]
Then create the data directory:
%CODE{"bash"}%
mkdir -p /data/postgresql/9.4/data &&
chown postgres /data/postgresql/9.4/data
%ENDCODE%
And change to user
postgres
%CODE{"bash"}%su - postgres %ENDCODE%
Initialize Database Directory:
%CODE{"bash"}% initdb -D /data/postgresql/9.4/data/ %ENDCODE%
Results in ...
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /data/postgresql/9.4/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /data/postgresql/9.4/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
postgres -D /data/postgresql/9.4/data
Exit back to superuser
root
:
%CODE{"bash"}%exit %ENDCODE%
Check and set boot option of service
postgresql
%CODE{"bash"}%chkconfig -l postgresql%ENDCODE%
postgresql 0:off 1:off 2:off 3:off 4:off 5:off 6:off
%CODE{"bash"}%chkconfig postgresql on &&
chkconfig -l postgresql%ENDCODE%
postgresql 0:off 1:off 2:off 3:on 4:off 5:on 6:off
Edit
/etc/sysconfig/postgresql
%CODE{"bash"}%vi /etc/sysconfig/postgresql%ENDCODE%
Set
POSTGRES_DATADIR
#POSTGRES_DATADIR="~postgres/data"
POSTGRES_DATADIR="/data/postgresql/9.4/data"
Change to user
postgres
...
%CODE{"bash"}%su - postgres %ENDCODE%
... and edit the configuration file
postgresql.conf
:
%CODE{"bash"}%export PGDATA=/data/postgresql/9.4/data/ &&
vi $PGDATA/postgresql.conf%ENDCODE%
#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
#listen_addresses = 'localhost' # what IP address(es) to listen on;
listen_addresses = '*' # what IP address(es) to listen on;
... followed by an edit of the file
pg_hba.conf
:
%CODE{"bash"}%$PGDATA/pg_hba.conf %ENDCODE%
hostnossl archive archiver .gsi.de trust
hostnossl archive report .gsi.de trust
hostnossl archive archiver 10.203.0.0/16 trust
hostnossl archive report 10.203.0.0/16 trust
Back to superuser
root
:
%CODE{"bash"}%exit %ENDCODE%
Start
postgresql
as a
service
%CODE{"bash"}%service postgresql start %ENDCODE%
Become again user
postgres
%CODE{"bash"}%su - postgres %ENDCODE%
create test db and connect to it
%CODE{"bash"}%createdb test &&
psql test%ENDCODE%