当我在我的Ubuntu VM上运行mongo时,一切都按预期工作:
fubar@ubuntu:~$ status mongod
mongod start/running, process 31104
fubar@ubuntu:~$ mongo --version
MongoDB shell version: 2.6.0
fubar@ubuntu:~$ mongo
MongoDB shell version: 2.6.0
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
>
bye
wurstworks@ubuntu:~$ mongo --host localhost
MongoDB shell version: 2.6.0
connecting to: localhost:27017/test
>
当我在我的Mac上尝试同样的东西时,使用从自制程序安装的mongod,这真的很奇怪但是mongo与运行mongod具有相同的效果。那就是:
mongodb bin文件夹中的mongo和mongod文件是不同的,但不知何故mongo似乎重定向到mongod!所以看看这个:
fubar@Aerys:~$ ps ax | fgrep -i mongo
57888 s001 S+ 0:00.00 fgrep -i mongo
fubar@Aerys:~$ mongo &
[1] 57889
fubar@Aerys:~$ ps ax | fgrep -i mongo
57889 s001 S 0:00.06 mongod --config /usr/local/etc/mongod.conf
57891 s001 S+ 0:00.00 fgrep -i mongo
fubar@Aerys:~$ mongo --host localhost
Error parsing command line: unknown option host
try 'mongod --help' for more information
fubar@Aerys:~$ mongo --help > mongo.txt
fubar@Aerys:~$ mongod --help > mongod.txt
fubar@Aerys:~$ diff mongo.txt mongod.txt
fubar@Aerys:~$ ls -l /usr/local/Cellar/mongodb/2.6.0_1/bin/mongo /usr/local/Cellar/mongodb/2.6.0_1/bin/mongod
-r-xr-xr-x 1 fubar admin 14726788 Apr 9 05:43 /usr/local/Cellar/mongodb/2.6.0_1/bin/mongo*
-r-xr-xr-x 1 fubar admin 26297460 Apr 9 05:43 /usr/local/Cellar/mongodb/2.6.0_1/bin/mongod*
fubar@Aerys:~$ which mongo
/usr/local/bin/mongo
fubar@Aerys:~$ which mongod
/usr/local/bin/mongod
fubar@Aerys:~$ ls -l /usr/local/bin/mongo
lrwxr-xr-x 1 fubar admin 35 May 4 16:34 /usr/local/bin/mongo@ -> ../Cellar/mongodb/2.6.0_1/bin/mongo
fubar@Aerys:~$ ls -l /usr/local/bin/mongod
lrwxr-xr-x 1 fubar admin 36 May 4 16:34 /usr/local/bin/mongod@ -> ../Cellar/mongodb/2.6.0_1/bin/mongod
fubar@Aerys:~$
在这里你可以看到没有mongod进程在运行。然后我输入mongo并再次检查,这是mongod进程。您还可以看到mongo --host localhost命令失败,这是一个完全合法的命令,在Ubuntu上运行正常。 mongo和mongod文件是不同的,当我输入命令时似乎在正确的时间被调用,但最后mongo正在启动mongod并且我根本没有mongo。
对我来说这是一个非常大的问题,因为我实际上是在尝试从我的Mac mongo客户端连接到Ubuntu mongod服务器。也就是说,我甚至不想在我的Mac上大部分时间都想要mongod,只需要mongo连接到服务器上!
这是自制公式中的错误吗?或者......任何想法?