developer tip

두 개의 CPU가있는 VirtualBox로 Vagrant에서 VM을 어떻게 만들 수 있습니까?

optionbox 2020. 11. 5. 07:55
반응형

두 개의 CPU가있는 VirtualBox로 Vagrant에서 VM을 어떻게 만들 수 있습니까?


Windows 7 64 비트에서 VM (Ubuntu 32 비트) 시작을 시도합니다. modify vmVagrantfile에 명령을 추가 했음에도 불구하고 VM에서 두 개의 코어를 표시하는 데 문제가 있습니다. 내 Vagrant 버전은 1.2.2입니다.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  config.vm.provider :virtualbox do |vb|
    vb.customize ["modifyvm", :id, "--memory", "2048"]
    vb.customize ["modifyvm", :id, "--cpus", "2"]   
  end  
end

이 Vagrantfile로 vagrant up명령을 내립니다. 그런 다음 나는 vagrant ssh다음 결과 lscpu발행 합니다.

Architecture:          i686
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 58
Stepping:              9
CPU MHz:               2565.513
BogoMIPS:              5131.02
L1d cache:             32K
L1d cache:             32K
L2d cache:             6144K

CPU가 2로 표시되어야한다고 생각하므로 VM에는 현재 CPU가 하나만 있습니다. 실행할 때 2 개의 CPU를 표시하려면 lscpu어떻게해야합니까?


Vagrantfile 내부 vb.customize ["modifyvm", :id, "--ioapic", "on"]config.vm.provider블록에 추가하십시오 .

VirtualBox 문서를 보면 다음과 같이 언급됩니다.

"참고 I / O APIC 활성화는 64 비트 게스트 운영 체제, 특히 Windows Vista에 필요합니다. 가상 컴퓨터에서 둘 이상의 가상 CPU를 사용하려는 경우에도 필요합니다."


Oracle Virtualbox를 사용하여 vagrant를 실행하는 경우 가장 일반적인 문제는 Windows 7, 8 또는 10에서 Hyper-V와 관련된 것입니다. 이로 인해 32 비트와 하나의 CPU로 제한됩니다.

"Windows 기능"을 실행하거나 검색하고 "Windows 기능 켜기 또는 끄기"를 선택합니다.

확인란에서 Hyper-V가 꺼져 있는지 확인합니다. Microsoft Hyper-V를 사용하여 Virtualbox에 대해 VT-x를 활성화 할 수 없습니다.

그런 다음 Vagrantfile 부팅을 다음과 같이 매우 사용자 친화적으로 만들 수 있습니다.

  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2404"
    vb.cpus = "2"
  end

2 개의 코어가 실행되고 2GB 이상의 메모리가 필요하다고 가정합니다.

추신-포트 포워딩을 추가하는 것을 잊지 마십시오. PHPStorm (xdebug, mysql 및 웹)의 경우 다음을 사용합니다.

  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.network "forwarded_port", guest: 3306, host: 3306
  config.vm.network "forwarded_port", guest: 9000, host: 9000

It seems you have not mentioned which provider you are using. As of Vagrant 1.7 many VM providers (such as VirtualBox, HyperV) supports the following configuration in your Vagrantfile:

config.vm.provider "virtualbox" do |v|
  v.memory = 1024
  v.cpus = 2
end

Check out the specific provider you are using in the vagrant documentation.

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

반응형