Vagrant (1.2.2) VM'yi VistualBox'u 'a ayarlıyorum: private_network ve bir Sinatra sunucusunu başlattım. Ancak o Sinatra örneğine bağlanamıyorum. Bununla birlikte, VM pingleri çalıştırır ve yanıt verir.Vagrant, private_network modunda bağlanmayı reddediyor
İşte
Vagrant.configure("2") do |config|
config.vm.box = "precise64"
config.vm.network :private_network, ip: "192.168.33.10"
end
yüzden
prodserv$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
prodserv$ vagrant ssh
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-23-generic x86_64)
* Documentation: https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Thu May 23 14:01:05 2013 from 10.0.2.2
Yani yukarı tüm iyi, güzel burada içine Serseri VM ve ssh başlamak benim Vagrantfile
olduğunu. VM bir ping iyi çalışır
prodserv$ ping 192.168.33.10
PING 192.168.33.10 (192.168.33.10): 56 data bytes
64 bytes from 192.168.33.10: icmp_seq=0 ttl=64 time=0.543 ms
64 bytes from 192.168.33.10: icmp_seq=1 ttl=64 time=0.328 ms
harika (ben de Yani paket kaybına yol açacaktır serseri yukarı olmadan ping. Bu gerçekten VM'lerin ip olduğunu işaretli)! Şimdi VY'de sunucuyu başlatmak
[email protected]:~$ sudo ruby /vagrant/server.rb
== Sinatra/1.4.2 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:4567, CTRL+C to stop
bu gelen server.rb olan
require 'rubygems'
require 'sinatra'
get '/' do
puts "WOW!"
'Hello, world!'
end
ben Sinatra her şeyi konuk VM Şimdi kıvrılıp eğer "iyi ve çalışır Selam Dünya!" iade edilecek. Ben ana makinede den kıvrılma için çalışırsanız
[email protected]:~$ curl 'http://localhost:4567'
Hello, [email protected]:~$
#and the Sintra/Ruby process gets me this
WOW!
127.0.0.1 - - [23/May/2013 16:06:36] "GET/HTTP/1.1" 200 13 0.0026
Ancak bağlantı reddedildi alır.
prodserv$ curl -v 'http://192.168.33.10:4567'
* About to connect() to 192.168.33.10 port 4567 (#0)
* Trying 192.168.33.10...
* Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
Peki n'aber?
Haklısınız, bir programlama sorusu değil. – robkuz
Vagrantfile'da 4567 için bağlantı noktası yönlendirmeyi açmanız gerekir. Varsayılan olarak, çalışan vm'ye gönderilen tek liman ssh için 22'dir. –