关于OpenLRW部署到mongo docker实例的exception

解决了:

我必须运行泊坞窗图像没有 – 真…

$ docker run -ti --rm -p 30000:27017 -v /srv/mongo:/data/db -e MONGOD_OPTIONS='--nojournal --smallfiles --noprealloc' arkadi/mongodb /sbin/my_init -- bash -l 

我有一个需求来实现一个学习logging存储(LRS)能够使用java或scala将数据保存到cassandra实例中。 我已经find了这个项目, https://github.com/Apereo-Learning-Analytics-Initiative/OpenLRW它使用mongo 2.6作为主后端,它是用java8和spring-boot编写的。

它看起来是一个很好的起点,我只需要将cassandra集成为新的依赖关系,构build一些连接器,但是当我尝试第一次运行时,我收到一个exception:

 Caused by: com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized for query on test.tenant' on server 172.17.0.3:27017 at com.mongodb.connection.ProtocolHelper.getQueryFailureException(ProtocolHelper.java:131) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:303) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:54) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) at com.mongodb.connection.DefaultServerConnection.query(DefaultServerConnection.java:209) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:496) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:482) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:239) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212) at com.mongodb.operation.FindOperation.execute(FindOperation.java:482) at com.mongodb.operation.FindOperation.execute(FindOperation.java:79) at com.mongodb.Mongo.execute(Mongo.java:772) at com.mongodb.Mongo$2.execute(Mongo.java:759) at com.mongodb.DBCollection.findOne(DBCollection.java:777) at com.mongodb.DBCollection.findOne(DBCollection.java:747) at com.mongodb.DBCollection.findOne(DBCollection.java:694) at org.springframework.data.mongodb.core.MongoTemplate$FindOneCallback.doInCollection(MongoTemplate.java:2143) at org.springframework.data.mongodb.core.MongoTemplate$FindOneCallback.doInCollection(MongoTemplate.java:2127) at org.springframework.data.mongodb.core.MongoTemplate.executeFindOneInternal(MongoTemplate.java:1901) ... 165 more 

这是完整的堆栈跟踪

我这样运行mongo实例:

 $ docker run -ti --rm -p 30000:27017 -v /srv/mongo:/data/db -e MONGOD_OPTIONS='--nojournal --smallfiles --noprealloc --auth' arkadi/mongodb /sbin/my_init -- bash -l *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh... No SSH host key available. Generating one... Creating SSH2 RSA key; this may take some time ... Creating SSH2 DSA key; this may take some time ... Creating SSH2 ECDSA key; this may take some time ... Creating SSH2 ED25519 key; this may take some time ... invoke-rc.d: policy-rc.d denied execution of restart. *** Running /etc/my_init.d/90_mongo-admin.sh... *** Running /etc/rc.local... *** Booting runit daemon... *** Runit started as PID 95 *** Running bash -l... note: noprealloc may hurt performance in many applications root@4b190dded9e7:/# 2017-09-14T13:51:29.119+0000 [initandlisten] MongoDB starting : pid=103 port=27017 dbpath=/data/db 64-bit host=4b190dded9e7 2017-09-14T13:51:29.119+0000 [initandlisten] db version v2.6.7 2017-09-14T13:51:29.119+0000 [initandlisten] git version: a7d57ad27c382de82e9cb93bf983a80fd9ac9899 2017-09-14T13:51:29.119+0000 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49 2017-09-14T13:51:29.119+0000 [initandlisten] allocator: tcmalloc 2017-09-14T13:51:29.119+0000 [initandlisten] options: { security: { authorization: "enabled" }, storage: { journal: { enabled: false }, preallocDataFiles: false, smallFiles: true } } 2017-09-14T13:51:29.125+0000 [initandlisten] waiting for connections on port 27017 Sep 14 13:51:29 4b190dded9e7 syslog-ng[105]: syslog-ng starting up; version='3.5.3' root@4b190dded9e7:/# mongo MongoDB shell version: 2.6.7 connecting to: test 2017-09-14T13:51:47.087+0000 [initandlisten] connection accepted from 127.0.0.1:47862 #1 (1 connection now open) 2017-09-14T13:51:47.087+0000 [conn1] note: no users configured in admin.system.users, allowing localhost access Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ ... 

mongo docker实例的ip是:

 root@4b190dded9e7:/# ifconfig eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:03 inet addr:**172.17.0.3** Bcast:0.0.0.0 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:28 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4500 (4.5 KB) TX bytes:0 (0.0 B) 

我可以从我的本地主机到达这个docker实例:

 $ ping 172.17.0.2 PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data. 64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.045 ms 64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.040 ms 64 bytes from 172.17.0.2: icmp_seq=3 ttl=64 time=0.041 ms 64 bytes from 172.17.0.2: icmp_seq=4 ttl=64 time=0.044 ms 64 bytes from 172.17.0.2: icmp_seq=5 ttl=64 time=0.043 ms 

这是它看起来我的实际application.yaml文件:

 # different mongo instance running within a docker container spring.data.mongodb.host: 172.17.0.3 spring.data.mongodb.port: 27017 server.port: 9966 spring.profiles: default matthews.security.jwt: tokenExpirationTime: 240 # Number of minutes refreshTokenExpTime: 360 # Minutes tokenIssuer: http://example.com tokenSigningKey: changeme endpoints: enabled: false info: enabled: true info: build: artifact: @project.artifactId@ name: @project.name@ description: @project.description@ version: @project.version@ matthews.users: encrypted: false adminuser : ${random.value} password: ${random.value} emailAddress: ${random.value}@unicon.net 

我用下一个命令运行该项目:

 `mvn clean package spring-boot:run` 

看起来我必须在运行jar文件之前在mongo实例中做其他事情,isnt?

非常感谢你。

它看起来你正在尝试连接到你的使用身份validation没有用户名和密码的mongodb实例。

你应该试试 :

  • 将用户名和密码提供给您的configuration文件以提供凭据
  • 如果是开发环境,请禁用authentication并testing您的应用程序连接到mongod实例