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


8.8.9 Database Services

The (gnu services databases) module provides the following services.

Scheme Procedure: postgresql-service [#:postgresql postgresql] [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] [#:port 5432] [#:locale ``en_US.utf8''] [#:extension-packages '()]

Return a service that runs postgresql, the PostgreSQL database server.

The PostgreSQL daemon loads its runtime configuration from config-file, creates a database cluster with locale as the default locale, stored in data-directory. It then listens on port.

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*
      (postgresql-service #: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.

Scheme Procedure: mysql-service [#:config (mysql-configuration)]

Return a service that runs mysqld, the MySQL or MariaDB database server.

The optional config argument specifies the configuration for mysqld, which should be a <mysql-configuration> object.

Data Type: mysql-configuration

Data type representing the configuration of mysql-service.

mysql (default: mariadb)

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.

port (default: 3306)

TCP port on which the database server listens for incoming connections.

Scheme Variable: memcached-service-type

This is the service type for the Memcached service, which provides a distributed in memory cache. The value for the service type is a memcached-configuration object.

(service memcached-service-type)
Data Type: memcached-configuration

Data type representing the configuration of memcached.

memcached (default: memcached)

The Memcached package to use.

interfaces (default: '("0.0.0.0"))

Network interfaces on which to listen.

tcp-port (default: 11211)

Port on which to accept connections on,

udp-port (default: 11211)

Port on which to accept UDP connections on, a value of 0 will disable listening on a UDP socket.

additional-options (default: '())

Additional command line options to pass to memcached.

Scheme Variable: mongodb-service-type

This is the service type for MongoDB. The value for the service type is a mongodb-configuration object.

(service mongodb-service-type)
Data Type: mongodb-configuration

Data type representing the configuration of mongodb.

mongodb (default: mongodb)

The MongoDB package to use.

config-file (default: %default-mongodb-configuration-file)

The configuration file for MongoDB.

data-directory (default: "/var/lib/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.

Scheme Variable: redis-service-type

This is the service type for the Redis key/value store, whose value is a redis-configuration object.

Data Type: redis-configuration

Data type representing the configuration of redis.

redis (default: redis)

The Redis package to use.

bind (default: "127.0.0.1")

Network interface on which to listen.

port (default: 6379)

Port on which to accept connections on, a value of 0 will disable listening on a TCP socket.

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

Directory in which to store the database and related files.


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