Skip to content

Instantly share code, notes, and snippets.

@explodingcamera
Created January 17, 2020 16:56
Show Gist options
  • Save explodingcamera/442f25df0a48840476ec6162a4cba25a to your computer and use it in GitHub Desktop.
Save explodingcamera/442f25df0a48840476ec6162a4cba25a to your computer and use it in GitHub Desktop.
Deploy CockroachDB
[Unit]
Description=Cockroach Database cluster node
Requires=network.target
[Service]
Type=notify
WorkingDirectory=/var/lib/cockroach
ExecStart=/usr/local/bin/cockroach start --certs-dir=certs --advertise-addr=<node1 address> --join=<node1 address>,<node2 address>,<node3 address> --cache=.25 --max-sql-memory=.25
TimeoutStopSec=60
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cockroach
User=cockroach
[Install]
WantedBy=default.target
#!/usr/bin/env bash
## ONLY FOR DEBIAN
## BEFORE RUNNING, have a dir called CERTS with
## certs/ca.crt, certs/client.root.crt, certs/client.root.key in the current directory!
## AND Create /etc/systemd/system/cockroachdb.service using the template below!
# SYNC CLOCK TO GOOGLE
sudo timedatectl set-ntp no
sudo apt-get install ntp
sudo service ntp stop
sudo ntpd -b time.google.com
sed -i "s/0.debian.pool.ntp.org/time1.google.com/g" /etc/ntp.conf
sed -i "s/1.debian.pool.ntp.org/time2.google.com/g" /etc/ntp.conf
sed -i "s/2.debian.pool.ntp.org/time3.google.com/g" /etc/ntp.conf
sed -i "s/3.debian.pool.ntp.org/time4.google.com/g" /etc/ntp.conf
sudo service ntp start
# INSTALL COCKROACHDB
wget -qO- https://binaries.cockroachdb.com/cockroach-v19.2.2.linux-amd64.tgz | tar xvz
mv -i cockroach-v19.2.2.linux-amd64/cockroach /usr/local/bin/
rm -rf cockroach-v19.2.2.linux-amd64
mkdir /var/lib/cockroach
useradd cockroach
mv certs /var/lib/cockroach/
chown -R cockroach.cockroach /var/lib/cockroach
systemctl enable cockroachdb
systemctl start cockroachdb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment