Professional Documents
Culture Documents
5 RPM OpenSCG Wiki
Postgres 9.5 RPM
From OpenSCG Wiki
OpenSCG provides PostgreSQL 9.5 RPM packages for an easy installation experience on Redhat, Fedora,
CentOS, OpenSUSE and similar systems. This tutorial explain how to install and configure PostgreSQL
using OpenSCG's rpm packages.
Contents
1 Requirements
2 Installation Steps
3 Configure and initializing PostgreSQL Server
4 Using the database
4.1 Setting the Environment
4.2 Default database
4.3 Default username
4.4 Default password
4.5 Change the default password
4.6 Forgot my password!
5 Uninstalling PostgreSQL Server
6 Reporting Bugs/Suggestions
Requirements
Appropriate 64 bit PostgreSQL 9.5 RPM package from OpenSCG
(http://www.openscg.org/se/postgresql/packages.jsp) .
Installation Steps
The installation of PostgreSQL 9.5 server is very easy. To install:
Download and save RPM package.
[user@fedorax64 ~]$ ls ‐l postgresql‐9.5.1‐1.x64‐bigsql.rpm
‐rw‐r‐‐r‐‐. 1 user user 16389304 Feb 3 12:02 postgresql‐9.5.1‐1.x64‐
bigsql.rpm
Switch to root user.
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 1/8
4/27/2016 Postgres 9.5 RPM OpenSCG Wiki
[user@fedorax64 ~]$ su
Password:
[root@fedorax64 user]#
Install the RPM package
[root@fedorax64 user]# rpm ‐ihv ./postgresql‐9.5.1‐1.x64‐bigsql.rpm
Preparing... ###########################################
[100%]
1:postgresql ###########################################
[100%]
PostgreSQL is cleanly installed to the "/opt/postgres/pg95" directory without changing any other shared
libraries on your system. All the libraries that PostgreSQL uses are in the "/opt/postgres/pg95/lib" directory
to minimize the chances of conflicts and other incompatibilities. You can specify prefix path to rpm to
relocate the package to a location of your choice.
Configure and initializing PostgreSQL Server
OpenSCG's server control script makes it very easy to configure the PostgreSQL server. The 'start'
command will attempt to initialize the server on its first usage (technically in the absence of data directory).
Enter following command in your shell prompt (as root user):
[root@fedorax64 user]# /etc/init.d/postgres‐9.5‐openscg start
You will be prompted to provide database server port, superuser password and server startup options.
You can either press <ENTER> for default values, or you can provide your own customized inputs.
Following the inputs, the database cluster will be initialized and server will be started.
[root@fedorax64 user]# /etc/init.d/postgres‐9.5‐openscg start
PostgreSQL 9.5 Configuration
‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐‐
This will initialize PostgreSQL database cluster. The following
questions will determine the database server port, superuser password
and to start server on system boot. Press <ENTER> to accept defaults.
Specify PostgreSQL server port [5432]:
Specify superuser password [password]:
Do you want PostgreSQL server to be started on boot (y/n) [y]:
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 2/8
4/27/2016 Postgres 9.5 RPM OpenSCG Wiki
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
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 text search configuration will be set to "english".
fixing permissions on existing directory /opt/postgres/pg95/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 32MB
creating configuration files ... ok
creating template1 database in /opt/postgres/pg95/data/base/1 ... ok
initializing pg_authid ... ok
setting password ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects descriptions ... 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
Success. You can now start the database server using:
/opt/postgres/pg95/bin/postgres ‐D /opt/postgres/pg95/data
or
/opt/postgres/pg95/bin/pg_ctl ‐D /opt/postgres/pg95/data ‐l logfile
start
Configuring PostgreSQL server startup scripts
Starting PostgreSQL 9.5:
waiting for server to start.... done
server started
PostgreSQL 9.5 started successfully
To load this postgres into your environment, source the env file:
. /opt/postgres/pg95/pg95‐openscg.env
The server can now be controlled by either using service command and/or by calling the script
directly:
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 3/8
4/27/2016 Postgres 9.5 RPM OpenSCG Wiki
[root@fedorax64 user]# service postgres‐9.5‐openscg status
pg_ctl: server is running (PID: 3291)
/opt/postgres/pg95/bin/postgres "‐D" "/opt/postgres/pg95/data"
[root@fedorax64 user]# /etc/init.d/postgres‐9.5‐openscg status
pg_ctl: server is running (PID: 3291)
/opt/postgres/pg95/bin/postgres "‐D" "/opt/postgres/pg95/data"
The server is controlled by postgres operating system user, which will be created (as a locked account) by
the configuration script if it does not already exists.
Using the database
After installation, using the database is simple:
$ /opt/postgres/pg95/bin/psql ‐U postgres ‐d postgres
Password:
psql (9.5.1)
Type "help" for help.
postgres=#
Setting the Environment
The OpenSCG's RPMs do not do anything to your system environment in order to prevent conflicts with
other software. If you wish to load the environment for this install, you can use the included env file:
[user@fedorax64 ~]$ . /opt/postgres/pg95/pg95‐openscg.env
[user@fedorax64 ~]$ psql
Password:
psql (9.5.1)
Type "help" for help.
postgres=#
This will load:
* PGHOME
* PGDATA
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 4/8
4/27/2016 Postgres 9.5 RPM OpenSCG Wiki
* PATH
* LD_LIBRARY_PATH
* PGUSER
* PGDATABASE
* PGPORT
Default database
The default database created at initialization time (as with most other PostgreSQL packages) is:
postgres
Default username
The default superuser created at initialization time (as with most other PostgreSQL packages) is:
postgres
Default password
The default password (unless you set it at initialization time) is:
password
Change the default password
To change the default password, you first need to login to the database with your current password:
$ /opt/postgres/pg95/bin/psql ‐U postgres ‐d postgres
Password:
psql (9.5.1)
Type "help" for help.
postgres=#
Now, change the password for the postgres user:
postgres=# ALTER USER postgres WITH PASSWORD 'newpasswordgoeshere';
ALTER ROLE
postgres=#
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 5/8
4/27/2016 Postgres 9.5 RPM OpenSCG Wiki
Now your password is changed.
Forgot my password!
If you've forgotten your password, that's no problem. Here's the reset process:
Become the root or postgres user. (Note: postgres might be locked, in which case you must use root
account or unlock postgres account)
[user@fedorax64 ~]$ su
Password:
[root@fedorax64 user]#
Edit the pg_hba.conf (host based access) file using your favorite editor
[root@fedorax64 user]# vi /opt/postgres/9.1/data/pg_hba.conf
Change highlighted line
# TYPE DATABASE USER CIDR‐ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
by changing connection method from md5 to trust:
# TYPE DATABASE USER CIDR‐ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
Save your changes
Command postgres to reread it's config file (either as root or postgres user)
[root@fedorax64 user]# /etc/init.d/postgres‐9.5‐openscg reload
Reloading PostgreSQL 9.5:
server signaled
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 6/8
4/27/2016 Postgres 9.5 RPM OpenSCG Wiki
Switch to normal user and login to the database (you will not be prompted for password).
[root@fedorax64 user]# exit
exit
[user@fedorax64 ~]$ . /opt/postgres/pg95/pg95‐openscg.env
[user@fedorax64 ~]$ psql
psql (9.5.1)
Type "help" for help.
postgres=#
Change the password (as described in previous section)
Edit the pg_hba.conf (host based access) file and change trust back to md5 and reload the server.
Uninstalling PostgreSQL Server
The uninstallation of PostgreSQL server can be performed as follows:
Switch to root user.
[user@fedorax64 ~]$ su
Password:
[root@fedorax64 user]#
Uninstall the RPM package
[root@fedorax64 user]# rpm ‐e postgres92
Attempting to stop server...
Stopping PostgreSQL 9.5:
waiting for server to shut down.... done
server stopped
Attempting to update server startup status...
Uninstallation complete.
Note that the data folder is not deleted after uninstallation.
Reporting Bugs/Suggestions
If you have any questions related to rpm installation, or you would like to report any bugs and/or
suggestions in OpenSCG's RPM packaging, feel free to join OpenSCG mailing list
(http://openscg.org/se/list/oscggeneral) to discuss.
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 7/8
4/27/2016 Postgres 9.5 RPM OpenSCG Wiki
Retrieved from "http://wiki.openscg.com/index.php/Postgres_9.5_RPM"
This page was last modified on 21 December 2015, at 16:47.
http://wiki.openscg.com/index.php/Postgres_9.5_RPM 8/8