首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于Ubuntu0.8连接问题的虚拟盒复制集设置MongoDB

基于Ubuntu0.8连接问题的虚拟盒复制集设置MongoDB
EN

Server Fault用户
提问于 2011-09-21 13:48:38
回答 2查看 1.8K关注 0票数 1

我正在我的服务器CentOS5.6上构建一个mongo副本集,它将从5 VB中安装Ubuntu 8.10和mongodb。主要的问题是我无法连接到虚拟盒上的mongo。

网络是通过NAT与转发端口建立的。

我有Ubuntu8.1的形象。下面是我创建一个盒子的方式

代码语言:javascript
复制
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"

而不是使用vboxtool转发端口。

代码语言:javascript
复制
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

因此,现在我可以通过ssh这样访问我的vbox:

代码语言:javascript
复制
ssh -p 2023 localhost

我还可以在localhost上访问apache :8083或在http://localhost:8083/munin/index.html上访问munin。

问题是我不能访问芒果。

我的mongo.conf

代码语言:javascript
复制
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

所以,当我试图连接到芒果时,我得到:

代码语言:javascript
复制
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

或者:

代码语言:javascript
复制
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

这是我的蒙戈登入虚拟盒

代码语言:javascript
复制
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

,谢谢你的帮助,我真的被困在这里了。

Marek.B

EN

回答 2

Server Fault用户

发布于 2012-03-17 23:17:33

检查您的mongodb.conf (在ubuntu: /etc/mongodb.conf上,不确定CentOS上的位置),看看是否:

代码语言:javascript
复制
bind_ip = 127.0.0.1

如果是,请用“#”对这一行进行注释:

代码语言:javascript
复制
#bind_ip = 127.0.0.1

请注意,这可能会对安全产生影响。

票数 3
EN

Server Fault用户

发布于 2011-11-03 16:51:26

我不知道这是怎么回事,但这对我来说确实很突出

代码语言:javascript
复制
getaddrinfo("127:0.0.1")

不是127.0.0.1吗?

票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/313917

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档