Note: If you are upgrading PostgresSQL (from earlier version), then
make sure that you backup (dump and copy) your database and configs.
Install PostgreSQL 9.2.1 Database Server on Fedora 18
Change root user
su -
Exclude Fedora own PostgreSQL Packages
Add exclude to /etc/yum.repos.d/fedora.repo file [fedora] section:
Add exclude to /etc/yum.repos.d/fedora.repo file [fedora] section:
[fedora]
...
exclude=postgresql*
Add exclude to /etc/yum.repos.d/fedora-updates.repo file [updates] section:
[updates]
...
exclude=postgresql*
Install PostgreSQL 9.2 Repository
rpm -Uvh http://yum.postgresql.org/9.2/fedora/fedora-18-x86_64/pgdg-fedora92-9.2-6.noarch.rpm
Para Fedora 19
rpm -Uvh http://yum.postgresql.org/9.2/fedora/fedora-19-x86_64/pgdg-fedora92-9.2-6.noarch.rpm
Ésta es una forma de llamar el comando, pero se puede personalizar segun sean las caracteristicas de su Sistema Operativo y Arquitectura, obteniendo la información de: http://yum.postgresql.org/9.2/fedora/
Install PostgreSQL 9.2 with YUM
yum install postgresql postgresql-server postgresql-contrib
Configure PostgreSQL 9.2
Initialize Cluster with initdb Command
Here is multiple alternatives howto do this (like service postgresql-9.x initdb, /etc/init.d/postgresql-9.x initdb) and postgresql-setup initdb, so that’s why I use here universal PostgreSQL initdb method, which should work with Fedora 18, CentOS/Red Hat (RHEL)/Scientific Linux (SL) 6.3/5.8:
su - postgres -c /usr/pgsql-9.2/bin/initdb
Set PostgreSQL Server to Listen Addresses and Set Port
Open /var/lib/pgsql/9.2/data/postgresql.conf file, and add/uncomment/modify following:
Open /var/lib/pgsql/9.2/data/postgresql.conf file, and add/uncomment/modify following:
listen_addresses = '*'
port = 5432
If you want just localhost setup, then use following:
listen_addresses = 'localhost'
port = 5432
Or if you want use specific ip, then use following:
listen_addresses = '192.1.2.33'
port = 5432
Set PostgreSQL Permissions
Modify PostgreSQL /var/lib/pgsql/9.2/data/pg_hba.conf (host-based authentication) file:
# Local networks
host all all xx.xx.xx.xx/xx md5
# Example
host all all 10.20.4.0/24 md5
# Example 2
host test testuser 127.0.0.1/32 md5
Modify PostgreSQL /var/lib/pgsql/9.2/data/pg_hba.conf (host-based authentication) file:
# Local networks
host all all xx.xx.xx.xx/xx md5
# Example
host all all 10.20.4.0/24 md5
# Example 2
host test testuser 127.0.0.1/32 md5
You can find more examples and full guide from PostgreSQL pg_hba.conf manual -> http://www.postgresql.org/docs/9.2/static/auth-pg-hba-conf.html
Start PostgreSQL Server and Autostart PostgreSQL on Boot
Despues del siguiente bloque, veremos llamar a postgresql-9.2.service pero ¿De donde obtenemos el nombre del servicio?, para obtenerlo acceder a la siguiente direccion:
]# pwd
/usr/lib/systemd/system
]# ls pos*
postgresql-9.2.service
Entonces ejecutar:
## Start PostgreSQL 9.2 ##
systemctl start postgresql-9.2.service
## Start PostgreSQL 9.2 on every boot ##
systemctl enable postgresql-9.2.service
Create Test Database and Create New User
Change to postgres user
su postgres
Create test database (as postgres user)
createdb test
Login test database (as postgres user)
psql test
Create New “testuser” Role with Superuser and Password
CREATE ROLE testuser WITH SUPERUSER LOGIN PASSWORD 'test';
Test Connection from localhost (as Normal Linux User)
psql -h localhost -U testuser test
De ésto modo ya tengo instalado PostgreSQL, pero necesito de una herramienta gráfica, por lo que recurro a instalar:
yum -y install pgadmin3
Aquí una imagen ya de nuestro gestor instalado.
Echa un vistazo a una herramienta gratuita - Valentina Studio. Producto asombroso! OMI es el mejor gestor de PostgreSQL, para todas las plataformas. http://www.valentina-db.com/en/valentina-studio-overview
ReplyDeleteSuena bastante bien, he revisado la liga y me interesa por el Módulo SQL Editor. Gracias por el dato, lo hecho andar y aqui mismo lo mencionaré. Un Saludo.
Delete