ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

vargrant初使用

2021-09-26 16:31:28  阅读:404  来源: 互联网

标签:box ... cetnos65 default vargrant vagrant 使用 virtualbox


使用简单,不用自己安装虚拟机,有现成的镜像,只需下载安装vagrant后直接调用就可以了

我使用的是virtualbox的镜像

1、下载安装vagrant

下载地址 :https://www.vagrantup.com/downloads

选择适合自己电脑的版本下载,安装时下一步下一步就可以了

 

 2、下载virtualbox和virtualbox镜像

virtuabox下载地址:https://www.virtualbox.org/wiki/Downloads   安装时点击下一步即可

镜像下载地址: http://www.vagrantbox.es/

我下载的为:centos65-x86_64-20140116.box

3、下载之后开始加载

1)cmd下找到镜像所在的位置

D:\xu\cetnos65>dir
2021/09/13  10:37       293,676,266 centos65-x86_64-20140116.box

2)安装虚拟机

D:\xu\cetnos65>vagrant box add new_box centos65-x86_64-20140116.box

==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'new_box' (v0) for provider:
    box: Unpacking necessary files from: file://D:/xu/cetnos65/centos65-x86_64-20140116.box
    box:
The box you're attempting to add already exists. Remove it before
adding it again or add it with the `--force` flag.
Name: new_box
Provider: virtualbox
Version: 0

3)注册虚拟机

D:\xu\cetnos65>vagrant init box_name

`Vagrantfile` already exists in this directory. Remove it before
running `vagrant init`.

4)启动虚拟机

D:\xu\cetnos65>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'new_box'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: cetnos65_default_1632642565053_83625
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

  https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

  VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

  config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222            虚拟机的ip地址和端口号
    default: SSH username: vagrant                    用户名和密码均为vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.3.6
    default: VirtualBox Version: 6.1
==> default: Mounting shared folders...
    default: /vagrant => D:/xu/cetnos65

4、打开virtualbox进行查看,已经在运行

 

5、远程软件进行连接

 

 

问题:

加载时遇到了一个问题:

报错kernel_require.rb:83:in `require'

 

 原因是我安装vagrant时,安装目录采用了中文的原因,将安装目录变更为英文后,记得变更环境变量,否则会报错找不到命令vagrant

标签:box,...,cetnos65,default,vargrant,vagrant,使用,virtualbox
来源: https://www.cnblogs.com/wangqianqiannb/p/15338633.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有