Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongoshake用户权限 #9

Closed
Roarain opened this issue Jul 19, 2018 · 11 comments
Closed

mongoshake用户权限 #9

Roarain opened this issue Jul 19, 2018 · 11 comments

Comments

@Roarain
Copy link

Roarain commented Jul 19, 2018

mongodb没有做username:password时,rs-->standalone,sharding-->sharding已经同步成功。
使用权限后,createUser参数是
{
user: "shake",
pwd: "shake",
roles: [
{ role: "readWrite", db: "mongoshake" },
{ role: "readWrite", db: "pri" },
{ role: "read", db: "local" },
{ role: "read", db: "admin" },
"clusterMonitor",
]
}
启动mongoshake时提示Oplog Tailer initialize failed: worker initialize error.
查看代码,到了
w := NewWorker(coordinator, syncer, uint32(i))
if !w.init() {
return errors.New("worker initialize error")
}
继续查看源码
func NewWorker(coordinator *ReplicationCoordinator, syncer *OplogSyncer, id uint32) *Worker {
return &Worker{
coordinator: coordinator,
syncer: syncer,
id: id,
queue: make(chan []*oplog.GenericOplog, conf.Options.WorkerBatchQueueSize),
}
}
image
type GenericOplog struct {
Raw []byte
Parsed *PartialLog
}

type PartialLog struct {
Timestamp bson.MongoTimestamp bson:"ts"
Operation string bson:"op"
Gid string bson:"g"
Namespace string bson:"ns"
Object bson.M bson:"o"
Query bson.M bson:"o2"
UniqueIndexes bson.M bson:"uk"

到这,不知道怎么找错误。
能否帮忙看看是什么问题,谢谢。
我的邮箱是wangxiaoyu@sensoro.com welovewxy@gmail.com

@vinllen
Copy link
Collaborator

vinllen commented Jul 20, 2018

请给出一下你的配置文件信息,和错误的全部log信息。另外,代码有改过吗?前后不一样的信息只是添加了账号?

@Roarain
Copy link
Author

Roarain commented Jul 20, 2018 via email

@vinllen
Copy link
Collaborator

vinllen commented Jul 20, 2018

报错的log信息给出一下,以及你邮件里说的循环风暴的日志。

@vinllen
Copy link
Collaborator

vinllen commented Jul 21, 2018

目的数据在变应该是在同步,同步Insert的oplog就添加,delete的就删除,等全部同步完你看看是否还在变。
delete failed应该是之前的数据没了,再次删除旧出错了。在v.1.0.0应该是修复了这个问题。
使用账号密码报的这个错误应该是配置问题,tunnel的目的配的不对,你再发一遍mongoshake刚起来的时候报的错误吧。

@Roarain
Copy link
Author

Roarain commented Jul 23, 2018

src端rs的权限如之前,但是dst端rs的权限没有测试出来,暂时在dst端没有做权限控制。
做测试rs-->rs,sh-->sh,sh-->stadnalone,rs-->standalone时由于oplog的时间窗口未覆盖,获取到的所有数据都正常。
在一个实时有insert和delete业务的的mongoDB上做实时数据同步,时间轴A--B--C--D。在A时刻对src端做的全库mongodump,加上了--oplog选项,B时刻mongodump完成。C时刻dst端mongorestore完成,启动mongo-shake时参数context.start_position应该设置为多少?B时刻?精确到秒,数据也可能缺失。当前测试时给的是A时刻,有些数据重复,在src端有4条数据,但是dst端有12条。一个笨方法,只能对src端做停机备份和数据同步?请问是否有别的方法?觉得这是一个典型的数据备份问题,想要不宕机的实时同步还是宕机下的数据完整性。

@Roarain
Copy link
Author

Roarain commented Jul 23, 2018

应该是找到原因了。同事做了drop操作,但使用mongoshake时只开启了IDU操作,replayer.dml_only = true。另外由于oplog是幂等的,从哪开始都一样。再做一次同步试试。

@vinllen
Copy link
Collaborator

vinllen commented Jul 23, 2018

对于DML是幂等的,DDL的重试不能保证幂等性

@Roarain
Copy link
Author

Roarain commented Jul 24, 2018

在测试过程中又两个疑惑。
1:src端在admin上createUser,src的oplog中有记录,但是没有同步到dst端,是否因为mongoshake不同步admin DB?
image
2:src到dst的oplog传输间隔。参数checkpoint.interval = 20还是batch_size控制。
image
根据bin/mongoshake-stat --port=9100获取到的数据,大概是凑够255条数据在dst端统一应用oplog。能否设置成3秒同步一次,无论是否到255条数据

@vinllen
Copy link
Collaborator

vinllen commented Jul 25, 2018

  1. admin表不同步
  2. checkpoint.interval单位是ms,默认5000ms也就是5s。也就是说最小的同步checkpoint是5s。batch数据是批量传送的,存在缓存机制,batch数据传送后才会触发刷新操作。目前没法做到固定时间刷一次。

@vinllen
Copy link
Collaborator

vinllen commented Jul 25, 2018

非标题相关问题建议多开一个issue,方便后人定位。这个问题我先关了。

@vinllen vinllen closed this as completed Jul 25, 2018
@marknewmail
Copy link

mongos启用权限时,每一个节点都要加账号,否则会报no oplog ns in mongo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants