Next: , Previous: , Up: Servicios   [Contents][Index]


11.10.12 Servicios de bases de datos

El módulo (gnu services databases) proporciona los siguientes servicios.

PostgreSQL

Variable: postgresql-service-type

The service type for the PostgreSQL database server. Its value should be a valid postgresql-configuration object, documented below. The following example describes a PostgreSQL service with the default configuration.

Si los servicios fallan al arrancar puede deberse a que ya se encuentra presente otro cluster incompatible en data-directory. Puede modificar el valor (o, si no necesita más dicho cluster, borrar data-directory), y reiniciar el servicio.

La identificación de pares se usa de manera predeterminada y la cuenta de usuaria postgres no tiene intérprete predeterminado, lo que evita la ejecución directa de órdenes psql bajo dicha cuenta. Para usar psql, puede ingresar temporalmente al sistema como postgres usando un intérprete de órdenes, crear una cuenta de administración de PostgreSQL con el mismo nombre de una de las usuarias del sistema y, tras esto, crear la base de datos asociada.

sudo -u postgres -s /bin/sh
createuser --interactive
createdb $MI_CUENTA_DE_USUARIA  # Sustituir por el valor apropiado.
Tipo de datos: postgresql-configuration

Tipo de datos que representa la configuración de postgresql-service-type.

postgresql (default: postgresql-10)

El paquete PostgreSQL usado para este servicio.

port (predeterminado: 5432)

Puerto en el que debe escuchar PostgreSQL.

locale (predeterminado: "en_US.utf8")

Localización predeterminada cuando se crea el cluster de la base de datos.

config-file (predeterminado: (postgresql-config-file))

The configuration file to use when running PostgreSQL. The default behaviour uses the postgresql-config-file record with the default values for the fields.

log-directory (default: "/var/log/postgresql")

The directory where pg_ctl output will be written in a file named "pg_ctl.log". This file can be useful to debug PostgreSQL configuration errors for instance.

data-directory (predeterminado: "/var/lib/postgresql/data")

Directorio en el que se almacenan los datos.

extension-packages (predeterminado: '())

Las extensiones adicionales se cargan de paquetes enumerados en extension-packages. Las extensiones están disponibles en tiempo de ejecución. Por ejemplo, para crear una base de datos geográfica con la extensión postgis, una usuaria podría configurar el servicio postgresql-service como en este ejemplo:

(use-package-modules databases geo)

(operating-system
  ...
  ;; postgresql es necesario para ejecutar `psql' pero no se necesita
  ;; postgis para un funcionamiento correcto.
  (packages (cons* postgresql %base-packages))
  (services
    (cons*
      (service postgresql-service-type
               (postgresql-configuration
                (postgresql postgresql-10)
                (extension-packages (list postgis))))
      %base-services)))

Una vez hecho, la extensión estará visible y podrá inicializar una base de datos geográfica de este modo:

psql -U postgres
> create database pruebapostgis;
> \connect pruebapostgis;
> create extension postgis;
> create extension postgis_topology;

No es necesaria la adición de este campo para extensiones incluidas en la distribución oficial39 como hstore o dblink, puesto que ya pueden cargarse en postgresql. Este campo únicamente es necesario para extensiones proporcionadas por otros paquetes.

create-account? (default: #t)

Whether or not the postgres user and group should be created.

uid (predeterminado: #f)

Explicitly specify the UID of the postgres daemon account. You normally do not need to specify this, in which case a free UID will be automatically assigned.

One situation where this option might be useful is if the data-directory is located on a mounted network share.

gid (default: #f)

Explicitly specify the GID of the postgres group.

Tipo de datos: postgresql-config-file

Data type representing the PostgreSQL configuration file. As shown in the following example, this can be used to customize the configuration of PostgreSQL. Note that you can use any G-expression or filename in place of this record, if you already have a configuration file you’d like to use for example.

(service postgresql-service-type
         (postgresql-configuration
          (config-file
           (postgresql-config-file
            (log-destination "stderr")
            (hba-file
             (plain-file "pg_hba.conf"
                         "
local	all	all			trust
host	all	all	127.0.0.1/32 	md5
host	all	all	::1/128 	md5"))
            (extra-config
             '(("session_preload_libraries"     "auto_explain")
               ("random_page_cost"              2)
               ("auto_explain.log_min_duration" "100 ms")
               ("work_mem"                      "500 MB")
               ("logging_collector"             #t)
               ("log_directory"                 "/var/log/postgresql")))))))
log-destination (predeterminado: "syslog")

The logging method to use for PostgreSQL. Multiple values are accepted, separated by commas.

hba-file (predeterminado: %default-postgres-hba)

Nombre de archivo o expresión-G para la configuración de identificación basada en nombres de máquina.

ident-file (predeterminado: %default-postgres-ident)

Nombre de archivo o expresión-G para la configuración de asociación de nombres de usuaria.

socket-directory (default: "/var/run/postgresql")

Specifies the directory of the Unix-domain socket(s) on which PostgreSQL is to listen for connections from client applications. If set to "" PostgreSQL does not listen on any Unix-domain sockets, in which case only TCP/IP sockets can be used to connect to the server.

By default, the #false value means the PostgreSQL default value will be used, which is currently ‘/tmp’.

extra-config (predeterminada: '())

Claves y valores adicionales que se incluirán en el archivo de configuración de PostgreSQL. Cada entrada en la lista debe ser una lista cuyo primer elemento sea la clave y los elementos restantes son los valores.

The values can be numbers, booleans or strings and will be mapped to PostgreSQL parameters types Boolean, String, Numeric, Numeric with Unit and Enumerated described here.

Variable: postgresql-role-service-type

This service allows to create PostgreSQL roles and databases after PostgreSQL service start. Here is an example of its use.

(service postgresql-role-service-type
            (postgresql-role-configuration
             (roles
              (list (postgresql-role
                     (name "test")
                     (create-database? #t))))))

This service can be extended with extra roles, as in this example:

(service-extension postgresql-role-service-type
                   (const (postgresql-role
                           (name "alice")
                           (create-database? #t))))
Data Type: postgresql-role

PostgreSQL manages database access permissions using the concept of roles. A role can be thought of as either a database user, or a group of database users, depending on how the role is set up. Roles can own database objects (for example, tables) and can assign privileges on those objects to other roles to control who has access to which objects.

name

The role name.

permissions (default: '(createdb login))

The role permissions list. Supported permissions are bypassrls, createdb, createrole, login, replication and superuser.

create-database? (default: #f)

whether to create a database with the same name as the role.

encoding (default: "UTF8")

The character set to use for storing text in the database.

collation (default: "en_US.utf8")

The string sort order locale setting.

ctype (default: "en_US.utf8")

The character classification locale setting.

template (default: "template1")

The default template to copy the new database from when creating it. Use "template0" for a pristine database with no system-local modifications.

Data Type: postgresql-role-configuration

Data type representing the configuration of postgresql-role-service-type.

host (default: "/var/run/postgresql")

The PostgreSQL host to connect to.

log (default: "/var/log/postgresql_roles.log")

File name of the log file.

roles (default: '())

The initial PostgreSQL roles to create.

MariaDB/MySQL

Variable: mysql-service-type

This is the service type for a MySQL or MariaDB database server. Its value is a mysql-configuration object that specifies which package to use, as well as various settings for the mysqld daemon.

Tipo de datos: mysql-configuration

Data type representing the configuration of mysql-service-type.

mysql (predeterminado: mariadb)

Objeto de paquete del servidor de bases de datos MySQL, puede ser tanto mariadb como mysql.

Para MySQL, se mostrará una contraseña de root temporal durante el tiempo de activación. Para MariaDB, la contraseña de root está vacía.

bind-address (predeterminada: "127.0.0.1")

The IP on which to listen for network connections. Use "0.0.0.0" to bind to all available network interfaces.

port (predeterminado: 3306)

Puerto TCP en el que escucha el servidor de bases de datos a la espera de conexiones entrantes.

socket (default: "/run/mysqld/mysqld.sock")

Socket file to use for local (non-network) connections.

extra-content (predeterminado: "")

Additional settings for the my.cnf configuration file.

extra-environment (default: #~'())

List of environment variables passed to the mysqld process.

auto-upgrade? (default: #t)

Whether to automatically run mysql_upgrade after starting the service. This is necessary to upgrade the system schema after “major” updates (such as switching from MariaDB 10.4 to 10.5), but can be disabled if you would rather do that manually.

Memcached

Variable: memcached-service-type

Este es el tipo de servicio para el servicio Memcached, que proporciona caché distribuida en memoria. El valor para este tipo de servicio es un objeto memcached-configuration.

(service memcached-service-type)
Tipo de datos: memcached-configuration

Tipo de datos que representa la configuración de memcached.

memcached (predeterminado: memcached)

El paquete de Memcached usado.

interfaces (predeterminadas: '("0.0.0.0"))

Interfaces de red por las que se esperan conexiones.

tcp-port (predeterminado: 11211)

Port on which to accept connections.

udp-port (predeterminado: 11211)

Puerto en el que se deben aceptar conexiones UDP, el valor 0 desactiva la escucha en un socket UDP.

additional-options (predeterminadas: '())

Opciones de línea de órdenes adicionales que se le proporcionarán a memcached.

Redis

Variable: redis-service-type

Es el tipo de servicio para el almacén de clave/valor Redis, cuyo valor es un objeto redis-configuration.

Tipo de datos: redis-configuration

Tipo de datos que representa la configuración de redis.

redis (predeterminado: redis)

El paquete Redis usado.

bind (predeterminada: "127.0.0.1")

La interfaz de red en la que se escucha.

port (predeterminado: 6379)

Puerto en el que se aceptan conexiones, el valor 0 desactiva la escucha en un socket TCP.

working-directory (predeterminado: "/var/lib/redis")

Directorio en el que se almacena los archivos de base de datos y relacionados.


Footnotes

(39)

NdT: “contrib” de “contributed” en inglés, “contribuciones” podría entenderse en castellano.


Next: Servicios de correo, Previous: File Search Services, Up: Servicios   [Contents][Index]