1
0
Fork 0

Merge pull request #41 from oscillatingworks/vagrant

Introduce vagrant env
master
Philip O'Toole 10 years ago
commit cf4e9a3f8c

4
.gitignore vendored

@ -6,6 +6,10 @@
# Folders # Folders
_obj _obj
_test _test
.vagrant
# Logs
*.log
# Temporary vim files # Temporary vim files
*.swp *.swp

@ -21,6 +21,22 @@ This starts a rqlite server listening on localhost, port 4001. This single node
$GOPATH/bin/rqlite -h $GOPATH/bin/rqlite -h
Alternatively you can use [Vagrant](https://www.vagrantup.com/) environment. To do so, simply [install Vagrant](https://docs.vagrantup.com/v2/installation/index.html) on your machine and execute being inside rqlite repository:
~~~bash
$ CLUSTER_SIZE=7 vagrant up rqlite
~~~
This will start Vagrant box and install rqlite with all required dependencies. After this is done, there will be formed a cluster with number of nodes specifed by `CLUSTER_SIZE` variable.
To execute queries against started cluster you can either ssh directly to the Vagrant box via `vagrant ssh rqlite` or execute them from you local box accessing cluster at `192.168.200.10` IP and any port within a range `[4001, 4001 + CLUSTER_SIZE -1]`.
To terminate Vagrant box simply execute:
~~~bash
$ vagrant destroy rqlite
~~~
### Forming a Cluster ### Forming a Cluster
While not strictly necessary to run rqlite, running multiple nodes means the SQLite database is replicated. While not strictly necessary to run rqlite, running multiple nodes means the SQLite database is replicated.

28
Vagrantfile vendored

@ -0,0 +1,28 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.define "rqlite" do |rqlite|
config.vm.network "private_network", ip: "192.168.200.10"
config.vm.provision :shell, :path => "setup.sh"
config.vm.provision :shell, :inline => "rqlite -logfile /vagrant/rqlite1.log ~/node.1 &"
if not ENV['CLUSTER_SIZE'].nil?
port = 4001
(2..ENV['CLUSTER_SIZE'].to_i).each do |i|
port = port + 1
config.vm.provision :shell, :inline => "rqlite -join localhost:4001 -p #{port} -logfile /vagrant/rqlite#{i}.log ~/node.#{i} &"
end
end
end
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
end

@ -0,0 +1,20 @@
#!/bin/bash
# Dependencies
add-apt-repository ppa:git-core/ppa -y
echo "Updating..."
apt-get update
apt-get install -y curl git bison make mercurial sqlite3
# Golang
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
source ~/.gvm/scripts/gvm
gvm install go1.4
gvm use go1.4
# Rqlite
mkdir -p rqlite
cd rqlite
export GOPATH=$PWD
go get github.com/otoolep/rqlite
ln -s $GOPATH/bin/rqlite /usr/local/bin/rqlite
Loading…
Cancel
Save