Postgresql - Conexiones Remotas

Embed Size (px)

DESCRIPTION

CONEXIÓN REMOTACENTOSpostgresql

Citation preview

CONEXIONES REMOTAS

1. Por seguridad, tras una instalacin por defecto de PostgreSQL en Centos, este aceptar nicamente conexiones locales en el puerto5432/tcp.[root@localhost a]# netstat -punta | grep LISTEN tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 3026/postmaster

2. Para modificar este comportamiento tenemos que editar el fichero/var/lib/pgsql/data/pg_hba.conf, que contiene la configuracin para la autenticacin de clientes y aadir el listado de las redes y/o IPs desde las que nos vamos a conectar:[root@localhost a]# vim /var/lib/pgsql/data/pg_hba.confhost all all 127.0.0.1/32 md5host all all 172.25.13.13/32 md5

host all all 172.25.13.0/16 md5su - [root@localhost a]# service postgresql stopStopping postgresql service: [OK] [root@localhost a]# service postgresql startStarting postgresql service: [OK]

3. Adems, tenemos que editar el fichero/var/lib/pgsql/data/postgresql.confy modificar el parmetrolisten_addressespara indicar que escuche en las interfaces necesarias, en este caso lo habilitaremos para todas:[root@localhost a]# vim /var/lib/pgsql/data/postgresql.conflisten_addresses='*' [root@localhost a]# /etc/init.d/postgresql restart [root@localhost a]# netstat -punta | grep LISTEN

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1711/sshd tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 29993/postmaster

[root@localhost a]# service postgresql stopStopping postgresql service: [OK] [root@localhost a]# service postgresql startStarting postgresql service: [OK]

Nota: para mayor informacin chequear el link: http://wiki.woop.es/PostgreSQL

4. Modificar la contrasea del usuario postgres de PostgreSQLPara cambiar la contrasea de un usuario de PostgreSQL tenemos que utilizar la sentencia sql:ALTER USER usuario WITH PASSWORD:# su - postgres$ psql -d template1 -U postgres

template1=# ALTER USER postgres WITH PASSWORD 'zaQ6RzRhFb';ALTER ROLE

5. Comprobar la versin de PostgreSQL instalada.La forma ms cmoda es ejecutando la sentencia SQL SELECT VERSION(), ejemplo:template1=# SELECT VERSION(); Version -----------------------------------------------------------------------------------------------------------PostgreSQL 8.1.11 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14)(1 fila)

Nota:Otros detalles que hay que tener en cuenta para la conexin remota, es desactivar el firewall en el servidor de base de datos postgres.