Multimachine infrastructure: how would you share data among nodes?

36 views
Skip to first unread message

Bjorn W

unread,
Dec 8, 2015, 5:54:06 AM12/8/15
to Vagrant
Hi,
I'm using Vagrant to model a production environment with 5 machines:

- 1 database server
- 1 storage server
- 2 webservers
- 1 loadbalancer.

So far most of it works as theorized except for storage.

My initial idea was to sync shared folders from my host laptop via Vagrant to the storage server VM and run a NFS server re-sharing the shared Vagrant folders the (guest) from storage server to, in this case, the webservers. However sharing synced (tried both default as well as NFS) Vagrant folders using this approach does not work: the storage server mounts the shared Vagrant folder and allows access to it. I can see a mount and I'm able to write something to it (on the webserver machine and see the result on the storage server as well). However existing folders on the storage server seem empty when I view them from the webserver machine. Any clues on what is causing this? Also I'm interested in how you would model a production environment like I described and in particular how would you share data (between the guest VM's as well as between the host and the guest VM's). 

ps: For now I'm going to test a workaround: Using Vagrant shared folders as the storage machine instead. So basically I mount the shared folders on the webserver VM's directly instead of via a storage server.
 

Alvaro Miranda Aguilera

unread,
Dec 9, 2015, 12:44:10 AM12/9/15
to vagra...@googlegroups.com
How is done in production today?

You can easily add a 2nd disk to the storage server, and then use it
for anything you like.

Sample Vagrant file with 1 extra disk

vm_name="db12102"
size_file_to_dbdisk = 50

Vagrant.configure(2) do |config|
config.vm.box = "alvaro/oracle6-preinstall"
config.vm.hostname = "#{vm_name}.kikitux.net"
config.vm.network :private_network, ip: "192.168.78.3"
config.vm.provider :virtualbox do |vb|
vb.name = vm_name
vb.customize ["modifyvm", :id, "--memory", 5555]
vb.customize ["modifyvm", :id, "--cpus", 4]
port=2
["1"].each do |disk|
file_to_dbdisk = "Y:/VirtualBox/#{vm_name}/#{vm_name}-disk#{disk}.vdi"
if !File.exist?(file_to_dbdisk)
vb.customize ['createhd', '--filename', file_to_dbdisk,
'--size', (size_file_to_dbdisk * 1024).floor ]
end
vb.customize ['storageattach', :id, '--storagectl', 'SATA
Controller', '--port', port, '--device', 0, '--type', 'hdd',
'--medium', file_to_dbdisk]
port=port+1
end
end
config.vm.provision "shell", path: "scripts/sdb.sh"

end



Sample script that won't delete if there is anything in the disk

#!/bin/bash

blkid /dev/sdb*
if [ $? -ne 0 ]; then
mkfs.ext4 -F /dev/sdb
blkid /dev/sdb 2>&1>/dev/null && echo $(blkid /dev/sdb -o export |
head -n1) /u01/stage ext4 defaults 0 0 >> /etc/fstab
mkdir -p /u01/stage
mount /u01/stage
else
echo "filesystem metadata found on sdb, ignoring"
fi



Alvaro
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vagrant-up/a3fc17d8-ab23-408c-a159-6bb48a90d264%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

pixel fairy

unread,
Dec 30, 2015, 2:48:56 AM12/30/15
to Vagrant
can you show us?

ive done similar things, but usually use ansibles synchronize module or just work from /vagrant

BjornW

unread,
Jan 1, 2016, 5:47:33 PM1/1/16
to vagra...@googlegroups.com
Hi,

My solution ended up using mounted directories from Vagrant and sharing
uploaded files via the NFS server.

grtz
BjornW
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this
> mailing list.
>
> GitHub Issues: https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "Vagrant" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vagrant-up/H2xqIBMEoOQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> vagrant-up+...@googlegroups.com
> <mailto:vagrant-up+...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vagrant-up/f3c3e019-8527-47e4-ae5a-50488c1661d6%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/f3c3e019-8527-47e4-ae5a-50488c1661d6%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

met vriendelijke groet,
Bjorn Wijers

* b u r o b j o r n .nl *
digitaal vakmanschap | digital craftsmanship

Postbus 14145
3508 SE Utrecht
The Netherlands

tel: +31 6 49 74 78 70
http://www.burobjorn.nl
Reply all
Reply to author
Forward
0 new messages