Differences between revisions 41 and 43 (spanning 2 versions)
Revision 41 as of 2015-01-24 17:18:26
Size: 6764
Editor: Diego Alonso
Comment: Full Spanish translation as by English version on this date
Revision 43 as of 2015-01-24 17:23:45
Size: 6107
Editor: Diego Alonso
Comment: added Spanish into menu
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#language es
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: [[PostgreSql|English]] - español - [[it/PostgreSql|Italiano]] - [[ru/PostgreSql|Русский]]-~
#language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: English - [[es/PostgreSql|español]] - [[it/PostgreSql|Italiano]] - [[ru/PostgreSql|Русский]]-~
Line 7: Line 7:
== Resumen de PostgreSQL ==
PostgreSQL tiene una ayuda extensiva y buena que debería ser la primera fuente de información a consultar respecto a este producto. Esta página esboza las primeras diferencias para la instalación genérica de Postgres utilizada por Debian.
== PostgreSQL Overview ==
PostgreSQL has extensive and good help that should be the first source of information regarding this database product. This page outlines main differences to generic PostgreSQL installation used by Debian.
Line 10: Line 10:
== Instalación ==
Paquetes requeridos: postgresql postgresql-client
== Installation ==
Required packages: postgresql postgresql-client
Line 17: Line 17:
Paquetes recomendados:
 * postgresql-doc - Documentación de PostgreSQL.
 * pgadmin3 - GUI de administración de PostgreSQL.
 * phppgadmin - Herramienta de administración basada en web de PostgreSQL.
Recommended packages:
 * postgresql-doc - PostgreSQL documentation.
 * pgadmin3 - PostgreSQL administration GUI.
 * phppgadmin - PostgreSQL web-based administration tool.
Line 22: Line 22:
Por favor note que los lenguajes procedurales se instalan separadamente (plpgsql viene por defecto). Realice una búsqueda de la base de datos de paquetes pera encontrar todas las posibilidades: Please note that the procedural languages are installed separately (plpgsql comes by default). Perform search packaging database to find the list of possibilities:
Line 28: Line 28:
== Acceso de Usuario ==
Tanto el usuario por defecto de la base de datos como ella misma se llaman '''postgres'''.
== User access ==
Both the default database user and default database are called '''postgres'''.
Line 31: Line 31:
Usted puede conectar a la base de datos utilizando la siguiente orden: You may connect to the database using the following command:
Line 37: Line 37:
=== Nuevo usuario y base de datos ===
Cree una cuenta normal de usuario de sistema utilizando '''adduser''' (salte este paso para utilizar una cuenta existente):
=== New User and database ===
Create a regular system user account using '''adduser''' (skip this step to use an existing account):
Line 43: Line 43:
Conecte a la base de datos Connect to database
Line 49: Line 49:
Cree unos nuevos usuario y base de datos: Create a new database user and a database:
Line 54: Line 54:
o or
Line 60: Line 60:
Salir de la base de datos Quit from the database
Line 65: Line 65:
Conecte como usuario mypguser a la nueva base de datos Connect as user mypguser to new database
Line 71: Line 71:
o or
Line 77: Line 77:
Si obtiene errores como: If you get errors like:
Line 82: Line 82:
edite '''pg_hba.conf''' en /etc/postgresql/X.Y/main/pg_hba.conf edit '''pg_hba.conf''' in /etc/postgresql/X.Y/main/pg_hba.conf
Line 88: Line 88:
reload postgresql reload postgresql 
Line 93: Line 93:
== Documentación == == Documentation ==
Line 95: Line 95:
Para tener una visión general de la arquitectura de PostgreSQL de Debian, instrucciones para un inicio rápido, y punteros a programas y manpages, déle un vistazo a `/usr/share/doc/postgresql-common/README.Debian.gz`. To get an overview about Debian's PostgreSQL architecture, instructions for a quick start, and pointers to the programs and manpages, have a look at `/usr/share/doc/postgresql-common/README.Debian.gz`.
Line 97: Line 97:
== Archivos de tutoriales == == Tutorial files ==
Line 99: Line 99:
La documentación de PostgreSQL apunta al tutorial, que se incluye en el paquete postgresql-doc. Para más información mire en
`/usr/share/doc/postgresql-doc-[versión]/tutorial/README`.
PostgreSQL documentation points to tutorial, which is included in postgresql-doc package. To get more information look at
`/usr/share/doc/postgresql-doc-[version]/tutorial/README`.
Line 102: Line 102:
== Listar Clusters de bases de datos existentes == == Listing existing database clusters ==
Line 104: Line 104:
Utilice la orden pg_lsclusters para comprobar los clusters instalados y obtener alguna información sica tal como: versión (major version), nombre, puerto, estado (en línea o caída), propietario, directorio de datos y archivo de bitácora log. Use pg_lsclusters command to check installed clusters and obtain some basic information such as: version (major version), name, port, status (online or down), owner, data directory and log file.
Line 110: Line 110:
== Recambio pg_ctl ==
pg_ctl es un programa de línea de comándos de PostgreSQL que puede utilizarse para controlar la base de datos. Debian ha construido un envoltorio en Perl para el pg_ctl llamado `/usr/bin/pg_ctlcluster`. Utilice el pg_ctlcluster cuando necesite utilizar el pg_ctl. Para adaptar el comportamiento compruebe el `/etc/postgresql/[versión]/[cluster]/pg_ctl.conf`
== pg_ctl replacement ==
pg_ctl is a PostgreSQL command line control program that can be used to control the database. Debian has made a Perl-wrapper for the pg_ctl called `/usr/bin/pg_ctlcluster`. Use the pg_ctlcluster whenever you need the pg_ctl. To customize the behavior check the `/etc/postgresql/[version]/[cluster]/pg_ctl.conf`
Line 113: Line 113:
Debian instala un script de inicio compatible con SysV-init (estándar) como `/etc/init.d/postgresql-[versión]`. Puede utilizarse para arrancar, parar y recargar el sistema. Llama internamente a pg_ctlcluster. Debian installs SysV-init compatible (standard) start-up script `/etc/init.d/postgresql-[version]`. It can be used to start, stop, restart and reload the system. It calls pg_ctlcluster internally.
Line 115: Line 115:
== Ubicaciones de Archivos ==
Debian separa la configuración de la base de datos de los archivos de la base de datos, en oposición a la instalación genérica de PostgreSQL que coloca todo bajo el mismo directorio. Note que Debian permite a múltiples clusters e incluso diferentes versiones de PostgreSQL coexistir en el mismo host.
== File locations ==
Debian splits the database configuration from the database files, opposed to generic PostgreSQL installation that puts everything under same directory. Note that Debian allows multiple clusters and even different versions of PostgreSQL to co-exist in same host.
Line 118: Line 118:
Archivos de configuración: /etc/postgresql/[versión]/[cluster]/<<BR>>
Binarios: /usr/lib/postgresql/[version]<<BR>>
Archivos de datos: /var/lib/postgresql/[versión]/[cluster]<<BR>>
Configuration files: /etc/postgresql/[version]/[cluster]/<<BR>>
Binaries: /usr/lib/postgresql/[version]<<BR>>
Data files: /var/lib/postgresql/[version]/[cluster]<<BR>>
Line 122: Line 122:
Archivos de bitácora Log: Instalar PostgreSQL crea un directorio de registro `/var/log/postgresql/`. Arrancar el motor de la base de datos crea un archivo de bitácora con el nombre `postgresql-[versión]-[cluster].log`. Log files: Installing PostgreSQL creates log directory `/var/log/postgresql/`. Starting the database engine creates log file with name `postgresql-[version]-[cluster].log`. 
Line 124: Line 124:
== Cambiar la instalación por defecto de Debian ==
La instalación por defecto de Debian PostgreSQL automáticamente llama al initdb p.e. eso inicializa el cluster con la codificación y localización por defecto. La codificación puede ser cambiada luego pero la localización no. Para cambiar la localización (y posiblemente otras opciones de initdb), elimine el cluster existente por defecto y crea uno nuevo:
 1. Tome privilegios root.
 1. Ejecute la siguiente orden:
== Changing Debian default installation ==
Debian PostgreSQL installation automatically calls the initdb i.e. it initializes the cluster with default encoding and locale. Encoding can be changed later but the locale cannot. To change the locale (an possibly other options in initdb), delete the existing default cluster and create a new one:
 1. Take root privileges.
 1. Run the following command:
Line 129: Line 129:
pg_dropcluster --stop <versión> main pg_dropcluster --stop <version> main
Line 131: Line 131:
 Por ejemplo:  For example:
Line 135: Line 135:
 1. Ejecute la initdb con sus opciones. Por ejemplo:  1. Run the initdb with your options. For example:
Line 141: Line 141:
'''¡Aviso!''' '''Warning!'''
Line 143: Line 143:
La operación previa evidentemente elimina todo lo que haya en las bases de datos del cluster. Realice esta operación tras haber instalado el paquete base. Compruebe el manual de PostgreSQL por si necesita cambiar la localización de una base de datos existente (no es una operación trivial). The previous operation obviously deletes everything you had in cluster databases. Perform this operation right after you have installed the base package. Check the PostgreSQL manual if you need to change locale for an existing database (it is not a trivial operation).
Line 146: Line 146:
Compruebe la página de localización [[Locale]] para ver cómo y ver más localizaciones. Check the [[Locale]] page to see how to add more locales.
Line 148: Line 148:
== Véase también == == See Also ==
Line 150: Line 150:
 * [[DebianPkg:postgresql|Paquetes PostgreSQL de Debian]]
 * [[https://lists.alioth.debian.org/mailman/listinfo/pkg-postgresql-public|PostgreSQL en la lista de correo de Debian]]
 * [[DebianPkg:postgresql|PostgreSQL packages in Debian]]
 * [[https://lists.alioth.debian.org/mailman/listinfo/pkg-postgresql-public|PostgreSQL on Debian email list]]
Line 153: Line 153:
 * [[DebianGis/UpdatingPostGIS]] (también describe el actualizar postgresql)  * [[DebianGis/UpdatingPostGIS]] (also describes upgrading postgresql) 
Line 155: Line 155:
== Enlaces externos== == External Links ==
Line 157: Line 157:
 * [[http://www.postgresql.org/|Sitio web oficial de PostgreSQL]]
 * [[WikiPed
ia:PostgreSQL|entrada de PostgreSQL en Wikipedia]]
 * [[http://www.debianhelp.co.uk/postgresql.htm|PostgreSQL en el sitio web de ayuda Debian Help]]
 * [[http://www.postgresql.org/|Official PostgreSQL web site]]
 * [[WikiPe
dia:PostgreSQL|PostgreSQL entry in Wikipedia]]
 * [[http://www.debianhelp.co.uk/postgresql.htm|PostgreSQL in Debian Help web site]]
Line 162: Line 162:
 * [[http://www.commandprompt.com/ppbook/|PostgreSQL práctico]]  * [[http://www.commandprompt.com/ppbook/|Practical PostgreSQL]]
Line 165: Line 165:
 * [[http://petereisentraut.blogspot.com/2011/06/enabling-core-files-for-postgresql-on.html|Activando archivos principales para PostgreSQL en Debian]]  * [[http://petereisentraut.blogspot.com/2011/06/enabling-core-files-for-postgresql-on.html|Enabling core files for PostgreSQL on Debian]]

Translation(s): English - español - Italiano - Русский


PostgreSQL Overview

PostgreSQL has extensive and good help that should be the first source of information regarding this database product. This page outlines main differences to generic PostgreSQL installation used by Debian.

Installation

Required packages: postgresql postgresql-client

# apt-get install postgresql postgresql-client

Recommended packages:

  • postgresql-doc - PostgreSQL documentation.
  • pgadmin3 - PostgreSQL administration GUI.
  • phppgadmin - PostgreSQL web-based administration tool.

Please note that the procedural languages are installed separately (plpgsql comes by default). Perform search packaging database to find the list of possibilities:

# aptitude search postgresql

User access

Both the default database user and default database are called postgres.

You may connect to the database using the following command:

# su - postgres
$ psql

New User and database

Create a regular system user account using adduser (skip this step to use an existing account):

# adduser mypguser    #from regular shell

Connect to database

# su - postgres
$ psql

Create a new database user and a database:

postgres=# CREATE USER mypguser WITH PASSWORD 'mypguserpass';
postgres=# CREATE DATABASE mypgdatabase OWNER mypguser;

or

# createuser mypguser    #from regular shell
# createdb -O mypguser mypgdatabase

Quit from the database

postgres=# \q

Connect as user mypguser to new database

# su - mypguser
$ psql mypgdatabase

or

# psql -d mypgdatabase -U mypguser

If you get errors like:

psql: FATAL:  Ident authentication failed for user "mypguser"

edit pg_hba.conf in /etc/postgresql/X.Y/main/pg_hba.conf

local   all         all                               trust     # replace ident or peer with trust

reload postgresql

# /etc/init.d/postgresql reload

Documentation

To get an overview about Debian's PostgreSQL architecture, instructions for a quick start, and pointers to the programs and manpages, have a look at /usr/share/doc/postgresql-common/README.Debian.gz.

Tutorial files

PostgreSQL documentation points to tutorial, which is included in postgresql-doc package. To get more information look at /usr/share/doc/postgresql-doc-[version]/tutorial/README.

Listing existing database clusters

Use pg_lsclusters command to check installed clusters and obtain some basic information such as: version (major version), name, port, status (online or down), owner, data directory and log file.

pg_lsclusters

pg_ctl replacement

pg_ctl is a PostgreSQL command line control program that can be used to control the database. Debian has made a Perl-wrapper for the pg_ctl called /usr/bin/pg_ctlcluster. Use the pg_ctlcluster whenever you need the pg_ctl. To customize the behavior check the /etc/postgresql/[version]/[cluster]/pg_ctl.conf

Debian installs SysV-init compatible (standard) start-up script /etc/init.d/postgresql-[version]. It can be used to start, stop, restart and reload the system. It calls pg_ctlcluster internally.

File locations

Debian splits the database configuration from the database files, opposed to generic PostgreSQL installation that puts everything under same directory. Note that Debian allows multiple clusters and even different versions of PostgreSQL to co-exist in same host.

Configuration files: /etc/postgresql/[version]/[cluster]/
Binaries: /usr/lib/postgresql/[version]
Data files: /var/lib/postgresql/[version]/[cluster]

Log files: Installing PostgreSQL creates log directory /var/log/postgresql/. Starting the database engine creates log file with name postgresql-[version]-[cluster].log.

Changing Debian default installation

Debian PostgreSQL installation automatically calls the initdb i.e. it initializes the cluster with default encoding and locale. Encoding can be changed later but the locale cannot. To change the locale (an possibly other options in initdb), delete the existing default cluster and create a new one:

  1. Take root privileges.
  2. Run the following command:
    pg_dropcluster --stop <version> main
    For example:
    pg_dropcluster --stop 8.3 main
  3. Run the initdb with your options. For example:
    pg_createcluster --locale de_DE.UTF-8 --start 8.3 main

Warning!

The previous operation obviously deletes everything you had in cluster databases. Perform this operation right after you have installed the base package. Check the PostgreSQL manual if you need to change locale for an existing database (it is not a trivial operation).

Check the Locale page to see how to add more locales.

See Also