Skip to content

Instantly share code, notes, and snippets.

@chaudum
Last active July 17, 2018 13:24
Show Gist options
  • Save chaudum/c7f358aa70ee4bc31940e470dff5437b to your computer and use it in GitHub Desktop.
Save chaudum/c7f358aa70ee4bc31940e470dff5437b to your computer and use it in GitHub Desktop.
Multi Service CrateDB

Multi Service CrateDB

Prerequisites

  • SSD disk for CrateDB storage.
  • Add vm.max_map_count=262144 to /etc/sysctl.d/crate.conf and load it with sudo sysctl -p.

Download CrateDB tarball from CDN

You can use the released version from https://cdn.crate.io/downloads/releases/ or the latest nightly from https://cdn.crate.io/downloads/releases/nightly.

wget wget https://cdn.crate.io/downloads/releases/nightly/crate-3.1.0-201807170203-95f4290.tar.gz
tar -xzf crate-3.1.0-201807170203-95f4290.tar.gz

Symlink installation folder

ln -s crate-3.1.0-201807170203-95f4290 crate

Enable provided service file

  • Please change the user in the crate@.service file accordingly!
  • Please change the -Cpath.data setting to a folder on an SSD disk!
  • Add a file named sysconfig in the home directory of the user and set the heap size, e.g. CRATE_HEAP_SIZE=12g. This file will be read as environment for the unit.

Then run:

sudo systemctl link $(pwd)/crate@.service
sudo systemctl daemon-reload

Since the service file points to the same configuration path for each named unit you start, you can edit the crate.yml and it will affect all units. The only setting that is unique to the units is the node.name setting, which is set in the service file itself (%i ... the part after the @ when starting the servive). For the tests, this should be good enough, as all nodes are configured equally.

Start/Stop named CrateDB instance

sudo systemctl {start|stop|restart} crate@{c01,c02,c03}

On start, the service file creates the necessary folders for data and logs.

Inspect logs

sudo systemctl -u crate@{c01,c02,c03}
[Unit]
Description=CrateDB %i
After=network.target
[Service]
Type=simple
User=admin
Group=admin
EnvironmentFile=-/home/admin/sysconfig
ExecStartPre=/bin/mkdir -pv /home/admin/%i/log /home/admin/%i/data
ExecStart=/home/admin/crate/bin/crate \
-Cpath.home=/home/admin/crate \
-Cpath.conf=/home/admin/crate/config \
-Cpath.logs=/home/admin/%i/log \
-Cpath.data=/home/admin/%i/data \
-Cnode.name=%i
StandardOutput=journal
StandardError=journal
TimeoutStopSec=0
SuccessExitStatus=143 SIGTERM SIGKILL
LimitMEMLOCK=infinity
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment