谈谈Vagrant中的那些坑:CentOS

Posted 昭阳柯

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了谈谈Vagrant中的那些坑:CentOS相关的知识,希望对你有一定的参考价值。

安装了vagrant之后,当然需要将它投入使用。由于计划中的生产环境是 CentOS 7,因此想搭建一个 基于CentOS 7(x86_64)的虚拟开发环境。

最开始的一系列工作,比如在vbox中安装CentOS 7、打包box文件、将box导入vagrant等都不在此一一细述,后面将有专文总结这些过程。

然后坑来了:修改Vagrantfile配置文件欲实现 public_network:

config.vm.network "public_network", ip: "192.168.0.6"

然后 vagrant up 启动虚拟机:

$ vagrant up
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> 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
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/server_version.rb:54:in `readpartial‘: An established connection was aborted by the software in your host machine. (Errno::ECONNABORTED)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/server_version.rb:54:in `block (2 levels) in negotiate!‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/server_version.rb:52:in `loop‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/server_version.rb:52:in `block in negotiate!‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/server_version.rb:50:in `loop‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/server_version.rb:50:in `negotiate!‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/server_version.rb:32:in `initialize‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/session.rb:84:in `new‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh/transport/session.rb:84:in `initialize‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh.rb:233:in `new‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/net-ssh-4.1.0/lib/net/ssh.rb:233:in `start‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.4/plugins/communicators/ssh/communicator.rb:397:in `block (2 levels) in connect‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:88:in `block in timeout‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `block in catch‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:103:in `timeout‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.4/plugins/communicators/ssh/communicator.rb:371:in `block in connect‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.4/lib/vagrant/util/retryable.rb:17:in `retryable‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.4/plugins/communicators/ssh/communicator.rb:370:in `connect‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.4/plugins/communicators/ssh/communicator.rb:68:in `block in wait_for_ready‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:88:in `block in timeout‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `block in catch‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch‘
        from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:103:in `timeout‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.4/plugins/communicators/ssh/communicator.rb:46:in `wait_for_ready‘
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.4/lib/vagrant/action/builtin/wait_for_communicator.rb:16:in `block in call‘

就这么出错了。Guest已经启动,可以通过 vagrant ssh 连接,但错误的结果导致不能在已启动的 vagrant box 中共享主机文件,这可是个大问题。先后许多天,一直陷在这个巨坑里,从 vagrant 配置、插件,到 CentOS 7 Guest 的配置,想尽了各种办法,始终无法解决这个问题。从网上搜集到的办法主要是针对 Ubuntu Guest 的,依照做了之后都不起作用。

$ vagrant plugin install vagrant-centos7_fix











































以上是关于谈谈Vagrant中的那些坑:CentOS的主要内容,如果未能解决你的问题,请参考以下文章

谈谈text-overflow的那些坑和应对方法

谈谈text-overflow的那些坑和应对方法

关于hyperledger,那些年我蹚过的那些坑……

国庆了,谈谈为何拼车变贵的那些坑

云计算从Serverless说起,谈谈边缘计算的未来;从物理机到Kubernetes的那些坑与心得

CentOS6中安装配置启动GitLab以及遇到的那些坑