I have idea about what Vagrant is because a training used it providing a environment long time ago, but thinking how to play it now, the bad is that my memory is empty, now i try to recover those basic things, and step into a little bit with others.
Create and configure lightweight, reproducible, and portable development environments Written in Ruby, a computer software that creates and configures virtual development environments It can be seen as a higher-level wrapper around virtualization software such as
Linux Containers (LXC)
and around configuration management software such as
supports server environments like Amazon EC2 , Natively support Docker containers. Refer
for Dev, unify development environment for team
for Ops, standardize same server environment
1 2 3 4 5 6 7 8
$ vagrant init // initialize $ vagrant up // start vm $ vagrant halt // stop vm $ vagrant reload // restart vm $ vagrant ssh // access vm by ssh $ vagrant status // check vm status $ vagrant destroy // destory current vm $ vagrant package // package.box can be distributed
Step by Step
1 2 3 4 5 6 7 8 9 10 11 12
// create vagrantfile $ vagrant init // create a box image file on current directory // add vagrant image $ vagrant box add hashicorp/precise64 // download from vagrant cloud, Ubuntu OS // configure vagrantfile Vagrant.configure("2") do |config| config.vm.box = "hashicorp/precise64" end // launch vagrant $ vagrant up // access virtual machine by ssh $ vagrant ssh // directory sychronized ( /vagrant of VM <> current directory Vagrantfile located)
automatically install softwares required
create a Bash script(bootstrap.sh) at directory Vagrantfile located
for development stage, allow you to install all you need to develop your application in an easy and simple way a virtual machine manager, it allows you to script the virtual machine configuration as well as the provisioning. However, it is still a virtual machine depending on Virtual Box (or others) with a huge overhead. It requires you to have a hard drive file that can be huge, it takes a lot of ram, and performance can be not very good.
for production stage, a technology that allows you to run self-contained applications eliminating worries about dependencies and libraries uses kernel cgroup and namespacing via lxc. It means that you are using the same kernel as the host and the same file system. You can use Dockerfile with the docker build command in order to handle the provisioning and configuration of your container. You have example at docs.docker.com on how to make your Dockerfile, it is very intuitive.
The only reason you could want to use vagrant is if you need to do BSD, Windows or other non-linux development on your ubuntu box. Otherwise, go for Docker.
docker & vagrant complementing each other
Install a Vagrant virtual machine in your computer containing the same OS you will have in your server ( normally Ubuntu Linux 12.04 LTS 64 bits). This means that you can program in any OS you want and still expect your program will run in your server.
Install your Docker packages to create Docker containers inside your virtual machine created for Vagrant. This step is better if you can install them through an script.
Inside your containers put your applications ( Nginx, Memcached, MongoDB, etc)
Configure a shell script, Puppet or Chef script to install Docker and run your Docker containers each time Vagrant begins.
Test your containers in your Vagrant VM inside your computer.
Thanks to providers now you can take the same file ( your Vagrant file ) and just type vagrant up —provider=“provider” where the provider is your next host and Vagrant will take care of everything. For example, if you choose AWS then Vagrant will: Connect to your AMI in AWS, install the same OS you used in your computer, install Docker, launch your Docker containers and give you a ssh session.
Test your containers in AWS and look that they behave exactly as you expect.
something about, embedded documents atomicity and transaction $isolated operator
only transaction-like for multiple document multi-document transaction, rollback-like functionality, not really an all or nothing transaction
atomicity, rollback previous state
consistency, consistent state recovery intermediate data presentation
concurrency control : two approach, unique index, update if current
Update if current pattern
an approach to currency control for multiple clients operate the same data
variant : version pattern , similar to Update if current pattern to add an version field to document schema, application/client need increment the version field upon each update operation to a specific document. version field can be set 1 as default value for a document creation / insert operation.
it need ensure client application query data including the version field.
version can be implemented by “auto-incrementing sequence” field
SQL2Mongo : tool to migrate all schema and data from MSSQL to mongodb,