阿里云mongodb 添加地理位置索引的心酸路。

前景提要:我们公司在aliyun 购买一台mongodb 服务,最近在项目中需要使用到地理位置排序功能。


1、登入阿里云DMS ,进入查询窗口,执行地理索引创建指令

db.home_store.ensureIndex( { loc : "2dsphere" } ) 

阿里云DMS 提示如下信息:

"Sorry this function is deprecated, and DMS do not support . Please use db.collection.createIndex()"

效果截图:



2、资讯阿里云售后服务,给出的解决答案:


根据阿里云 售后服务给出的答案,只能通过公网服务器,连接mongodb shell 创建地理位置索引。


3、我使用了一台公司在公网的服务器(CentOS6.5),下载mongodb 客户端,进行mongodb 的shell 连接,但是问题又接踵而至:

[root@iZ94qawymalZ bin]# ./mongo --host dds-wz9fc7e1efae1c**.mongodb.rds.aliyuncs.com:3717 -u *** -p **** --authenticationDatabase admin
MongoDB shell version: 2.4.9
connecting to: dds-wz9fc7e1efae1c841.mongodb.rds.aliyuncs.com:3717/test
Thu Nov 10 10:13:12.040 Error: 18 { ok: 0.0, errmsg: "auth failed", code: 18 } at src/mongo/shell/db.js:228
exception: login failed
根据上面的反馈信息,我们可以清楚的看出:连接mongodb 认证失败。

啊,悲催!!!!!!!


4、再次在阿里云工单服务中发起紧急工单,这次阿里的售后服务,等的我花开花落好久,不过最后,售后的帅哥靓妹们还是给出了相关解决答案:


给出这样的答案,我吐血了,我使用的是mongodb 2.4.9 版本客户端,心里油然升起(日*******************),没办法,只能将mongodb 的版本由2.4.9提升3.4.2.


5、给出我在公网服务器(centos)连接mongodb shell 的指令代码:

[root@iZ94qawymalZ local]# cd mongodb
[root@iZ94qawymalZ mongodb]# ls -a
.  ..  bin  GNU-AGPL-3.0  MPL-2  README  THIRD-PARTY-NOTICES
[root@iZ94qawymalZ mongodb]# cd bin
[root@iZ94qawymalZ bin]# ./mongo --host dds-wz9fc7e1efae1c***.mongodb.rds.aliyuncs.com:3717 --authenticationDatabase admin -u ** -p ****
MongoDB shell version: 3.2.1
connecting to: dds-wz9fc7e1efae1c***.mongodb.rds.aliyuncs.com:3717/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
mgset-2066113:PRIMARY> show dbs;
admin         0.000GB
local         0.088GB
wgbj_db       0.050GB
wlsq_db_main  0.011GB
mgset-2066113:PRIMARY> use wgbj_db
switched to db wgbj_db
mgset-2066113:PRIMARY> show collections;
homeDeviceLog
homeDeviceReport
homeGatewayMongodb
homeUserMsg
home_store
system.profile
waterFlowDay
waterFlowWeek
mgset-2066113:PRIMARY> db.home_store.ensureIndex( { loc : "2dsphere" } ) 
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
mgset-2066113:PRIMARY> use admin
switched to db admin
mgset-2066113:PRIMARY> db.home_store.ensureIndex( { loc : "2dsphere" } )
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
mgset-2066113:PRIMARY> shwo dbs
2016-11-10T11:25:02.068+0800 E QUERY    [thread1] SyntaxError: missing ; before statement @(shell):1:5

mgset-2066113:PRIMARY> show dbs;
admin         0.000GB
local         0.088GB
wgbj_db       0.050GB
wlsq_db_main  0.011GB
mgset-2066113:PRIMARY> use wlsq_db_main
switched to db wlsq_db_main
mgset-2066113:PRIMARY> show collections
homeDeviceLog
homeGatewayMongodb
homeUserMsg
home_store
system.profile
mgset-2066113:PRIMARY> wlsq_db_main.home_store.ensureIndex({ loc:"2dsphere"})
2016-11-10T11:27:35.037+0800 E QUERY    [thread1] ReferenceError: wlsq_db_main is not defined :
@(shell):1:1


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值