나는 첫 번째 Vagrant 상자를 만들었습니다.
vagrant up
상자를 열면 다음 오류가 발생합니다 .
tange/centos3.3 Bringing machine 'default' up with 'virtualbox' provider...
tange/centos3.3 ==> default: Importing base box 'tange/centos3'...
tange/centos3.3 ==> default: Matching MAC address for NAT networking...
tange/centos3.3 ==> default: Setting the name of the VM: centos3_default_1598053704177_14223
tange/centos3.3 ==> default: Fixed port collision for 22 => 2222. Now on port 2203.
tange/centos3.3 ==> default: Clearing any previously set network interfaces...
tange/centos3.3 ==> default: Preparing network interfaces based on configuration...
tange/centos3.3 default: Adapter 1: nat
tange/centos3.3 default: Adapter 2: hostonly
tange/centos3.3 ==> default: Forwarding ports...
tange/centos3.3 default: 22 (guest) => 2203 (host) (adapter 1)
tange/centos3.3 ==> default: Running 'pre-boot' VM customizations...
tange/centos3.3 ==> default: Booting VM...
tange/centos3.3 ==> default: Waiting for machine to boot. This may take a few minutes...
tange/centos3.3 default: SSH address: 127.0.0.1:2203
tange/centos3.3 default: SSH username: vagrant
tange/centos3.3 default: SSH auth method: private key
tange/centos3.3 default:
tange/centos3.3 default: Vagrant insecure key detected. Vagrant will automatically replace
tange/centos3.3 default: this with a newly generated keypair for better security.
tange/centos3.3 default:
tange/centos3.3 default: Inserting generated public key within guest...
tange/centos3.3 default: Removing insecure key from the guest if it's present...
tange/centos3.3 default: Key inserted! Disconnecting and reconnecting using new SSH key...
tange/centos3.3 ==> default: Machine booted and ready!
tange/centos3.3 ==> default: Checking for guest additions in VM...
tange/centos3.3 default: The guest additions on this VM do not match the installed version of
tange/centos3.3 default: VirtualBox! In most cases this is fine, but in rare cases it can
tange/centos3.3 default: prevent things such as shared folders from working properly. If you see
tange/centos3.3 default: shared folder errors, please make sure the guest additions within the
tange/centos3.3 default: virtual machine match the version of VirtualBox you have installed on
tange/centos3.3 default: your host and reload your VM.
tange/centos3.3 default:
tange/centos3.3 default: Guest Additions Version: 4.3.8
tange/centos3.3 default: VirtualBox Version: 6.1
tange/centos3.3 ==> default: Configuring and enabling network interfaces...
tange/centos3.3 The following SSH command responded with a non-zero exit status.
tange/centos3.3 Vagrant assumes that this means the command failed!
tange/centos3.3
tange/centos3.3 /sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'
tange/centos3.3
tange/centos3.3 Stdout from the command:
tange/centos3.3
tange/centos3.3
tange/centos3.3
tange/centos3.3 Stderr from the command:
tange/centos3.3
tange/centos3.3 bash: line 1: ip: command not found
tange/centos3.3 bash: line 1: ifconfig: command not found
시스템에서 찾을 수도 ip
찾을 수도 없는 것 같지만 ifconfig
로그인하면 vagrant
명령이 제대로 작동합니다. 내가 실행하면 :
/sbin/ip -o -0 addr | grep -v LOOPBACK | awk '{print $2}' | sed 's/://'
네트워크 인터페이스 목록을 얻었습니다.
그렇다면 수동으로 실행하면 작동하지만 Vagrant로 실행하려고 하면 작동하지 않는 이유는 무엇입니까?
이런 일이 발생하지 않도록 상자를 교체하려면 어떻게 해야 합니까?
방황하는 파일:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "tange/centos3"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "172.27.27.3"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "512"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell" do |s|
ssh_pub_key = File.readlines("../../authorized_keys").first.strip
s.inline = <<-SHELL
mkdir /root/.ssh
echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
sudo apt install rsync || sudo yum install -y rsync || sudo pkg install -y rsync
SHELL
end
end
$ vagrant --version
Vagrant 2.2.9
답변1
Hashicorp에는 얼마나 많은 리포지토리가 업데이트되더라도 CentOS가 Base Box를 기존 커널로 업데이트하지 않는다는 해결되지 않은 오래된 문제가 있습니다. 문제는 플러그인에 동일한 Box 커널 버전의 패키지가 필요하지만 CentOS가 저장소에서 해당 패키지를 제거했다는 것입니다.
Vagrantfile에서 커널을 업데이트하려면 vbguest 지침을 추가하거나 vagrant-vbguest 플러그인의 이전 버전을 사용해야 합니다.
config.vbguest.installer_options = { allow_kernel_upgrade: true }