In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The editor today takes you to understand the installation of vagrant, a tool for building the Linux development environment. The knowledge points in this article are introduced in great detail. Friends who think it is helpful can browse the content of the article with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Let's follow the editor to learn more about the installation of vagrant, a tool for building the Linux development environment.
Introduction to Vagrant: Vagrant is a Ruby-based tool for creating and deploying virtualized development environments. It uses Oracle's open source VirtualBox virtualization system and Chef to create an automated virtual environment.
To prepare to use Vagrant, you first need to install a virtual machine software. common virtual machine software includes virtualbox and VMware, but the latter is free and is not recommended. Virtualbox is preferred. The installation tools for virtulbox and Vagrant are not specific here, but note that after installation, for ease of use, you need to add vagrant to the "Path" environment variable.
Use Vagrant to add box first of all, the installation of the Linux system is essential to its system files, and this file is best downloaded locally from the Internet, you can choose to download from the box mirror source. For some reason, it is best to use the scientific method of surfing the Internet, otherwise it will not be able to download. Create a new "vagrant" folder under the E disk (according to your own situation), create a new "box" folder under its directory, and put the downloaded box file "centos.box" in the "box" folder.
Cd vagrant / / enter the vagrant folder vagrant box add-- name centos box\ centos.box / /-- name to specify the system name of box. 123will be used in the Vagrant configuration file and command will be used.
Vagrant box list 1 can view the box that has been added, as shown below
Configure Vagrantfile before the system starts, you need to configure it, use the command
Vagrant init centos 1 initializes "centos" and generates a Vagrantfile file in the "vagrant" directory, with the following contents
#-*-mode: ruby-*-# vi: set ft=ruby: # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure ("2") do | config | # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. Config.vm.box = "centos" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated. This is not recommended. # config.vm.box_check_update = false # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # config.vm.network "forwarded_port", guest: 80, host: 8080 # Create a private network, which allows host-only access to the machine # using a specific IP. # config.vm.network "private_network", ip: "192.168.33.10" # Create a public network, which generally matched to bridged network. # Bridged networks make the machine appear as another physical device on # your network. # config.vm.network "public_network" # Share an additional folder to the guest VM. The first argument is # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. # config.vm.synced_folder ".. / data", "/ vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # # config.vm.provider "virtualbox" do | vb | # # Display the VirtualBox GUI when booting the machine # vb.gui = true # Customize the amount of memory on the VM: # vb.memory = "1024" # end # # View the documentation for the provider you are using for more # information on available options # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies # such as FTP and Heroku are also available. See the documentation at # https://docs.vagrantup.com/v2/push/atlas.html for more information. # config.push.define "atlas" do | push | # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" # end # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. # config.vm.provision "shell", inline: you can see that for common configurations, this file is listed and explained. Here is a brief introduction to some configurations. Vagrant.configure ("2") do | config | # configuration start config.vm.box = "centos" # configuration of the system 'centos' # Network Settings # config.vm.network "forwarded_port", guest: 80, host: 8080 # here is port forwarding, host: 8080-> guest: 80 config.vm.network "public_network" # is configured as a public network, just like an actual physical computer IP addresses will be assigned by routers in the network # synchronize shared folders config.vm.synced_folder ". / data", "/ home/vagrant" # two folders are configured here, the first is a local folder The latter is the folder under the centos system # so you need to create a new "data" folder under the "vagrant" directory # display and memory settings config.vm.provider "virtualbox" do | vb | # specify the virtual machine software virtualbox vb.gui = false # whether to display gui vb.memory = "1024" # virtual machine memory settings end end # end of configuration 1234567891011121314151617181920 or above is the configuration of a single virtual machine Use the command vagrant up 1 to start the virtual machine. As shown in the figure, Vagrantfile can be configured to start multiple virtual machines with the following structure: Vagrant.configure ("2") do | config | # virtual machine centos config.vm.define: centos do | centos | centos.vm.box= "centos" centos.vm.network "public_network" end # virtual machine ubuntu config.vm.define: ubuntu do | ubuntu | ubuntu.vm.box= "ubuntu" end end 1234567891011 You can specify a virtual machine boot, for example, vagrant up centos 1 can only boot the centos system, if not specified, it will start all the virtual machines. For more configuration options, you can refer to the Chinese documentation for more configuration learning. Log in to the system after entering the command vagrant ssh 1 and enter the password, as shown in the figure default system username and password user: vagrant passwd: vagrant / / administrator password is also this 12 use the command ip addr 1 to obtain the IP address of the virtual machine, as shown in the figure, the address of the virtual machine in the local area network is "192.168.199.215", using this address We can also log in from other computers in the local area network, as shown in the figure, it is even easier for file sharing. Before we configured config.vm.synced_folder ". / data" and "/ home/vagrant" 1, after logging in, we tested cd ~ pwd touch guset.txt 123. as shown in the local directory, we can see that we can choose our favorite editor to edit the file under the Windows system. And can be quickly deployed to the Linux system. System packaging if you want to share your configured Linux system, you need to package the system. You need to turn off the virtual machine before packaging, and use the command vagrant halt 1 to shut down the virtual machine. Use the command vagrant package 1 to package the system, as shown in the picture in the "vagrant" directory with a .box file, as shown above is the content related to the Linux system shared by Liangxu tutorial Network for all friends. If you want to know more about Linux, remember to follow the official account "good Linux", or scan the QR code below to follow, more practical information is waiting for you! What are the versions of Linux? the versions of Linux are Deepin, UbuntuKylin, Manjaro, LinuxMint, Ubuntu and so on. Among them, Deepin is one of the best-developed Linux distributions in China; UbuntuKylin is a derivative release based on Ubuntu; Manjaro is a Linux release based on Arch; LinuxMint's default Cinnamon desktop is similar to Windows XP's easy-to-use; Ubuntu is the Linux operating system based on desktop applications.
Thank you for your reading. This is the whole content of "how is the installation of vagrant, a tool for building Linux development environment?". Friends who learn to learn to do it quickly. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.