DevOps

Vagrant - Ubuntu 가상환경 구동시 오류(Timed out while waiting for the machine to boot)

맑은안개 2023. 4. 5. 12:47

아래의 Vagrantfile 구동시 Timed out while waiting for the machine to boot 오류 발생.

사용된 이미지는 ubuntu/focal64 ( 20.04 LTS ) 이다.

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

Vagrant.configure("2") do |config|
    N = 3 # max number of master redis

    (1..N).each do |i|
        config.vm.define "m#{i}-redis" do |cfg|
            cfg.vm.box = "ubuntu/focal64"
            cfg.vm.provider "virtualbox" do |vb|
                vb.name = "m#{i}-redis(KRS-system)"
                vb.cpus = 2
                vb.memory = 2048
                vb.customize ["modifyvm", :id, "--groups", "/KRS-system"]
                vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
                vb.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
            end
            cfg.vm.host_name = "m#{i}-redis"
            cfg.vm.network "private_network", ip: "192.168.1.1#{i}"
            cfg.vm.network "forwarded_port", guest: 22, host: "6020#{i}", auto_correct: true, id: "ssh"
            cfg.vm.synced_folder "../data", "/vagrant", disabled: true
            cfg.vm.provision "shell", path: "config.sh", args: N
            cfg.vm.provision "shell", path: "install_pkg.sh"
        end
    end
end

오류 내용

==> m1-redis: Running 'pre-boot' VM customizations...
==> m1-redis: Booting VM...
==> m1-redis: Waiting for machine to boot. This may take a few minutes...
    m1-redis: SSH address: 127.0.0.1:60201
    m1-redis: SSH username: vagrant
    m1-redis: SSH auth method: private key
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

다음의 가사머신 옵션을 추가하여 문제 해결

Vagrant.configure("2") do |config|
    N = 3 # max number of master redis

    (1..N).each do |i|
        config.vm.define "m#{i}-redis" do |cfg|
            cfg.vm.box = "ubuntu/focal64"
            cfg.vm.provider "virtualbox" do |vb|
                vb.name = "m#{i}-redis(KRS-system)"
                vb.cpus = 2
                vb.memory = 2048
                vb.customize ["modifyvm", :id, "--groups", "/KRS-system"]
                vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
                vb.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
            end
            cfg.vm.host_name = "m#{i}-redis"
            cfg.vm.network "private_network", ip: "192.168.1.1#{i}"
            cfg.vm.network "forwarded_port", guest: 22, host: "6020#{i}", auto_correct: true, id: "ssh"
            cfg.vm.synced_folder "../data", "/vagrant", disabled: true
            cfg.vm.provision "shell", path: "config.sh", args: N
            cfg.vm.provision "shell", path: "install_pkg.sh"
        end
    end
end

vb.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
vb.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]

위 코드 추가 후 해결

 

반응형