2015-04-19 8 views
18

Sto configurando una cartella sincronizzata in una macchina vagabonda come mostrato in cmd dump di seguito e mi aspetto che ogni volta che aggiorno i file in questa cartella sulla macchina host gli aggiornamenti si riflettano all'interno anche la macchina ospite, tuttavia non sta succedendo.La cartella sincronizzata in vagante non si sincronizza in tempo reale

Ecco la discarica e l'evidenza di non accada (creo un file di esempio e modificarlo cambiando il testo in in esso test1-test2):

mypc:~ user$ cd Projects/synctest/ 
mypc:synctest user$ ls 
Vagrantfile 
mypc:synctest user$ cat Vagrantfile 
# -*- mode: ruby -*- 
# vi: set ft=ruby : 

VAGRANTFILE_API_VERSION = "2" 

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 

    # always use Vagrants insecure key 
    config.ssh.insert_key = false 

    # Setup box 
    config.vm.box = "coreos-stable" 

    # Setup shared folder 
    config.vm.synced_folder ".", "/vagrant" 

    # Setup memory usage 
    config.vm.provider "virtualbox" do |v| 
    v.memory = 2048 
    end 

    # Define `dev` vm 
    config.vm.define :dev do |dev| 
    end 

    if Vagrant.has_plugin?("vagrant-cachier") 
    config.cache.scope = :box 
    end 

end 
mypc:synctest user$ echo "test1" > test.txt 
mypc:synctest user$ cat test.txt 
test1 
mypc:synctest user$ vagrant up 
Bringing machine 'dev' up with 'virtualbox' provider... 
==> dev: Importing base box 'coreos-stable'... 
==> dev: Matching MAC address for NAT networking... 
==> dev: Checking if box 'coreos-stable' is up to date... 
==> dev: Setting the name of the VM: synctest_dev_1429451824339_35638 
==> dev: Fixed port collision for 22 => 2222. Now on port 2200. 
==> dev: Clearing any previously set network interfaces... 
==> dev: Preparing network interfaces based on configuration... 
    dev: Adapter 1: nat 
==> dev: Forwarding ports... 
    dev: 22 => 2200 (adapter 1) 
==> dev: Running 'pre-boot' VM customizations... 
==> dev: Booting VM... 
==> dev: Waiting for machine to boot. This may take a few minutes... 
    dev: SSH address: 127.0.0.1:2200 
    dev: SSH username: core 
    dev: SSH auth method: private key 
    dev: Warning: Connection timeout. Retrying... 
==> dev: Machine booted and ready! 
==> dev: Rsyncing folder: /Users/user/Projects/synctest/ => /vagrant 
==> dev: Rsyncing folder: /Users/user/.vagrant.d/cache/coreos-stable/ => /tmp/vagrant-cache 
==> dev: Configuring cache buckets... 
mypc:synctest user$ vagrant ssh 
CoreOS stable (633.1.0) 
[email protected] ~ $ cd ../../vagrant/ 
[email protected] /vagrant $ ls 
Vagrantfile test.txt 
[email protected] /vagrant $ cat test.txt 
test1 
[email protected] /vagrant $ exit 
logout 
Connection to 127.0.0.1 closed. 
mypc:synctest user$ cat test.txt 
test1 
mypc:synctest user$ echo "test2" > test.txt 
mypc:synctest user$ cat test.txt 
test2 
mypc:synctest user$ vagrant ssh 
Last login: Sun Apr 19 13:57:37 2015 from 10.0.2.2 
CoreOS stable (633.1.0) 
[email protected] ~ $ cd ../../vagrant/ 
[email protected] /vagrant $ ls 
Vagrantfile test.txt 
[email protected] /vagrant $ cat test.txt 
test1 
[email protected] /vagrant $ echo "hi from guest machine" > test.txt 
[email protected] /vagrant $ cat test.txt 
hi from guest machine 
[email protected] /vagrant $ exit 
logout 
Connection to 127.0.0.1 closed. 
mypc:synctest user$ cat test.txt 
test2 
mypc:synctest user$ 

È persino supposto per la sincronizzazione in tempo reale? Se sì, perché non si sta sincronizzando?

Modifica: OS X 10.8.5, VirtualBox, coreos casella.

risposta

25

Nel tuo Vagrantfile il tipo di cartella sincronizzata è il default vboxsf, tuttavia, nello stdout vagabondo, mostra il tipo rsync, penso che sia necessario correggerlo nel file di configurazione.

Si supponga che si sta utilizzando il tipo rsync, si dovrebbe avere la seguente nel Vagrantfile

Vagrant.configure("2") do |config| 
    config.vm.synced_folder ".", "/vagrant", type: "rsync", 
    rsync__exclude: ".git/" 
end 

NOTA: per impostazione predefinita, rsync__auto è impostata su true, il che significa rsync-auto sarà guardare e sincronizzare questa cartella automaticamente .

Eseguire vagrant rsync-auto e la directory deve essere sincronizzata tra host e guest.

Vedere vagrant docs per ulteriori informazioni.

+0

Grazie per la risposta. Sembra che il problema sia nella scatola "coreos". L'installazione di default non ci sta davvero lavorando. Alla fine ho imitato l'impostazione delle cartelle sincronizzate da vagabondo da [repository coreos-vagrant] (https://github.com/coreos/coreos-vagrant/blob/master/Vagrantfile) perché rsync-auto non ha funzionato per me (I dovevo avviare esplicitamente 'vagrant rsync-auto' perché potesse funzionare). A proposito, con altre finestre (in particolare 'ubuntu/trusty64') l'impostazione di sincronizzazione predefinita funziona correttamente. –

+0

Felice di essere di aiuto. Mi è appena venuto in mente qualcosa: CoreOS/filesystem (subvol Btrfs) dovrebbe essere di sola lettura? Questa potrebbe essere la causa ... –

+0

Sfortunatamente sto avendo lo stesso problema con la scatola ufficiale di Vora di Fedora 22. Aggiungere la configurazione suggerita ed eseguire 'vagrant rsync-auto' non sembra aver fatto nulla. – DuffJ

Problemi correlati