vagrant 1.下载部署linux环境
2016-09-22 17:23
369 查看
原地址:Vagrant 下载部署linux环境
1. 安装 VirtualBox
虚拟机还是得依靠 VirtualBox 来搭建,免费小巧
下载地址:https://www.virtualbox.org/wiki/Downloads
* 虽然 Vagrant 也支持 VMware,不过 VMware 是收费的,对应的 Vagrant 版本也是收费的。
我下载的是:VirtualBox 5.1.6 for Windows hosts x86/amd64
2. 下载 Vagrant
下载地址:http://downloads.vagrantup.com/
3.下载contos box,可以来这里下载:http://www.vagrantbox.es/
经过上面的下载,我们
下载了virtual box vagrant centos 6.6 box 三个文件
4.安装 virtualbox , vagrant ,这个基本都是下一步,安装完成后要重启
安装上面的两个成功后,重启后。
4.1
window建+r ,打开命令行,
进入命令行模式,输入vagrant,看看是否安装成功
4.2 添加centos box
进入d盘,添加centos box
进入contos box文件所在的文件夹,我的是在d:\vagrant文件路径下,按照上面截图的命令行进入d盘,在通过cd vagrant 进入相应文件夹。
按照这个命令box
通过vagrant box list 查看添加的列表
4.3创建虚拟机:
添加了 Box 以后,我们就可以用 Vagrant 基于这个 Box 去创建虚拟机了。先找个地方去创建一个目录,这个目录就是你的项目所在的目录,它会自动跟虚拟机上的某个目录同步,也就是在你电脑上的这个目录里面的文件,你同样可以在虚拟机里的某个目录里面找到。比如我的目录在d:\myvagrant,我创建这个目录,然后再进入到这个目录,在命令行工具下面执行:
初始化:
启动 vagrant up命令,第一次会慢一些,因为要复制文件。
在上面,发现了拨错:
打开文件:D:\myvagrant\Vagrantfile
将Vagrantfile配置文件中vb.gui = true的注释去掉,下面将三行的代码的注释去掉了,也就是前面的 # 号,而不是一行,这里要注意,如果仅仅去掉vb.gui = true的注释,会报错。
然后关闭 vagrant halt ,重启,查看报错。
运行vagrant up 启动 virtualbox 后,GUI会给出提示
重启后,换一个文件路径,我原来的是d:\myvagrant,我换到了另外一个路径d:\disk\va1
上面出现waining,是没有问题的,现在我们可以通过ssh直连了。
查看vagrant的状态 vagrant status
关闭VM vagrant halt
在启动 vagrant up, 第二次启动会比较快,因为不会复制文件,但是还是很慢,哈哈,多等下就好了。
ssh 连接
ip:127.0.0.1
端口:2222
用户名:vagrant
密码:vagrant
root的密码也是vagrant ,上面连接一定要注意,更改ssh的默认端口22 为 2222
ssh 登录后,我发现语言是德语的,日
语言改成英语
重启一下linux
查看centos 版本:
到此为止,初始环境搭配好了,下面需要安装 lnmp环境了。
具体参看下一节
其他问题:
问题2: vagrant启动报错The following SSH command responded with a non-zero exit status.
解决方案
虽然vagrant up启动报错,但是vagrant ssh还是能登陆虚拟机的,进入虚拟机后,执行如下命令
对, 问题就处在在持久网络设备udev规则(persistent network device udev rules)是被原VM设置好的,再用box生成新VM时,这些rules需要被更新。而这和Vagrantfile里对新VM设置private network的指令发生冲突。删除就好了。
vagrant reload 再次启动就OK。
1. 安装 VirtualBox
虚拟机还是得依靠 VirtualBox 来搭建,免费小巧
下载地址:https://www.virtualbox.org/wiki/Downloads
* 虽然 Vagrant 也支持 VMware,不过 VMware 是收费的,对应的 Vagrant 版本也是收费的。
我下载的是:VirtualBox 5.1.6 for Windows hosts x86/amd64
2. 下载 Vagrant
下载地址:http://downloads.vagrantup.com/
3.下载contos box,可以来这里下载:http://www.vagrantbox.es/
经过上面的下载,我们
下载了virtual box vagrant centos 6.6 box 三个文件
4.安装 virtualbox , vagrant ,这个基本都是下一步,安装完成后要重启
安装上面的两个成功后,重启后。
4.1
window建+r ,打开命令行,
进入命令行模式,输入vagrant,看看是否安装成功
4.2 添加centos box
进入d盘,添加centos box
进入contos box文件所在的文件夹,我的是在d:\vagrant文件路径下,按照上面截图的命令行进入d盘,在通过cd vagrant 进入相应文件夹。
D:\vagrant\centos-6.6-x86_64.box
按照这个命令box
vagrant box add 名称 路径
通过vagrant box list 查看添加的列表
4.3创建虚拟机:
添加了 Box 以后,我们就可以用 Vagrant 基于这个 Box 去创建虚拟机了。先找个地方去创建一个目录,这个目录就是你的项目所在的目录,它会自动跟虚拟机上的某个目录同步,也就是在你电脑上的这个目录里面的文件,你同样可以在虚拟机里的某个目录里面找到。比如我的目录在d:\myvagrant,我创建这个目录,然后再进入到这个目录,在命令行工具下面执行:
初始化:
启动 vagrant up命令,第一次会慢一些,因为要复制文件。
在上面,发现了拨错:
Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period. If you look above, you should be able to see the error(s) that Vagrant had when attempting to connect to the machine. These errors are usually good hints as to what may be wrong. If you're using a custom box, make sure that networking is properly working and you're able to connect to the machine. It is a common problem that networking isn't setup properly in these boxes. Verify that authentication configurations are also setup properly,as well. If the box appears to be booting properly, you may want to increase the timeout ("config.vm.boot_timeout") value.
打开文件:D:\myvagrant\Vagrantfile
将Vagrantfile配置文件中vb.gui = true的注释去掉,下面将三行的代码的注释去掉了,也就是前面的 # 号,而不是一行,这里要注意,如果仅仅去掉vb.gui = true的注释,会报错。
config.vm.provider "virtualbox" do |vb| # # Don't boot with headless mode vb.gui = true # # # Use VBoxManage to customize the VM. For example to change memory: # vb.customize ["modifyvm", :id, "--memory", "1024"] end
然后关闭 vagrant halt ,重启,查看报错。
运行vagrant up 启动 virtualbox 后,GUI会给出提示
VT-x/AMD-V硬件加速在您的系统中不可用。您的64-位虚拟机将无法检测到 64-位处理器,从而无法启动。 这是由于在BOIS中没有开启cpu虚拟化支持,重启F2或F10等进入BIOS设置Virtualization为Enable(我的Thinkpad是Security=>Virtualizatio设置为Enable);
电脑重启后,再次vagrant up启动虚拟机还是有一些问题,当时也没有记录下来错误信息,只记得解决方案是使用vagrant destroy将虚拟机从磁盘中删除,然后使用vagrant up命令重新创建。
重启后,换一个文件路径,我原来的是d:\myvagrant,我换到了另外一个路径d:\disk\va1
上面出现waining,是没有问题的,现在我们可以通过ssh直连了。
查看vagrant的状态 vagrant status
关闭VM vagrant halt
在启动 vagrant up, 第二次启动会比较快,因为不会复制文件,但是还是很慢,哈哈,多等下就好了。
ssh 连接
ip:127.0.0.1
端口:2222
用户名:vagrant
密码:vagrant
root的密码也是vagrant ,上面连接一定要注意,更改ssh的默认端口22 为 2222
ssh 登录后,我发现语言是德语的,日
vim /etc/sysconfig/i18n
语言改成英语
LANG="en_US.UTF-8" SYSFONT="latarcyrheb-sun16"
重启一下linux
查看centos 版本:
[root@localhost ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@localhost ~]#
到此为止,初始环境搭配好了,下面需要安装 lnmp环境了。
具体参看下一节
其他问题:
问题2: vagrant启动报错The following SSH command responded with a non-zero exit status.
The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! ARPCHECK=no /sbin/ifup eth1 2> /dev/null Stdout from the command: Device eth1 does not seem to be present, delaying initialization. Stderr from the command:
解决方案
虽然vagrant up启动报错,但是vagrant ssh还是能登陆虚拟机的,进入虚拟机后,执行如下命令
sudo rm -f /etc/udev/rules.d/70-persistent-net.rules
对, 问题就处在在持久网络设备udev规则(persistent network device udev rules)是被原VM设置好的,再用box生成新VM时,这些rules需要被更新。而这和Vagrantfile里对新VM设置private network的指令发生冲突。删除就好了。
vagrant reload 再次启动就OK。
相关文章推荐
- win8下使用vagrant安装部署Linux虚拟环境出错的问题解决
- 使用Vagrant在Windows平台搭建嵌入式Linux开发环境(1)虚拟环境部署
- Linux环境redis的下载安装部署过程
- J2EE项目在LINUX环境下的部署:一、LINUX 安装
- arm-linux,arm-elf-交叉编译环境下载地址(转)
- 在Linux平台下部署Java web环境和发布Java web程序
- 在Linux下Java环境的部署(linux+jdk+tomcat+mysql)
- Linux环境下配置AT91RM9200固件下载工具
- J2EE项目在LINUX环境下的部署:五、容器TOMCAT的安装
- Linux 开发环境工具 下载网址大全
- linux下Oracle 安装前的环境部署
- J2EE项目在LINUX环境下的部署:一、LINUX 安装
- arm-linux,arm-elf-交叉编译环境下载地址
- J2EE项目在LINUX环境下的部署:二、F-Secure SSH Client的使用
- J2EE项目在LINUX环境下的部署:三、JDK的安装
- Linux 开发环境工具 下载网址大全
- 在Linux环境下构建P2P下载服务的方法教程
- arm-linux , arm-elf-交叉编译环境下载地址
- LINUX桌面环境 KDE 4.1 RC1发布下载
- linux下perl连接mysql数据库环境部署详解