...
The following table lists several common Vagrant commands. For more information, see Vagrant Command-Line Interface documentation.
Command | Description | |
---|---|---|
Create or rebuild a VM | ||
vagrant up <vm-name> | Create and configure guest machines. Example: Starts a specific VM. ( Note: if you do not specify the | |
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 When you are ready to begin working with it again, run | vagrant resume [<vm-name>] | Resumes all suspended VMs launched from the current directory Optional: Specify a specific VM to resumesuspend. |
vagrant | sshhalt <vm-name> | Starts a SSH session to the host. Example: |
vagrant --help | List 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 Optional: Specify a specific VM to destroy. |
Connect to a VM | |
vagrant ssh <vm-name> | Starts a SSH session to the host. Example: |
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 --help | List information about Vagrant commands. |
Recommendation: After you start the VMs--but before you run anything on the VMs--run vagrant snapshot take init
VMs–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