Software

etcd for ubuntu

A highly-available key value store for shared configuration and service discovery.
I'll show you how to install this on Ubuntu Server 14.04.

Install Dependencies

sudo apt-get install ruby-dev gcc make
sudo gem install fpm

curl -L https://raw.githubusercontent.com/solarkennedy/etcd-packages/master/Makefile  > Makefile

Edit Makefile and replace "VERSION=0.4.3" with later version. (0.4.6 at the time of writing).
Once you've done that, you can build the deb package.

make deb

If all goes to plan you will end up with a file called "etcd_0.4.6_amd64.deb".

I've have been using puppet to install etcd and setup the init scripts, as etcd doesn't come with them by default.
If this the route you want to go down, then you'll need the puppet-etcd module.

node default {
  exec { '/usr/bin/dpkg -i /root/etcd-0.4.6.deb.deb':
    before           => Class['::etcd'],
  }
  
  class { '::etcd':
    discovery               => true,
    # generate a new token for each unique cluster from https://discovery.etcd.io/new
    # if you are following my cluster guide, then use the token you created for you cluster here
    discovery_token         => "",
    peer_election_timeout   => 500,
    peer_heartbeat_interval => 100,
    addr                    => "${::ipaddress_eth0}:4001",
    bind_addr               => "",
    peer_addr               => "${::ipaddress_eth0}:7001",
    peer_bind_addr          => "",
    snapshot                => true,
    verbose                 => false,
    very_verbose            => false,
  }
}

Or we can try to install the package manually.

sudo dpkg -i etcd_0.4.6_amd64.deb
mkdir /var/lib/etcd /etc/etcd

Next we need to create a config file

nano /etc/etcd/etcd.conf

discovery          = "https://discovery.etcd.io/"
name               = ""
addr               = "0.0.0.0:4001"
bind_addr          = ""
ca_file            = ""
cert_file          = ""
cpu_profile_file   = ""
data_dir           = "/var/lib/etcd"
key_file           = ""
max_result_buffer  = 1024
max_retry_attempts = 3
snapshot           = true
snapshot-count     = 10000
verbose            = false
very_verbose       = false

[peer]
addr               = "0.0.0.0:7001"
bind_addr          = ""
ca_file            = ""
cert_file          = ""
key_file           = ""
election_timeout   = 500
heartbeat_interval = 100

Now all you need to do is add etcd to start at boot.
Edit /etc/rc.local and type 'etcd&' the line above 'exit 0'.

After you reboot etcd should be running.
You can confirm by typing 'etcdctl ls'.

Tags: etcd, ubuntu

comments powered by Disqus