• Vagrant 的熟悉和使用


    简介:由于工作期间忘性大,隔断时间常常忘记当初的情景和解决方案,归结原因是没有记录和记笔记的习惯,从今天开始希望 好好记笔记&总结

    一方面可以提升自己的总结能力,另一方面可以方便以后查看,提高工作效率

    前沿:

    vagrant 需要和virtualbox 搭配使用,可查询virtualbox官网 下载版本即可,如果觉得太慢,可以私信我~我virtualbox版本是最新的

    一、我的Vagrant版本:

    [D:HashiCorpVagrantin]$ vagrant.exe --version
    Vagrant 2.2.4

    二、添加一个Box

    我这里是添加本机的一个下载好的box

    [D:HashiCorpVagrantin]$ vagrant.exe box add Ubuntu D:BaiduNetdiskDownloadxenial-server-cloudimg-amd64-vagrant(1).box
    ==> box: Box file was not detected as metadata. Adding it directly...
    ==> box: Adding box 'Ubuntu' (v0) for provider:
    box:
    The box you're attempting to add already exists. Remove it before
    adding it again or add it with the `--force` flag.

    Name: Ubuntu
    Provider: virtualbox
    Version: 0

    三、查看一下当前的Box 列表

    【D:HashiCorpVagrantin】这里是安装路径

    【D:ApplicationsVagrant】这里为了不混淆 我重新起了一个路径

    [D:ApplicationsVagrant]$ Vagrant box list
    ubuntu (virtualbox, 0)

    四、启动命令

    [D:ApplicationsVagrant]$ Vagrant up
    ==> default: Matching MAC address for NAT networking...==> default: Setting the name of the VM: Vagrant_default_1555125507464_27514==> 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: Running 'pre-boot' VM customizations...==> default: Booting VM...==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222
    default: SSH username: ubuntu
    default: SSH auth method: password
    default: Warning: Connection reset. Retrying... default: Warning: Connection aborted. Retrying... default: Warning: Remote connection disconnect. Retrying... default: Warning: Connection reset. Retrying... 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: 5.0.40
    default: VirtualBox Version: 6.0
    ==> default: Mounting shared folders...
    default: /vagrant => D:/Applications/Vagrant

    五、登陆vm

    不要用xshell 使用该命令,虽然我不知道有什么限制,但是就是无法运行该命令

    我直接开启window DOS 命令: vagrant ssh

    六、查看状态 vagrant status

    七、关闭vm vagrant halt

    八、销毁 vagrant destory Ubuntu

    其他、

    关于vagrantfile 其中的一些配置可以搜索一下相关的文件,这里就不多阐述了

    vagrantFile 扩容

    在配置文件中加入该命令

    config.disksize.size = '25GB' 

    重新reload 发现报错,需要添加一个配置插件,添加成功后,重新启动虚拟机,磁盘扩容

     

    最后,参考文章的链接:https://www.jianshu.com/p/b7d599403aa6

  • 相关阅读:
    如何根据关键字匹配度排序
    LeetCode 题解目录
    Spring Boot、Cloucd 学习示例
    JavaScript工具库
    使用 Docker 部署 Spring Boot 项目
    LeetCode 寻找两个有序数组的中位数
    Bean 生命周期
    Dubbo支持的协议
    MySQL组成模块
    Spring Boot 搭建TCP Server
  • 原文地址:https://www.cnblogs.com/santachi/p/10700460.html
Copyright © 2020-2023  润新知