Vector Packet Processing (二)配置开发环境

本篇主要是介绍如何配置VPP的编译开发环境,具体配置请参考VPP开发文档:https://wiki.fd.io/view/VPP/Setting_Up_Your_Dev_Environment

  • 搭建开发环境

首先我们需要在主机上安装Vagrant软件和虚拟机,并在虚拟化里面设置编译开发环境,当然也可以不在虚拟机里面直接在主机host上来配置VPP的编译开发环境也是一样的,我这里面主要是刚开始使用对VPP还不熟悉的时候还是老老实实的按照官方文档上面的步骤来吧。

默认的配置是支持VMWare和Virtualbox的,首先需要安装这两者之一。

VMWare比Virtualbox运行的快,但是需要购买授权的。Virtualbox却是免费的,我们这里使用的是Virtualbox,可以从这里下载安装:https://www.virtualbox.org/wiki/Downloads

安装Vagrant软件,可以从这里下载安装:https://www.vagrantup.com/downloads.html

安装Vagrant插件

我们安装vagrant-cachier插件,这个插件主要是为了cache apt/yum命令的一些安装包,为了让Vagrant虚拟机重建的时候速度更快,当然这个插件的安装是可选的。

安装完Vagrant程序之后,我们可以使用下面的命令来安装vagrant-cachier插件,当然如有必要的话请设置好代理:

$ vagrant plugin install vagrant-cachier

安装Vagrant的虚拟机box文件,这里有两种类型的系统box文件,一种是Ubuntu系统,一种是CentOS系统。在这里Vagrant会直接从指定的URL处下载box文件并导入虚拟机,所以请保持网络通畅。

使用下面的命令来安装Ubuntu系统:

$ vagrant box add  --provider virtualbox https://atlas.hashicorp.com/puppetlabs/ubuntu-14.04-64-nocm

使用下面的命令来安装CentOS系统:

$ vagrant box add --provider virtualbox https://atlas.hashicorp.com/puppetlabs/centos-7.2-64-nocm
  • 获取VPP的源码
$ cd $HOME/source/vpp
$ git clone https://gerrit.fd.io/r/vpp
  • 定制Vagrant虚拟机

使用Vagrant启动虚拟机的时候是使用一个Vagrantfile文件来配置启动的虚拟机的一些配置的,我们VPP的开发环境虚拟机的配置文件在下面位置:

$ cd $HOME/source/vpp
$ vim ./build-root/vagrant/Vagrantfile

在这个Vagrantfile文件里面初始时使用的是默认配置,在这个文件里可以指定CPU、内存、网络、共享目录等等,具体更详细的配置信息请参考Vagrant的官网:https://www.vagrantup.com/docs/vagrantfile/

  • 操作虚拟机

一旦确定配置好了Vagrantfile文件,那么我们就可以开始操作虚拟机了。首先我们需要切换当前目录到Vagrantfile所在的目录下,这样我们才能够正确的操作虚拟机使用下面的一些命令:

$ cd $HOME/source/vpp/build-root/vagrant/

然后我们使用下面的命令来建立和启动VM:

$ vagrant up

在第一次启动的时候会比较慢,但是后续再启动的时候就会快一些。

成功启动VM之后,使用下面的命令登陆进入虚拟机中:

$ vagrant ssh

虚拟机使用完毕之后,我们可以使用下面的命令来关闭虚拟机:

$ vagrant halt

还有一些其他的操作命令如下:

$ vagrant suspend   //暂停虚拟机的运行
$ vagrant resume    //恢复虚拟机的运行
$ vagrant destroy    //关闭虚拟机并destroy所有的资源,但是下载下来的虚拟机box文件还是存在的,下次依然可以使用vagrant up命令来建立并启动虚拟机,如果要删除box文件,请使用vagrant box remove
  •  编译、安装并测试VPP

当我们成功的启动了虚拟机并在虚拟机中使用git命令获取了VPP的源代码之后,我们就可以编译安装并对VPP进行一些基本的功能测试了。

具体的编译安装以及测试请参考VPP的官网帮助:https://wiki.fd.io/view/VPP/Build,_install,_and_test_images

--------------------------------------------------------------------------------------------------------------------------------------------------

这里是本人初次配置VPP的开发环境以及编译、安装和测试VPP的时候遇到的一些问题和解决方法,在此记录作为后续的参考:

 1. 安装Vagrant插件的时候报错,报错信息如下:

    [root@demo-sff1 gems]# vagrant plugin install vagrant-cachier
    Installing the 'vagrant-cachier' plugin. This can take a few minutes...
    Bundler, the underlying system Vagrant uses to install plugins,
    reported an error. The error is shown below. These errors are usually
    caused by misconfigured plugin installations or transient network
    issues. The error from Bundler is:

    An error occurred while installing net-ssh (2.9.4), and Bundler cannot continue.
    Make sure that `gem install net-ssh -v '2.9.4'` succeeds before bundling.

    Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.Gem::RemoteFetcher::FetchError: Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/gems/net-ssh-2.9.4.gem)

这里报错信息提示我们要先使用命令"gem install net-ssh -v 2.9.4"来安装net-ssh包,但是使用gem命令来安装缺失的net-ssh包的时候,又报错了:

    [root@demo-sff1 gems]# gem install net-ssh -v '2.9.4'
    Errno::ECONNRESET: Connection reset by peer - SSL_connect (https://rubygems.org/)

这个原因是由于我们国内无法访问https://rubygems.org/,被GFW给屏蔽了。所以我们需要换成国内的gem源。使用下面的命令:

    [root@demo-sff1 gems]# gem sources -l        //查看当前gem的源
    *** CURRENT SOURCES ***

    https://rubygems.org/                        //当前使用的gem源是https://rubygems.org/
    [root@demo-sff1 gems]# gem sources -a https://ruby.taobao.org/                //更改源为淘宝提供的源
    [root@demo-sff1 gems]# gem sources --remove https://rubygems.org/            //删除原来的那个被屏蔽的源

关于这个问题可以参考这个link:http://blog.csdn.net/u012336923/article/details/50447835

如果有代理的话请正确的设置使用的代理,编辑文件/etc/profile, 在文件最后加入下面的命令:

    export http_proxy=http://proxy-prc.intel.com:911
    export https_proxy=http://proxy-prc.intel.com:912
    export ftp_proxy=http://proxy-prc.intel.com:911
    export socks_proxy=http://proxy-prc.intel.com:1080
    export no_proxy=intel.com,.intel.com,10.0.0.0/8,192.168.0.0/16,localhost,127.0.0.0/8,134.134.0.0/16

    export HTTP_PROXY=http://proxy-prc.intel.com:911
    export HTTPS_PROXY=http://proxy-prc.intel.com:912
    export FTP_PROXY=http://proxy-prc.intel.com:911
    export SOCKS_PROXY=http://proxy-prc.intel.com:1080
    export NO_PROXY=intel.com,.intel.com,10.0.0.0/8,192.168.0.0/16,localhost,127.0.0.0/8,134.134.0.0/16

进行上面的一些设置之后,我们就可以使用gem install命令来安装缺失的包,之后就可以使用vagrant plugin install命令来安装插件了,请使用下面的命令来安装,防止出现其他的错误。

[root@demo-sff1 gems]# gem install net-ssh -v '2.9.4' --install-dir /opt/vagrant/embedded/gems

请注意: 我们必须显示的指定gem将net-ssh包安装到目录/opt/vagrant/embedded/gems中,这样安装完成之后net-ssh包就可以被vagrant识别到,否则即使我们用gem install命令安装net-ssh成功了,但是vagrant还是会报"An error occurred while installing net-ssh (2.9.4), and Bundler cannot continue"的错误。

我们可以使用命令gem environment来查看下gem默认的一些环境配置。

[root@demo-sff1 vagrant]# gem environment
    RubyGems Environment:
      - RUBYGEMS VERSION: 2.1.11
      - RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [x86_64-linux]
      - INSTALLATION DIRECTORY: /usr/local/share/gems                    //gem命令将安装的包都安装到目录/usr/local/share/gems中了,但是很遗憾这个目录vagrant识别不到。有一种方法是将该目录下的相应子目录拷贝到vagrant的目录/opt/vagrant/embedded/gems中也是可以的,但是太麻烦; 
//第二种方法是直接在gem install命令安装的时候加上--install-dir /opt/vagrant/embedded/gems参数来指定安装位置。
- RUBY EXECUTABLE: /usr/bin/ruby - EXECUTABLE DIRECTORY: /usr/local/bin - SPEC CACHE DIRECTORY: /root/.gem/specs - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /usr/local/share/gems - /root/.gem/ruby - /usr/share/gems - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :backtrace => false - :bulk_threshold => 1000 - :sources => ["https://ruby.taobao.org/"] - REMOTE SOURCES: - https://ruby.taobao.org/ - SHELL PATH: - /usr/lib64/ccache - /usr/local/sbin - /usr/local/bin - /usr/sbin - /usr/bin - /usr/local/bin - /usr/local/sbin - /root/bin - /root/minion - /root/bin

安装提示使用gem命令安装完所有确实的包之后,我们就可以使用vagrant命令来安装插件了。

[root@demo-sff1 gems]# vagrant plugin install vagrant-cachier --plugin-source https://ruby.taobao.org/

在这里我们使用--plugin-source https://ruby.taobao.org/来指定插件下载源为国内淘宝源,如果不加这个参数那么默认使用的是源https://rubygems.org

具体可以参考下面的links:http://stackoverflow.com/questions/32805193/vagrant-plugin-install-error-gem-install-little-plugger-v-1-1-4-succeeds-be

            http://stackoverflow.com/questions/26414803/vagrant-proxyconf-split-bad-uri-error-on-installing-plugin-for-vagrant

2. 使用vagrant来启动VPP开发环境虚拟机

首先我们使用git命令来获取VPP source code:

    $ cd /home
    $ git clone https://gerrit.fd.io/r/vpp

上述命令完成之后,就会有一个/home/vpp/目录,该目录中为VPP的源码。

    $ cd /home/vpp/build-root/vagrant
    $ vi Vagrantfile

在源码中有一个Vagrantfile文件,这个文件是vagrant的配置文件。请注意: 我们后续使用vagrant命令对虚拟机进行的一系列操作(比如:vagrant up、vagrant ssh、vagrant halt等等命令)都必须先cd到目录/home/vpp/build-root/vagrant中,因为在这个目录下有vagrant操作虚拟机所需要的配置文件Vagrantfile。我们也可以看到VPP的官方文档中也提到了这些:

    cd to the vagrant directory
    In the command-line interface, navigate to the directory that has the pre-configured Vagrantfile. (In the following sample command, <install_dir> is the directory where you unzipped or cloned the VPP software.)
    $ cd <install_dir>/build-root/vagrant/    //操作虚拟机之前请切换当前目录到<install_dir>/build-root/vagrant/
    
    NOTE: The .../build-root directory contains the files that make up most of the build system. It contains all of the generic targets, including: xxx-build, xxx-rebuild, xxx-install, xxx-clean, xxx-wipe, xxx-configure, and xxx-find-source.
    
    Build the VM with Vagrant
    By default this will build an Ubuntu 14.0.4 VM.

    If you wish instead to build a Centos7 VM instead:
    $ (export VPP_VAGRANT_DISTRO=centos7;vagrant up)    //默认情况下搭建的VM是Ubuntu 14.0.4的系统,不过也可以使用这条命令来搭建一个CentOS 7的系统
    
    If you wish to use VMWareFusion as your provider, use:
    $ (export VAGRANT_DEFAULT_PROVIDER=vmware_fusion;vagrant up)  //默认情况下使用的是Virtualbox,如果要使用VMWare请使用这条命令
    
    When you first start Vagrant, it is normal for it to run for several minutes, building the VM, building VPP, and then a README will be displayed telling you how to run VPP.

    Use the Vagrant up command to cause Vagrant to start. Vagrant uses the Vagrantfile in the current working directory.

    $ vagrant up
    这个命令会默认建立一个Ubuntu 14.0.4的VM,首先vagrant会从https://vagrantcloud.com/puppetlabs/boxes/ubuntu-14.04-64-nocm/versions/1.0.3/providers/virtualbox.box下载一个box文件,随后会将该box文件用virtualbox来启动起来。
    
    Access the shell
    Use the Vagrant SSH command to access the running Vagrant machine and give you access to a shell.
    $ vagrant ssh
    
    If you wish to forward X-windows server requests, use this variation:
    $ vagrant ssh -- -X
    
    Success!

3. 关于vagrant设置proxy的问题

首先我们安装vagrant的一个插件vagrant-proxyconf,这个插件可以帮助我们设置在VM中的一些代理配置。

[root@demo-sff1 gems]# vagrant plugin install vagrant-proxyconf --plugin-source https://ruby.taobao.org/

安装完这个插件之后,我们在host宿主机上必须设置几个环境变量。

    export VAGRANT_HTTP_PROXY=http://proxy-prc.intel.com:911
    export VAGRANT_HTTPS_PROXY=http://proxy-prc.intel.com:912
    export VAGRANT_FTP_PROXY=http://proxy-prc.intel.com:911
    export VAGRANT_NO_PROXY=intel.com,.intel.com,10.0.0.0/8,192.168.0.0/16,localhost,127.0.0.0/8,134.134.0.0/16

随后当我们使用vagrant up命令来启动虚拟机的时候,vagrant-proxyconf插件就会获取到宿主机上设置的VAGRANT_HTTP_PROXY、VAGRANT_HTTPS_PROXY等环境变量的值并自动的对VM中的代理做一些配置。

比如我现在启动了一个Ubuntu 14.04版本的VM,那么vagrant-proxyconf插件会帮我设置好相应的proxy的环境变量。我们可以使用vagrant ssh命令登陆进入虚拟机并使用命令来查看当前虚拟机的代理是否正确设置了:

    vagrant@localhost:/vpp/build-root$ env | grep -i proxy
    NO_PROXY=intel.com,.intel.com,10.0.0.0/8,192.168.0.0/16,localhost,127.0.0.0/8,134.134.0.0/16
    http_proxy=http://proxy-prc.intel.com:911
    ftp_proxy=http://proxy-prc.intel.com:911
    FTP_PROXY=http://proxy-prc.intel.com:911
    https_proxy=http://proxy-prc.intel.com:912
    HTTPS_PROXY=http://proxy-prc.intel.com:912
    no_proxy=intel.com,.intel.com,10.0.0.0/8,192.168.0.0/16,localhost,127.0.0.0/8,134.134.0.0/16
    HTTP_PROXY=http://proxy-prc.intel.com:911

请注意: 这里需要在宿主机上设置的环境变量是VAGRANT_HTTP_PROXY、VAGRANT_HTTPS_PROXY等项,而不是http_proxy、https_proxy等项,根据实验证明设置http_proxy、https_proxy等项没有作用。

当然我们也可以直接修改Vagrantfile配置文件,将proxy配置进行修改即可。

      # use http proxy if avaiable
      if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
       config.proxy.http     = "$http_proxy"            //将$http_proxy修改为http://proxy-prc.intel.com:911
       config.proxy.https    = "$https_proxy"            //将$https_proxy修改为http://proxy-prc.intel.com:912
       config.proxy.no_proxy = "localhost,127.0.0.1"
      end

参考links: http://www.rubydoc.info/gems/vagrant-proxyconf/1.0.

4. 关于vagrant启动时配置provision的问题

在我们目前使用的Vagrantfile配置文件中,有如下的配置:

      # Pick the right distro and bootstrap, default is ubuntu1404
      distro = ENV['VPP_VAGRANT_DISTRO']
      if distro == 'centos7'
        config.vm.box = "puppetlabs/centos-7.2-64-nocm"
        config.vm.provision 'shell', path: 'bootstrap.centos7.sh'
      else
        config.vm.box = "puppetlabs/ubuntu-14.04-64-nocm"
        config.vm.provision 'shell', path: 'bootstrap.ubuntu1404.sh'
      end

这里配置了VM的provision,表示在VM启动完成后就会自动执行一个shell脚本,在我们这里执行的是当前目录下的bootstrap.ubuntu1404.sh脚本文件。

    Provisioners are run in three cases: the initial vagrant up, vagrant provision, and vagrant reload --provision.
    By default, provisioners are only run once, during the first vagrant up since the last vagrant destroy, unless the --provision flag is set, as noted above.

这个provision只在3种情况下运行: 第一次初始化的vagrant up命令运行时; 使用vagrant provision命令来显式的指定运行provision; 使用vagrant reload --provision命令来显式的指定重新加载provision。

默认情况下,从第一次vagrant up命令到最后的vagrant destroy命令之间, provisioners只会运行一次。 也就是说从第2次的vagrant up命令都不会再自动运行provisioners,除非使用vagrant destroy命令来destroy这个VM并再次使用vagrant up来启动虚拟机或者可以使用显式的运行provisioners命令来运行它。

参考links: https://www.vagrantup.com/docs/provisioning/basic_usage.html

5. 使用git命令下载源码包

使用git config命令来设置git使用的代理:

    git config --system http.proxy http://proxy-chain.intel.com:911
    git config --system https.proxy http://proxy-chain.intel.com:912

随后可以使用git命令来查看当前设置的代理:

    [root@demo-sff1 home]# git config -l
    http.proxy=http://proxy-prc.intel.com:911
    https.proxy=http://proxy-prc.intel.com:912

但是这里只设置了http和https的代理,所以我们只能使用git clone命令从http或者https管理的资源库来下载了。

    [root@demo-sff1 home]# git clone git://git.linaro.org/lng/odp.git
    Cloning into 'odp'...
    fatal: unable to connect to git.linaro.org:
    git.linaro.org[0: 23.21.56.198]: errno=Connection timed out

这里因为没有设置git资源库的代理,所以当我们从git://git.linaro.org/lng/odp.git地址下载源码包时下载是失败的,但是我们可以改为从http或者https服务器来下载。

    [root@demo-sff1 home]# git clone https://git.linaro.org/lng/odp.git
    Cloning into 'odp'...
    remote: Counting objects: 22946, done.
    remote: Compressing objects: 100% (5427/5427), done.
    remote: Total 22946 (delta 17185), reused 22205 (delta 16693)
    Receiving objects: 100% (22946/22946), 4.63 MiB | 2.95 MiB/s, done.
    Resolving deltas: 100% (17185/17185), done.
    Checking connectivity... done

直接改为从https服务器下载就成功了。

6. 使用vagrant配置public network

我们想从外部直接访问VM内部,在vagrant启动虚拟机的时候,默认会自动启动一个NAT类型的网络,也就是VM可以通过这个NAT类型的网络访问外部internet,但是外部不能通过这个NAT类型的网络来直接访问VM. 有两种方法可以进行配置:

  a. 我们可以设置vagrant的forwarded_port网络,这样可以配置访问宿主机host的某个端口的数据直接转发到VM的某个端口

  b. 我们可以给VM配置一个public_network网络并使用dhcp来给它分配一个IP地址

首先修改Vagrantfile配置文件,加入如下的配置:

config.vm.network "public_network"            //给VM额外配置一个public network

当使用vagrant up命令来启动虚拟机时,会提示需要给public network指定一个桥接的宿主机host的NIC网络接口,我们应该指定为宿主机上的连接外网的那个NIC网卡接口卡,比如我的宿主机上是em0网卡。

    [root@demo-sff1 home]# ifconfig
    em0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 10.239.129.177  netmask 255.255.254.0  broadcast 0.0.0.0
            inet6 fe80::21e:67ff:fed8:19b9  prefixlen 64  scopeid 0x20<link>
            ether 00:1e:67:d8:19:b9  txqueuelen 1000  (Ethernet)
            RX packets 2750043  bytes 1188719586 (1.1 GiB)
            RX errors 0  dropped 2  overruns 0  frame 0
            TX packets 469131  bytes 171203709 (163.2 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

这样指定之后,随后VM就会启动并自动建立一个网络桥接到宿主机的em0网卡上,并且会使用dhcp来分配一个IP地址。

    root@localhost:/# ifconfig
    eth0      Link encap:Ethernet  HWaddr 08:00:27:76:7a:6b                      //这个是vagrant启动时默认的一个NAT类型的网卡
              inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
              inet6 addr: fe80::a00:27ff:fe76:7a6b/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:6768 errors:0 dropped:0 overruns:0 frame:0
              TX packets:5066 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:601359 (601.3 KB)  TX bytes:587636 (587.6 KB)

    eth1      Link encap:Ethernet  HWaddr 08:00:27:a9:cd:45                      //这个是public network类型的网卡
              inet addr:10.239.128.208  Bcast:10.239.129.255  Mask:255.255.254.0
              inet6 addr: fe80::a00:27ff:fea9:cd45/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:125714 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1277 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:23733064 (23.7 MB)  TX bytes:297446 (297.4 KB)

    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:56 errors:0 dropped:0 overruns:0 frame:0
              TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:3354 (3.3 KB)  TX bytes:3354 (3.3 KB)

使用ping命令来测试网络是否通畅,发现VM可以ping通外网IP,但是外网IP无法ping通VM。这个原因是没有加入路由信息到系统路由表中。

vagrant@localhost:~$ route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
    10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
    10.239.128.0    0.0.0.0         255.255.254.0   U     0      0        0 eth1
    
    root@localhost:~# route add -net 10.239.0.0 netmask 255.255.0.0 gw 10.239.128.1 dev eth1    //加入一条路由信息访问网络10.239.0.0/16的数据直接从eth1网卡发送到网关10.239.128.1
    root@localhost:~# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    0.0.0.0         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
    10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
    10.239.0.0      10.239.128.1    255.255.0.0     UG    0      0        0 eth1
    10.239.128.0    0.0.0.0         255.255.254.0   U     0      0        0 eth1

7. 配置vagrant启动虚拟机使用多个CPU

现在VPP项目启动时需要配置多个core来进行运行,所以我们必须配置VM启动时使用多个CPU。我们修改配置文件Vagrantfile:

  config.vm.provider "virtualbox" do |vb|                        //这里表示,我们使用的虚拟机工具是virtualbox, 目前我们使用的是virtualbox
    vb.customize ["modifyvm", :id, "--ioapic", "on"]            //注意: 如果要配置VM使用多个CPU,那么必须将ioapic功能开启,否则设置多个CPU是不会生效的
    #vb.customize ["modifyvm", :id, "--memory", "8192"]
    #vb.customize ["modifyvm", :id, "--cpus", "16"]
    vb.memory = 8192                                            //设置VM的内存为8G
    vb.cpus = 16                                                //设置VM的CPU个数为16个
  end
  config.vm.provider "vmware_fusion" do |fusion,override|        //这里表示,我们使用的虚拟机工具是vmware fusion, vmware fusion是面向苹果电脑推出的一款软件
    fusion.vmx["memsize"] = "4096"
  end
  config.vm.provider "vmware_workstation" do |vws,override|        //这里表示,我们使用的虚拟机工具是vmware workstation
    vws.vmx["memsize"] = "8192"
    vws.vmx["numvcpus"] = "4"
  end

具体可以参考如下的一些links:

http://stackoverflow.com/questions/17117063/how-can-i-create-a-vm-in-vagrant-with-virtualbox-with-two-cpus

http://www.ibm.com/developerworks/cn/linux/l-affinity.html

转载于:https://www.cnblogs.com/hurenkai/p/5592426.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值