Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The following table lists several common Vagrant commands. For more information, see Vagrant Command-Line Interface documentation.

ssh
CommandDescription
Create or rebuild a VM
vagrant up <vm-name>

Create and configure guest machines. Example: vagrant up c6406

Starts a specific VM. (up.sh is a wrapper for this call. ) You can use this command to start more VMs after you called up.sh.Example: vagrant up c6406

Note: if you do not specify the <vm-name> parameter, it Vagrant will try attempt to start ten VMs.

Tear down a VM
vagrant status suspend [<vm-name>]Shows which VMs are running, suspended, etc.
vagrant destroy -f [<vm-name>]

Destroys all VMs launched from the current directory, and deletes them from disk.

Optional: Specify a specific VM to destroy.

vagrant suspend [<vm-name>]

Suspends (snapshot) all VMs launched from the current directory so that you can resume them later

Optional: Specify a specific VM to suspend.

Save the current running state of a VM and stop the VM. A suspend effectively saves the exact point-in-time state of a machine. When you issue a resume command, the VM begins running immediately from that point, rather than doing a full boot.

When you are ready to begin working with it again, run vagrant up. The machine will resume where you left off. The main benefit of suspend is that it is very fast; it usually takes only 5 to 10 seconds to stop and start your work. The downside is that the operation uses disk space for the VM and to store all VM state information (in RAM, when running) on disk.

vagrant resume [<vm-name>]

Resumes all suspended VMs launched from the current directory

Optional: Specify a specific VM to resumesuspend.

vagrant halt <vm-name>

Starts a SSH session to the host.

Example: vagrant ssh c6401

vagrant --helpList information about Vagrant commands.

Taking Snapshots

A Vagrant snapshot saves the current state of a VM so that you can restart the VM from the same point at a future time. Vagrant makes it easy to take snapshots of the entire cluster. (Note: the following plugin overrides the default snapshot command in Vagrant.)

Install the snapshot plugin:

Code Block
vagrant plugin install vagrant-vbox-snapshot --plugin-version=0.0.2

...

Gracefully shut down the guest operating system and power down the VM. When you are ready to begin working with it again, use vagrant up. The main benefit of halt is that it cleanly shuts down your machine, preserves disk contents, and allows VMs to be cleanly started again. The downside is that it takes some time to restart the VM, and the guest machine still consumes disk space.
vagrant destroy -f [<vm-name>]

Remove all traces of the guest machine from your system. The destroy command stops the guest machine, powers it down, and removes all guest hard disks. When you are ready to begin working with it again, run vagrant up. The benefit of this all disk space and RAM consumed by the guest machine are reclaimed; your host machine is left clean. The downside is that the vagrant up operation will take extra time; rebuilding the environment takes the longest (compared with suspend and halt) because it re-imports and re-provisions the machine.

Optional: Specify a specific VM to destroy.

Connect to a VM
vagrant ssh <vm-name>

Starts a SSH session to the host.

Example: vagrant ssh c6401

Additional commands
vagrant status [<vm-name>]Shows which VMs are running, suspended, and so on.
vagrant snapshot

A Vagrant snapshot saves the current state of a VM so that you can restart the VM from the same point at a future time. Commands include push, pop, save, restore, list, and delete. For more information, see https://www.vagrantup.com/docs/cli/snapshot.html

...

.

Note: Upon resuming a snapshot, you may find that time-sensitive services such as the (HBase RegionServer) may be down. If this happens, you will

...

need to restart those services.

vagrant --helpList information about Vagrant commands.

Recommendation: After you start the VMs--but before you run anything on the VMs--run vagrant snapshot take initVMs–save a snapshot.  This allows you to go back to restore the initial state of the VMs by running vagrant snapshot go init. This restores your initial state much more quickly your VMs. This process is much faster than starting the VMs from scratch and then reinstalling Ambari and HDP. You can return to the initial state without destroying other named snapshots that you create later.

More information: https://www.vagrantup.com/docs/getting-started/teardown.html