Home > Vagrant | 開発環境 > Vagrant + VirtualBox で nfs を使って、synced_folder を速くする

Vagrant + VirtualBox で nfs を使って、synced_folder を速くする


   354  

Vagrant + VirtualBox 便 synced_folder  nfs 使

vagrant
 Vagrant + VirtualBox 使 synced_folder 

synced_folder VirtualBox  shared folders  nfs 使

nfsd 


synced_folder  nfs  nfsd 

OS XLion / Mountain Lion nfsd nfsd  enable nfsd  nfsd 

 nfsd  /etc/exports 
 
$ sudo touch /etc/exports
$ ls /etc/exports
/etc/exports

nsfd enable  nfsd 
 
$ sudo nfsd enable

$ sudo nfsd status
nfsd service i enabled
nfsd is running (pid xxxxx, 8 threads)

nfsd disable nfsd 
 
$ sudo nfsd disable

$ sudo nfsd status
nfsd service is disabled
nfsd is not running

Vagrantfile  nfs 


Vagrantfile  synced_folder  NFS 

2 host-only IPsynced_folder  :nfs => true 


vagrant up synced_folder  NFS 
 
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
(snip)
[default] Exporting NFS shared folders...
Preparing to edit /etc/exports. Administrator privileges will be required...
The nfsd service does not appear to be running.
Starting the nfsd service (use 'enable' to permanently enable)
[default] Mounting NFS shared folders...

 NFS 
 
$ vagrant ssh
[vagrant@localhost ~]$ df -h
Filesystem            Size  Used Avail Use% マウント位置
/dev/mapper/VolGroup-lv_root
                      8.4G  1.1G  7.0G  14% /
tmpfs                 230M     0  230M   0% /dev/shm
/dev/sda1             485M   32M  429M   7% /boot
/vagrant              931G  359G  572G  39% /vagrant
192.168.33.1:/path/to/directory                      <---- NFS でマウントした synced_folder
                      931G  359G  572G  39% /share

ホストの /etc/exports には下記のように対象のディレクトリが自動で追記されています。

$ cat /etc/exports
# VAGRANT-BEGIN: 0f0224b9-b61c-47ff-b769-49d1e3103b28
"/path/to/directory" 192.168.33.30 -mapall=501:20
# VAGRANT-END: 0f0224b9-b61c-47ff-b769-49d1e3103b28

IPvagrant up 
 
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
(snip)
NFS requires a host-only network with a static IP to be created.
Please add a host-only network with a static IP to the machine
for NFS to work.


NFS 使 Web  siege 

CakePHPHelloDBdocument_root

siege -c 10 -t 60s -b http://URL/5

NFS  3.5
方式 計測値 Rate
share folders(synced_folderデフォルト) 11.366 trans/sec 1
NFS 40.066 trans/sec 3.52

参考までに、Vagrant サイトでは実際の Rails プロジェクトのテストを使った結果が掲載されています。NFS が 22s に対して、Shared folders は 5m14s となっており、大きく速度が異なっています。

VirtualBox Shared Folders: 5m 14s
Host File System: 10s
Native VM File System: 13s
NFS Shared Folders: 22s
NFS Shared Folders (warm cache): 14s
http://docs-v1.vagrantup.com/v1/docs/nfs.html

まとめ

NFS を使うことで簡単に synced_folder のパフォーマンスを上げることができます。synced_folder のパフォーマンスに不満がある場合は NFS を一度試してみて下さい。

ただ、ホスト側で nfsd を動かす必要があるので、Windows など nfsd が標準でインストールされていない環境では気軽に使えないのが難点ですね。

参考

Pocket

follow us in feedly

Home > Vagrant | 開発環境 > Vagrant + VirtualBox で nfs を使って、synced_folder を速くする

検索

フィード
メタ情報

Return to page top