After configuring my new shiny MacBook I started to think about how to establish a Datastax Enterprise Environment on my Notebook. First I wanted to have it cost free and secondly automated, what took me to Vagrant and Virtualbox. I checked different repositories but they always used a config management like chef, puppet or ansible what´s great for production or a datacenter. I decided to use new bash scripts in a Vagrantfile and to copy the cassandra.yaml and hosts file to have the ability to edit them offline.

So I installed Vagrant and added a new Ubuntu box to the repository. Then I configured a new clustered definition like this:

VAGRANTFILE_API_VERSION = “2”
boxes = [
  { :name => ‘dse-node0’, :ip => ‘192.168.50.100’, :cpus =>2, :memory => 4096 },
  { :name => ‘dse-node1’, :ip => ‘192.168.50.101’, :cpus =>2, :memory => 4096 },
  { :name => ‘dse-node2’, :ip => ‘192.168.50.102’, :cpus =>2, :memory => 4096 }
]
Vagrant.configure(“2”) do |config|
  config.ssh.shell = “bash -c ‘BASH_ENV=/etc/profile exec bash'”
  boxes.each do |val|
    config.vm.define val[:name] do |config|
      config.vm.box = “Ubuntu”
      config.vm.provider :virtualbox do |v|
        v.customize [“modifyvm”, :id, “–memory”, val[:memory]]
        v.customize [“modifyvm”, :id, “–cpus”, val[:cpus] ]
      config.vm.network :private_network, ip: val[:ip]
      config.vm.provision :shell, :inline => “cp -fv /vagrant/hosts /etc/hosts”
      if val[:name] == “dse-node0”
        config.vm.provision :shell, :path => “first.sh”
      else
        config.vm.provision :shell, :path => “nodes.sh”
        config.vm.provision :shell, :inline => “sed -i ‘s/listen_address:.*$/listen_address: #{val[:ip]}/’ /etc/dse/cassandra/cassandra.yaml”
      end
    end
  end
end
end

 

As you can see there is a first and a additional node (first node holds the Opscenter as well, only for testing purpose). In this example there are only three nodes but it is more than easy to add additional ones.

 

I added some scripts for the network interfaces, the pre-reqs and the services. The thing to notice is, that you have to add your own username and password in the external scripts which you can have for free.

The whole scripts can be found in my GitHub repository:

https://github.com/cjohannsen81/dse-vagrant

After the “vagrant up” run is completed you can just “Manage an existing cluster” in the OpsCenter (http://192.168.50.100:8888/opscentrer in my case).

Opscenter 5.0.0

Feel free to check it out and commit or comment 🙂