(gnu services databases) module provides the following services.
The following example describes a PostgreSQL service with the default configuration.
If the services fails to start, it may be due to an incompatible cluster already present in data-directory. Adjust it (or, if you don’t need the cluster anymore, delete data-directory), then restart the service.
Peer authentication is used by default and the
account has no shell, which prevents the direct execution of
commands as this user. To use
psql, you can temporarily log in
postgres using a shell, create a PostgreSQL superuser with the
same name as one of the system users and then create the associated
sudo -u postgres -s /bin/sh createuser --interactive createdb $MY_USER_LOGIN # Replace appropriately.
Data type representing the configuration for the
PostgreSQL package to use for the service.
Port on which PostgreSQL should listen.
Locale to use as the default when creating the database cluster.
The configuration file to use when running PostgreSQL. The default behaviour uses the postgresql-config-file record with the default values for the fields.
Directory in which to store the data.
Additional extensions are loaded from packages listed in
extension-packages. Extensions are available at runtime. For instance,
to create a geographic database using the
postgis extension, a user can
configure the postgresql-service as in this example:
(use-package-modules databases geo) (operating-system ... ;; postgresql is required to run `psql' but postgis is not required for ;; proper operation. (packages (cons* postgresql %base-packages)) (services (cons* (service postgresql-service-type (postgresql-configuration (postgresql postgresql-10) (extension-packages (list postgis)))) %base-services)))
Then the extension becomes visible and you can initialise an empty geographic database in this way:
psql -U postgres > create database postgistest; > \connect postgistest; > create extension postgis; > create extension postgis_topology;
There is no need to add this field for contrib extensions such as hstore or dblink as they are already loadable by postgresql. This field is only required to add extensions provided by other packages.
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" "'100ms'") ("work_mem" "'500MB'") ("logging_collector" "on") ("log_directory" "'/var/log/postgresql'")))))))
The logging method to use for PostgreSQL. Multiple values are accepted, separated by commas.
Filename or G-expression for the host-based authentication configuration.
Filename or G-expression for the user name mapping configuration.
List of additional keys and values to include in the PostgreSQL config file. Each entry in the list should be a list where the first element is the key, and the remaining elements are the values.
Return a service that runs
mysqld, the MySQL or MariaDB
The optional config argument specifies the configuration for
mysqld, which should be a
Data type representing the configuration of mysql-service.
Package object of the MySQL database server, can be either mariadb or mysql.
For MySQL, a temporary root password will be displayed at activation time. For MariaDB, the root password is empty.
TCP port on which the database server listens for incoming connections.
This is the service type for the Memcached service, which provides a distributed in memory cache. The
value for the service type is a
Data type representing the configuration of memcached.
The Memcached package to use.
Network interfaces on which to listen.
Port on which to accept connections on,
Port on which to accept UDP connections on, a value of 0 will disable listening on a UDP socket.
Additional command line options to pass to
This is the service type for MongoDB.
The value for the service type is a
Data type representing the configuration of mongodb.
The MongoDB package to use.
The configuration file for MongoDB.
This value is used to create the directory, so that it exists and is owned by the mongodb user. It should match the data-directory which MongoDB is configured to use through the configuration file.
This is the service type for the Redis
key/value store, whose value is a
Data type representing the configuration of redis.
The Redis package to use.
Network interface on which to listen.
Port on which to accept connections on, a value of 0 will disable listening on a TCP socket.
Directory in which to store the database and related files.