- 标签
- Vagrant
最新发布的 Vagrant v2.4.2 已经支持 VirtualBox 7.1 了。
近期将本地安装的 VirtualBox 升级到 7.1 版本,昨天启动开发环境时时发现 Vagrant 2.4.1 不支持 VirtualBox 7.1,错误提示如下:
The provider 'virtualbox' that was requested to back the machine
'xxxxyyyyyzzzz' is reporting that it isn't usable on this system. The
reason is shown below:
Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:
4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0, 6.1, 7.0
A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.
看起来 Vagrant 2.4.1 最高支持到 7.0 版本的 VirtualBox。如果要等 Vagrant 更新版本还不知道要到猴年马月,将 VirtualBox 退回到 7.0 版本也怕把开发环境弄坏。好在只要稍稍动一下手脚就能让 Vagrant 支持 VirtualBox 7.1 了。
……
日常操作系统是 Windows ,通常使用 Vagrant 来搭建本地开发环境。在某次重装系统后,像往常一样用 vagrant up --provision
命令成功地创建了开发环境,接下来用 vagrant ssh
登录系统时,竟然提示要求输入密码:
[email protected]'s password:
这是之前从未遇到过的问题。虽然可以用默认密码 vagrant
登录系统,但是总觉得不爽。一定要找到原因。
用 vagrant ssh --debug
命令输出调试信息:
DEBUG safe_exec: Converted - Command: `"C:\\Windows\\System32\\OpenSSH\\/ssh.EXE"` Args: `["[email protected]", "-p", "2222", "-o", "LogLevel=FATAL", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-o", "PubkeyAcceptedKeyTypes=+ssh-rsa", "-o", "HostKeyAlgorithms=+ssh-rsa", "-i", "D:/myproject/devenv/.vagrant/machines/myproject/virtualbox/private_key", "-o", "ForwardAgent=yes"]`
[email protected]'s password:
发现 ssh 命令确实有使用 private_key 文件来进行验证身份。但是不知道为什么失败了,转而要求输入密码。
……
在使用 Vagrant 的过程中发现了一个问题:对于使用 config.vm.synced_folder
进行配置的共享文件夹,如果在 Host 系统(本地环境)中修改了其路径下的文件,在 Guest 系统(虚拟机环境)中是无法通过 inotifywait
接收到文件系统事件的。
而通常情况下,Vagrant 的共享目录是用来存放源代码的。我们会在 Host 系统中编辑源代码,在 Guest 系统中运行它们。如果 Guest 系统无法监控源代码目录的变化,就无法实现源代码的自动编译和热加载。
……
下载 ubuntu-15.04-amd64.box 包文件。使用离线安装的方式:
shellvagrant box add ubuntu-15.04-amd64 file:///D:\downloads\ubuntu-15.04-amd64.box
其中 D:\downloads\ubuntu-15.04-amd64.box
是下载后的 box 文件路径。
切换到项目路径下,初始化并启动 Vagrant:
shellmkdir ~/project/devstack
cd ~/project/devstack
vagrant init ubuntu-15.04-amd64
启动并登录虚拟机系统
shellvagrant up
vagrant ssh
更新 apt 软件库:
shellsudo apt-get update -y
sudo apt-get upgrade -y
安装需要的软件包:
shellsudo apt-get install -y git ansible libmysqld-dev mysql-server mongodb-server redis-server nginx-full supervisor uwsgi uwsgi-plugin-python python-pip python-dev python-virtualenv python-mysqldb python-mongoengine python-redis python-gevent virtualenvwrapper php5 php5-fpm php5-dev libjpeg-dev
安装第三方软件:
shellsudo dpkg -i /vagrant/elasticsearch-2.0.0.deb
sudo dpkg -i /vagrant/logstash_2.0.0-1_all.deb
禁用无用的服务:
……