Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to build a mongo replica set on my server, Centos 5.6, that would be setup from 5 VB holding Ubuntu 8.10 and mongodb. The main problem is i can't connect to mongo on virtual box.

The network is setup over NAT with forwarded ports.

I have my image of Ubuntu 8.1. Below the way I create a box

VBoxManage createvm --name "mongovb_03" --ostype Ubuntu --register
VBoxManage modifyvm "mongovb_03" --memory 2048 --acpi on --boot1 dvd --nic1 nat
VBoxManage modifyvm "mongovb_03" --pae on --cpus 2 
VBoxManage storagectl "mongovb_03" --name "SATA Controller" --add sata --controller IntelAhci
VBoxManage storageattach "mongovb_03" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "ubuntu_8.vdi"

Than I forward port using vboxtool.

Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-2003-2812/GuestPort, Value: 2812
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-2003-2812/HostPort, Value: 2003
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-2003-2812/Protocol, Value: TCP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-2023-22/GuestPort, Value: 22
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-2023-22/HostPort, Value: 2023
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-2023-22/Protocol, Value: TCP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-27003-27017/GuestPort, Value: 27017
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-27003-27017/HostPort, Value: 27003
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-27003-27017/Protocol, Value: TCP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-28003-28017/GuestPort, Value: 28017
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-28003-28017/HostPort, Value: 28003
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-28003-28017/Protocol, Value: TCP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-8083-80/GuestPort, Value: 80
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-8083-80/HostPort, Value: 8083
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-tcp-8083-80/Protocol, Value: TCP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-2003-2812/GuestPort, Value: 2812
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-2003-2812/HostPort, Value: 2003
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-2003-2812/Protocol, Value: UDP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-2023-22/GuestPort, Value: 22
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-2023-22/HostPort, Value: 2023
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-2023-22/Protocol, Value: UDP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-27003-27017/GuestPort, Value: 27017
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-27003-27017/HostPort, Value: 27003
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-27003-27017/Protocol, Value: UDP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-28003-28017/GuestPort, Value: 28017
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-28003-28017/HostPort, Value: 28003
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-28003-28017/Protocol, Value: UDP
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-8083-80/GuestPort, Value: 80
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-8083-80/HostPort, Value: 8083
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/vboxtool-udp-8083-80/Protocol, Value: UDP

So now I can have access my vbox via ssh like that:

ssh -p 2023 localhost

I can also access my apache on localhost:8083 or munin on http://localhost:8083/munin/index.html

The problem is that I can't access mongo.

My mongo.conf

dbpath=/var/lib/mongodb

#where to log
logpath=/var/log/mongodb/mongodb.log

 logappend=true

 port=27017
 journal=true
 bind_ip=127.0.0.1

So when I try to connect to mongo I get:

mongo 127:0.0.1:27003
MongoDB shell version: 1.8.1
connecting to: 127:0.0.1:27003/test
Wed Sep 21 14:33:31 getaddrinfo("127:0.0.1") failed: nodename nor servname provided, or         not known
Wed Sep 21 14:33:31 Error shell/mongo.js:81
exception: connect failed

Or:

mongo localhost:27003
MongoDB shell version: 1.8.1
connecting to: localhost:27003/test
Wed Sep 21 14:34:04 DBClientCursor::init call() failed
Wed Sep 21 14:34:04 terminate() called in shell, printing stack:
0x2947 0x960d717a 0x960d71ba 0x960d72b8 0xbd752 0xe651d 0xf0777 0x2c9a0 0x14b0e4     0x1c960f 0x1cae2b 0x1d4e93 0x1c9fe5 0x18b379 0x18b2d0 0x18b1da 0x15598f 0x214da 0x13b979 0x9b82 
 0   mongo                               0x00002947 _Z11myterminatev + 103
 1   libstdc++.6.dylib                   0x960d717a _ZN10__cxxabiv111__terminateEPFvvE + 10
 2   libstdc++.6.dylib                   0x960d71ba _ZN10__cxxabiv112__unexpectedEPFvvE + 0
 3   libstdc++.6.dylib                   0x960d72b8 _ZL23__gxx_exception_cleanup19_Unwind_Reason_CodeP17_Unwind_Exception + 0
 4   mongo                               0x000bd752 _ZN5mongo9uassertedEiPKc + 210
 5   mongo                               0x000e651d _ZN5mongo17DBClientInterface7findOneERKSsRKNS_5QueryEPKNS_7BSONObjEi + 1325
 6   mongo                               0x000f0777 _ZN5mongo20DBClientWithCommands10runCommandERKSsRKNS_7BSONObjERS3_i + 119
 7   mongo                               0x0002c9a0 _ZN5mongo10shellUtils9onConnectERNS_20DBClientWithCommandsE + 496
 8   mongo                               0x0014b0e4 _ZN5mongo26mongo_external_constructorEP9JSContextP8JSObjectjPlS4_ + 388
 9   mongo                               0x001c960f js_Invoke + 3275
 10  mongo                               0x001cae2b js_InvokeConstructor + 702
 11  mongo                               0x001d4e93 js_Interpret + 40685
 12  mongo                               0x001c9fe5 js_Execute + 774
 13  mongo                               0x0018b379 JS_EvaluateUCScriptForPrincipals + 167
 14  mongo                               0x0018b2d0 JS_EvaluateUCScript + 67
 15  mongo                               0x0018b1da JS_EvaluateScript + 108
 16  mongo                               0x0015598f _ZN5mongo7SMScope4execERKNS_10StringDataERKSsbbbi + 511
 17  mongo                               0x000214da _ZN5mongo10shellUtils9initScopeERNS_5ScopeE + 282
 18  mongo                               0x0013b979 _ZN5mongo12ScriptEngine8newScopeEv + 41
 19  mongo                               0x00009b82 _Z5_mainiPPc + 4850

And this is my mongo log on virtual box:

cat mongodb.log
Wed Sep 21 14:12:51 [initandlisten] MongoDB starting : pid=5033 port=27017 dbpath=/var/lib/mongodb 64-bit 
Wed Sep 21 14:12:51 [initandlisten] db version v1.8.3, pdfile version 4.5
Wed Sep 21 14:12:51 [initandlisten] git version: c206d77e94bc3b65c76681df5a6b605f68a2de05
Wed Sep 21 14:12:51 [initandlisten] build sys info: Linux bs-linux64.10gen.cc 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_41
Wed Sep 21 14:12:51 [initandlisten] journal dir=/var/lib/mongodb/journal
Wed Sep 21 14:12:51 [initandlisten] recover : no journal files present, no recovery needed
Wed Sep 21 14:12:51 [initandlisten] waiting for connections on port 27017
Wed Sep 21 14:12:51 [websvr] web admin interface listening on port 28017
Wed Sep 21 14:13:51 [dur] lsn set 59540
Wed Sep 21 14:14:51 [dur] lsn set 119480
Wed Sep 21 14:15:45 [initandlisten] connection accepted from 127.0.0.1:48081 #1
Wed Sep 21 14:15:45 [conn1] end connection 127.0.0.1:48081
Wed Sep 21 14:15:51 [dur] lsn set 179021
Wed Sep 21 14:16:51 [dur] lsn set 238991
Wed Sep 21 14:17:02 [initandlisten] connection accepted from 127.0.0.1:48082 #2
Wed Sep 21 14:17:08 [conn2] end connection 127.0.0.1:48082
Wed Sep 21 14:17:51 [dur] lsn set 298802
Wed Sep 21 14:18:45 [initandlisten] connection accepted from 127.0.0.1:55467 #3
Wed Sep 21 14:18:45 [conn3] end connection 127.0.0.1:55467
Wed Sep 21 14:18:51 [dur] lsn set 358133
Wed Sep 21 14:19:51 [dur] lsn set 418033
Wed Sep 21 14:20:51 [dur] lsn set 477573
Wed Sep 21 14:21:45 [initandlisten] connection accepted from 127.0.0.1:55478 #4
Wed Sep 21 14:21:45 [conn4] end connection 127.0.0.1:55478
Wed Sep 21 14:21:51 [dur] lsn set 537524
Wed Sep 21 14:22:51 [dur] lsn set 597514
Wed Sep 21 14:23:51 [dur] lsn set 657484
Wed Sep 21 14:24:45 [initandlisten] connection accepted from 127.0.0.1:53699 #5
Wed Sep 21 14:24:45 [conn5] end connection 127.0.0.1:53699
Wed Sep 21 14:24:51 [dur] lsn set 717465
Wed Sep 21 14:25:51 [dur] lsn set 777015
Wed Sep 21 14:26:51 [dur] lsn set 836945
Wed Sep 21 14:27:45 [initandlisten] connection accepted from 127.0.0.1:53710 #6
Wed Sep 21 14:27:45 [conn6] end connection 127.0.0.1:53710
Wed Sep 21 14:27:51 [dur] lsn set 896856
Wed Sep 21 14:28:51 [dur] lsn set 956696
Wed Sep 21 14:29:51 [dur] lsn set 1016546
Wed Sep 21 14:30:45 [initandlisten] connection accepted from 127.0.0.1:42644 #7
Wed Sep 21 14:30:45 [conn7] end connection 127.0.0.1:42644
Wed Sep 21 14:30:51 [dur] lsn set 1075887
Wed Sep 21 14:31:51 [dur] lsn set 1135717
Wed Sep 21 14:32:51 [dur] lsn set 1195657
Wed Sep 21 14:33:45 [initandlisten] connection accepted from 127.0.0.1:51476 #8
Wed Sep 21 14:33:45 [conn8] end connection 127.0.0.1:51476
Wed Sep 21 14:33:51 [dur] lsn set 1255638
Wed Sep 21 14:34:51 [dur] lsn set 1315568
Wed Sep 21 14:35:51 [dur] lsn set 1375048
Wed Sep 21 14:36:45 [initandlisten] connection accepted from 127.0.0.1:51487 #9
Wed Sep 21 14:36:45 [conn9] end connection 127.0.0.1:51487
Wed Sep 21 14:36:51 [dur] lsn set 1435019
Wed Sep 21 14:37:51 [dur] lsn set 1495029
Wed Sep 21 14:38:51 [dur] lsn set 1555019
Wed Sep 21 14:39:45 [initandlisten] connection accepted from 127.0.0.1:46313 #10
Wed Sep 21 14:39:45 [conn10] end connection 127.0.0.1:46313
Wed Sep 21 14:39:51 [dur] lsn set 1614990
Wed Sep 21 14:40:51 [dur] lsn set 1674480
Wed Sep 21 14:41:51 [dur] lsn set 1734470
Wed Sep 21 14:42:45 [initandlisten] connection accepted from 127.0.0.1:46324 #11
Wed Sep 21 14:42:45 [conn11] end connection 127.0.0.1:46324
Wed Sep 21 14:42:51 [dur] lsn set 1794451

Thanks for all the help, I'm really stuck here.

Marek.B

share|improve this question
add comment

2 Answers

Check you mongodb.conf (on ubuntu: /etc/mongodb.conf, not sure where on CentOS) and see if:

bind_ip = 127.0.0.1

If so, comment that line with "#":

#bind_ip = 127.0.0.1

Note that this may have security repercussions.

share|improve this answer
add comment

I'm not sure what the issue is but this certainly sticks out at me

getaddrinfo("127:0.0.1")

Shouldn't that be 127.0.0.1?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.