使用 VirtualBox + Vagrant + Homestead 超时
Time out of sync using VirtualBox + Vagrant + Homestead
每当我的电脑休眠时,Homestead 环境中的时间就会不同步。唤醒时时间不会更新,它只是从计算机开始休眠时开始继续。这迫使我销毁然后再启动 Vagrant。
版本:
- Homestead 5.0.1
- 流浪汉 2.0.1
- VirtualBox 5.2.4
我已将其添加到 Vagrantfile:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider 'virtualbox' do |vb|
vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000 ]
end
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
// More code...
如何让 Homestead 环境同步时间?
当您的计算机休眠时,它正在使用 vagrant suspend
命令,就虚拟机而言,这就像按时(和宇宙)暂停按钮。
唯一真正的解决方法是在让计算机休眠之前手动 vagrant halt
虚拟机。
你可以运行:
sudo service ntp stop && sudo ntpdate -s time.nist.gov && sudo service ntp start
(您可能需要安装 ntpdate)
我已将此添加到 after.sh,因此它 运行 已提供,但它不会 运行 唤醒或 "up"。
我很想找到一种自动执行此操作的方法。
我在 going out of sync with s3 时遇到了这个解决方案。
编辑ntp.conf
sudo vim /etc/ntp.conf
将服务器更改为:
server 0.amazon.pool.ntp.org iburst
server 1.amazon.pool.ntp.org iburst
server 2.amazon.pool.ntp.org iburst
server 3.amazon.pool.ntp.org iburst
重启ntp服务
sudo service ntp restart
大功告成。
重启ntp服务
$sudo service ntp restart
Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use.
我通过 phpmyAdmin 登录到我的数据库,并且服务器时间已正确同步。试一试
每当我的电脑休眠时,Homestead 环境中的时间就会不同步。唤醒时时间不会更新,它只是从计算机开始休眠时开始继续。这迫使我销毁然后再启动 Vagrant。
版本:
- Homestead 5.0.1
- 流浪汉 2.0.1
- VirtualBox 5.2.4
我已将其添加到 Vagrantfile:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider 'virtualbox' do |vb|
vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000 ]
end
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
end
// More code...
如何让 Homestead 环境同步时间?
当您的计算机休眠时,它正在使用 vagrant suspend
命令,就虚拟机而言,这就像按时(和宇宙)暂停按钮。
唯一真正的解决方法是在让计算机休眠之前手动 vagrant halt
虚拟机。
你可以运行:
sudo service ntp stop && sudo ntpdate -s time.nist.gov && sudo service ntp start
(您可能需要安装 ntpdate)
我已将此添加到 after.sh,因此它 运行 已提供,但它不会 运行 唤醒或 "up"。
我很想找到一种自动执行此操作的方法。
我在 going out of sync with s3 时遇到了这个解决方案。
编辑ntp.conf
sudo vim /etc/ntp.conf
将服务器更改为:
server 0.amazon.pool.ntp.org iburst
server 1.amazon.pool.ntp.org iburst
server 2.amazon.pool.ntp.org iburst
server 3.amazon.pool.ntp.org iburst
重启ntp服务
sudo service ntp restart
大功告成。
重启ntp服务
$sudo service ntp restart
Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use.
我通过 phpmyAdmin 登录到我的数据库,并且服务器时间已正确同步。试一试