2015-06-05 1 views
2

Пытается запустить два бродячих экземпляра на одном хосте. Бродяга файлы на первой инстанции не делает ничего особенного с SSH портов:пересылка порта ssh не выполняется при запуске двух экземпляров бродяг с одного и того же хоста?

# 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. 
config.vm.network "forwarded_port", guest: 8080, host: 9080 
config.vm.network "forwarded_port", guest: 8081, host: 9081 
config.vm.network "forwarded_port", guest: 9990, host: 9090 
config.vm.network "forwarded_port", guest: 8983, host: 8983 
config.vm.network "forwarded_port", guest: 8985, host: 8985 
config.vm.network "forwarded_port", guest: 2181, host: 2181 
config.vm.network "forwarded_port", guest: 8002, host: 8002 
# If true, then any SSH connections made will enable agent forwarding. 
# Default value: false 
# config.ssh.forward_agent = true 

И этот экземпляр раскручивается, как и ожидалось:

$ vagrant up 
Bringing machine 'default' up with 'virtualbox' provider... 
==> default: Checking if box 'hashicorp/precise32' is up to date... 
==> default: Resuming suspended VM... 
==> default: Booting VM... 
==> default: Waiting for machine to boot. This may take a few minutes... 
    default: SSH address: 127.0.0.1:2222 
    default: SSH username: vagrant 
    default: SSH auth method: private key 
    default: Warning: Connection refused. Retrying... 
==> default: Machine booted and ready! 

Второй экземпляр перенаправляет порт гостя 22 для размещения 2221:

# 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. 
config.vm.network "forwarded_port", guest: 8080, host: 10080 
config.vm.network "forwarded_port", guest: 80, host: 45678 
config.vm.network "forwarded_port", guest: 9999, host: 10999 
config.vm.network "forwarded_port", guest: 9000, host: 10900 
config.vm.network "forwarded_port", guest: 22, host: 2221 

Но когда он раскручивается, я все еще получаю конфликты на порт 22222:

$ vagrant up 
Bringing machine 'default' up with 'virtualbox' provider... 
==> default: Checking if box 'hashicorp/precise32' is up to date... 
Vagrant cannot forward the specified ports on this VM, since they 
would collide with some other application that is already listening 
on these ports. The forwarded port to 2222 is already in use on the host  
machine. 

To fix this, modify your current projects Vagrantfile to use another 
port. Example, where '1234' would be replaced by a unique host port: 

config.vm.network :forwarded_port, guest: 22, host: 1234 

Sometimes, Vagrant will attempt to auto-correct this for you. In this 
case, Vagrant was unable to. This is usually because the guest machine 
is in a state which doesn't allow modifying port forwarding. 

Итак, у меня было это, с теми же двумя бродячими файлами 3 месяца назад. Похоже, что обновление базовых полей «hashicorp/exact32» было обновлено без соответствующего изменения документации, и изменения в переходе ssh для порта больше не разрешены? Обновление файла config.ssh.port, похоже, потребует изменения основного изображения.

Мысли?

==================================================================================================================================== ==== Update: Запуск 2-й экземпляр (вперед 22 => 2221), то перезарядка производит следующий вывод:

$ vagrant up 
Bringing machine 'default' up with 'virtualbox' provider... 
==> default: Checking if box 'hashicorp/precise32' is up to date... 
==> default: Resuming suspended VM... 
==> default: Booting VM... 
==> default: Waiting for machine to boot. This may take a few minutes... 
default: SSH address: 127.0.0.1:2222 
default: SSH username: vagrant 
default: SSH auth method: private key 
default: Warning: Connection refused. Retrying... 
==> default: Machine booted and ready! 

[email protected] /cygdrive/c/Gui-again 
$ vagrant reload 
==> default: Attempting graceful shutdown of VM... 
==> default: Checking if box 'hashicorp/precise32' is up to date... 
==> default: Clearing any previously set forwarded ports... 
==> default: Clearing any previously set network interfaces... 
==> default: Preparing network interfaces based on configuration... 
    default: Adapter 1: nat 
==> default: Forwarding ports... 
    default: 8080 => 10080 (adapter 1) 
    default: 80 => 45678 (adapter 1) 
    default: 9999 => 10999 (adapter 1) 
    default: 9000 => 10900 (adapter 1) 
    default: 22 => 2221 (adapter 1) 
    default: 22 => 2222 (adapter 1) 
==> default: Booting VM... 
==> default: Waiting for machine to boot. This may take a few minutes... 
    default: SSH address: 127.0.0.1:2222 
    default: SSH username: vagrant 
    default: SSH auth method: private key 
    default: Warning: Connection timeout. Retrying... 
==> default: Machine booted and ready! 
==> default: Checking for guest additions in VM... 
    default: The guest additions on this VM do not match the installed version of 
    default: VirtualBox! In most cases this is fine, but in rare cases it can 
    default: prevent things such as shared folders from working properly. If you see 
    default: shared folder errors, please make sure the guest additions within the 
    default: virtual machine match the version of VirtualBox you have installed on 
    default: your host and reload your VM. 
    default: 
    default: Guest Additions Version: 4.2.0 
    default: VirtualBox Version: 4.3 
==> default: Mounting shared folders... 
    default: /vagrant => C:/OSC/PBD-Gui-again 
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision` 
==> default: to force provisioning. Provisioners marked to run always will still run 

Так где-то SSH порт вынужден 2222. Это не в сам бродячий файл, где еще искать?

ответ

4

Вы можете попробовать добавить в Ид SSH 'до конца

config.vm.network :forwarded_port, guest: 22, host: 2221, id: 'ssh' 

Или, может быть, это работает для вас, чтобы сначала отключить порт SSH (в зависимости от версии Бродячей)

config.vm.network :forwarded_port, guest: 22, host: 2221, id: "ssh", disabled: true 
config.vm.network :forwarded_port, guest: 22, host: 2221, auto_correct: true 

Источник: https://github.com/mitchellh/vagrant/issues/3232

+0

Это сделало. Мне пришлось принести виртуальную машину с переадресованным портом 22, а затем перезагрузить его до того, как произойдут изменения, но я могу жить с этим. Благодаря! – LizH

Смежные вопросы