We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原文链接: #28 应用场景: 本地开发机器是mac或者Linux、windows,需要模拟发布到centos服务器的流程
注意执行该命令位置(pwd) /home/someone/
/home/someone/
已有box, 位置: /home/someone/centos.box
vagrant box add --name centos_for_dev /home/someone/centos.box
vagrant init centos_for_dev
会发现在 /home/someone/有一个文件 VagrantFile
vagrant up && vagrant ssh 登录centos_for_dev 机器
vagrant up && vagrant ssh
自动登录, 用户名和密码都是 vagrant
端口映射
config.vm.network "forwarded_port", guest: 8000, host: 3306
mysql -u root -p
sudo vim /etc/sysconfig/iptables
-A INPUT -p tcp -m tcp --dport 3306 -m state --state NEW -j ACCEPT
service iptables restart
文件映射
config.vm.synced_folder "/home/someone/code/", "/opt/code"
/home/someone/code/
/opt/code
scp 同步文件
vagrant plugin install vagrant-scp scp -P 2222 your_file vagrant@127.0.0.1:/home/vagrant/
vagrnat up 开机
vagrant halt 关机
创建新用户centos
useradd centos
config.ssh.username = "centos"
node.vm.network "public_network", ip: "10.10.30.#{200+i}", bridge: "en0: Wi-Fi (AirPort)" ip 与 ifconfig 中主要的实际使用使用的网络在同一个网段即可,200+是因为200以后的 IP 多数没有被占用 bridge 使用 networksetup -listallhardwareports 查看;关键字List All Network Hardware from the Command Line in OS X
使用 networksetup -listallhardwareports
List All Network Hardware from the Command Line in OS X
node.vm.box = "/Users/someone/workspace/vagrant-boxs/centos7_test.box"
可以是 虚拟机 box 的绝对路径 vagrant 市场中的名称 和 Vagrantfile 在同一个文件夹中 node.vm.box = "centos7_test.box"
node.vm.box = "centos7_test.box"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
注意执行该命令位置(pwd)
/home/someone/
已有box, 位置: /home/someone/centos.box
vagrant box add --name centos_for_dev /home/someone/centos.box
vagrant init centos_for_dev
会发现在 /home/someone/有一个文件 VagrantFile
vagrant up && vagrant ssh
登录centos_for_dev 机器自动登录, 用户名和密码都是 vagrant
端口映射
config.vm.network "forwarded_port", guest: 8000, host: 3306
其中host为宿主机(比如widdows或者mac机器),guest为vagrant内的虚拟机。mysql -u root -p
的时候,访问本地3306端口的mysql,实际上访问的是vagrant中的端口为8000的mysqlsudo vim /etc/sysconfig/iptables
编辑防火墙,开启8000端口,供外部访问-A INPUT -p tcp -m tcp --dport 3306 -m state --state NEW -j ACCEPT
service iptables restart
文件映射
config.vm.synced_folder "/home/someone/code/", "/opt/code"
/home/someone/code/
目录下的代码修改了之后,vagrant虚拟机的/opt/code
目录下的代码会同步更新,或者说二者指向同一份文件scp 同步文件
vagrnat up 开机
vagrant halt 关机
创建新用户centos
useradd centos
创建centos用户。config.ssh.username = "centos"
更多参见官网文档 Get Started
Vagrant 集群配置
node.vm.box = "/Users/someone/workspace/vagrant-boxs/centos7_test.box"
The text was updated successfully, but these errors were encountered: