ExFdbmonitor (ex_fdbmonitor v0.1.0)

View Source

ExFdbmonitor is an Elixir application that manages the starting and stopping of fdbmonitor, which is the management process for FoundationDB.

The goal of ExFdbmonitor is to allow a FoundationDB cluster to bootstrap itself using the distributed capabilities of the Erlang VM.

With a correctly crafted set of application environment variables, a cluster can be brought up from zero as long as each node is started individually.

Once the cluster is established, node restarts are equivalent to restarts of fdbmonitor itself.

Configuration of :ex_fdbmonitor

FDB executable paths

If your FoundationDB installation is not in the default location, then you must set the following environment variables. The paths shown here are the defaults.

config :ex_fdbmonitor,
       fdbcli: "/usr/local/bin/fdbcli",
       fdbserver: "/usr/local/libexec/fdbserver",
       fdbdr: "/usr/local/bin/fdbdr",
       backup_agent: "/usr/local/foundationdb/backup_agent/backup_agent",
       dr_agent: "/usr/local/bin/dr_agent"

FDB cluster configuration

The env vars :etc_dir and :run_dir are used on every boot.

database_path = "/var/lib/myapp/data/fdb"

config :ex_fdbmonitor,
  etc_dir: Path.join(database_path, "etc"),
  run_dir: Path.join(database_path, "run")

The :bootstrap env var is used only on first boot of each node in the cluster. Once a cluster is established, it is ignored on all subsequent boots. A simple example is shown here.

config :ex_fdbmonitor,
  bootstrap: [
    cluster: [
      coordinator_addr: "127.0.0.1"
    ],
    conf: [
      data_dir: Path.join(database_path, "data"),
      log_dir: Path.join(database_path, "log"),
      fdbservers: [
        [port: 5000]
      ]
    ],
    fdbcli: ~w[configure new single ssd-redwood-1]
  ]

Usage

See examples/example_app/README.md for a tutorial on using ExFdbmonitor in your application.

Summary

Functions

Opens a database connection.

Functions

open_db(input \\ nil)

Opens a database connection.

Arguments

  • :input: Ignored. It's here for compatibility with other libraries.

Examples

Use whenever you need to open the t:erlfdb.database/0:

db = ExFdbmonitor.open_db()
"world" = :erlfdb.get(db, "hello")

Use in conjuncation with Ecto.Adapters.FoundationDB:

config :my_app, MyApp.Repo,
  open_db: &ExFdbmonitor.open_db/1