mongooplog失败,未经授权的错误

时间:2014-06-27 14:31:48

标签: mongodb replication

我正在尝试在mongo中将oplog从1个副本集重放到另一个副本集。我收到错误,知道为什么?

mongooplog --from "10.0.0.180:27017"  -h "my_rs/10.0.0.88:27017,10.0.0.88:27018,10.0.0.88:27019" -d my_db -u dbuser -p db_pass
Fri Jun 27 14:24:21 starting new replica set monitor for replica set my_rs with seed of 10.0.0.88:27017,10.0.0.88:27018,10.0.0.88:27019                    
Fri Jun 27 14:24:21 successfully connected to seed 10.0.0.88:27017 for replica set my_rs
Fri Jun 27 14:24:21 changing hosts to { 0: "10.0.0.88:27017", 1: "10.0.0.88:27018" } from my_rs/                                                           
Fri Jun 27 14:24:21 trying to add new host 10.0.0.88:27017 to replica set my_rs
Fri Jun 27 14:24:21 successfully connected to new host 10.0.0.88:27017 in replica set my_rs
Fri Jun 27 14:24:21 trying to add new host 10.0.0.88:27018 to replica set my_rs
Fri Jun 27 14:24:21 successfully connected to new host 10.0.0.88:27018 in replica set my_rs
Fri Jun 27 14:24:21 successfully connected to seed 10.0.0.88:27019 for replica set my_rs
Fri Jun 27 14:24:21 Primary for replica set my_rs changed to 10.0.0.88:27017                                                                               
Fri Jun 27 14:24:21 replica set monitor for replica set my_rs started, address is my_rs/10.0.0.88:27017,10.0.0.88:27018                                  
connected to: my_rs/10.0.0.88:27017,10.0.0.88:27018,10.0.0.88:27019                                                                                        
Fri Jun 27 14:24:21 [ReplicaSetMonitorWatcher] starting                                                                                                      
Fri Jun 27 14:24:21 [oplogreplay] going to connect                                                                                                           
Fri Jun 27 14:24:21 [oplogreplay] connected                                                                                                                  
Fri Jun 27 14:24:21 [oplogreplay] starting from Jun 26 14:24:21:0                                                                                            
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [omongooplog --from "10.0.0.180:27017"  -h "my_rs/10.0.0.88:27017,10.0.0.88:27018,10.0.0.88:27019" -d my_db -u dbuser -p db_pass
Fri Jun 27 14:24:21 starting new replica set monitor for replica set my_rs with seed of 10.0.0.88:27017,10.0.0.88:27018,10.0.0.88:27019                    
Fri Jun 27 14:24:21 successfully connected to seed 10.0.0.88:27017 for replica set my_rs
Fri Jun 27 14:24:21 changing hosts to { 0: "10.0.0.88:27017", 1: "10.0.0.88:27018" } from my_rs/                                                           
Fri Jun 27 14:24:21 trying to add new host 10.0.0.88:27017 to replica set my_rs
Fri Jun 27 14:24:21 successfully connected to new host 10.0.0.88:27017 in replica set my_rs
Fri Jun 27 14:24:21 trying to add new host 10.0.0.88:27018 to replica set my_rs
Fri Jun 27 14:24:21 successfully connected to new host 10.0.0.88:27018 in replica set my_rs
Fri Jun 27 14:24:21 successfully connected to seed 10.0.0.88:27019 for replica set my_rs
Fri Jun 27 14:24:21 Primary for replica set my_rs changed to 10.0.0.88:27017                                                                               
Fri Jun 27 14:24:21 replica set monitor for replica set my_rs started, address is my_rs/10.0.0.88:27017,10.0.0.88:27018                                  
connected to: my_rs/10.0.0.88:27017,10.0.0.88:27018,10.0.0.88:27019                                                                                        
Fri Jun 27 14:24:21 [ReplicaSetMonitorWatcher] starting                                                                                                      
Fri Jun 27 14:24:21 [oplogreplay] going to connect                                                                                                           
Fri Jun 27 14:24:21 [oplogreplay] connected                                                                                                                  
Fri Jun 27 14:24:21 [oplogreplay] starting from Jun 26 14:24:21:0                                                                                            
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 } plogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 }                                                                                                                                             
Fri Jun 27 14:24:21 [oplogreplay] { assertion: "unauthorized db:admin ns:admin lock type:1 client:10.0.0.88", assertionCode: 10057, errmsg: "db assertion failure", ok: 0.0 } 

from参数也是RS(设置noauth=true),但如果我尝试使用" my_rs / 10.0.0.180:27017"它失败了,看起来from参数不能使用RS地址。

用于88上重播的用户名和密码位于admin db和my_db中。

更新

我已升级到2.4.10。升级似乎提供了更有意义的日志记录。在180,我可以连接到本地数据库(没有auth)并执行db.oplog.rs.count()并获得结果(在本地和远程连接上)。但是,当我以180作为from运行mongooplog时,我仍然会收到错误(这是88):

Tue Jul  1 10:16:29.034 [oplogreplay] error getting oplog
Tue Jul  1 10:16:29.034 [oplogreplay] { $err: "not authorized for query on local.oplog.rs", code: 16550 }

我在180的错误日志中看到了类似的错误。

2 个答案:

答案 0 :(得分:1)

您需要将身份验证数据库添加到命令行,因为默认情况下,mongooplog将假定您的用户名和密码凭据适用于您正在应用oplog的数据库。

- authenticationDatabase dbname

  

版本2.4中的新功能。

     

指定保存用户凭据的数据库。如果你这样做   如果没有指定认证数据库,则mongooplog假定

     

指定为--db选项的参数的数据库保存   用户的凭据。

因此,在您的情况下,我会将--authenticationDatabase admin添加到您的命令行。

答案 1 :(得分:0)

Mongooplog似乎在身份验证方面存在问题,而且似乎也不支持过滤dbs进行复制。

我编写了一个工具(gem),允许在两个副本集之间进行复制。它可以在https://github.com/brettcave/mongo-oplogreplay

获得