Browse Source

修改双向同步问题

rz 1 year ago
parent
commit
797c4419d3
4 changed files with 64 additions and 11 deletions
  1. 3 3
      config.yaml
  2. 5 5
      config_n.yaml
  3. 51 0
      config_on.yaml
  4. 5 3
      main.go

+ 3 - 3
config.yaml

@@ -13,7 +13,7 @@ ses:
 #目标端配置
 des:
   addr: "http://127.0.0.1:19902"
-  index: "bidding_v1"
+  index: "bidding_temp"
   stype: "bidding"
   #当需要指定同步字段时要使用,比如同步到未登录用户只需要个别字段,同步全部字段请注释此行
   #fields: ["are","autoid","bidamount","bidstatus","budget","buyer","buyerclass","city","comeintime","createtime","dataweight","detail","district","entidlist","href","id","multipackage","pici","projectcode","publishtime","s_subscopeclass","s_topscopeclass","site","subtype","title","topscopeclass","toptype"]
@@ -23,8 +23,8 @@ des:
 
 # id支持时间19位格式和id24位格式---------id支持两种模式,不能混合使用
 #gtid: "650ea35ce17a7c80fbe231ed"
-gtid: "2023-09-24 00:10:00"
-lteid: "2023-09-25 11:50:00"
+gtid: "2023-09-25 20:10:00"
+lteid: "2023-09-26 08:20:00"
 #lteid: "650eb13de2d7d34fa0415373"
 
 #同步模式mode  1是初始模式源到目标  2双向同步   3是定时源到目标模式  4双向定时

+ 5 - 5
config_n.yaml

@@ -7,20 +7,20 @@ ses:
   size: 2
 des:
   addr: "http://127.0.0.1:19902"
-  index: "bidding_temp"
+  index: "bidding_y1"
   stype: "bidding"
   user: "jybid"
   pwd: "Top2023_JEB01i@31"
-  #fields: ["are","autoid","bidamount","bidstatus","budget","buyer","buyerclass","city","comeintime","createtime","dataweight","detail","district","entidlist","href","id","multipackage","pici","projectcode","publishtime","s_subscopeclass","s_topscopeclass","site","subtype","title","topscopeclass","toptype"]
+  fields: ["are","autoid","bidamount","bidstatus","budget","buyer","buyerclass","city","comeintime","createtime","dataweight","detail","district","entidlist","href","id","multipackage","pici","projectcode","publishtime","s_subscopeclass","s_topscopeclass","site","subtype","title","topscopeclass","toptype"]
   size: 2
 # id支持时间19位格式和id24位格式
-gtid: "2023-08-25 07:00:00"
-lteid: "2023-09-25 10:00:00"
+gtid: "2023-01-01 07:00:00"
+lteid: "2023-09-25 21:00:00"
 # 同步模式mode 1,2是初始模式  3,4定时
 mode: 1
 # 数据连续模式 0默认 1最大id  2比较
 lastmode: 0
-synctest: true 
+synctest: false 
 sync: 
   -
     freq: 60

+ 51 - 0
config_on.yaml

@@ -0,0 +1,51 @@
+#源端配置
+ses:
+  addr: "http://127.0.0.1:9902"
+  #当源和目标不在一个集群中时要使用,确保双方通信正常 
+  sync: "http://192.168.0.229:45008"
+  index: "bidding_v1"
+  stype: "bidding"
+  #可以增加sql,限定数据范围
+  #boolsql: '{"bool":{"must_not":[{"terms":{"toptype":["采购意向","拟建"]}}]}}'
+  user: "es_all"
+  pwd: "TopJkO2E_d1x"
+  size: 3
+#目标端配置
+des:
+  addr: "http://127.0.0.1:19902"
+  index: "bidding_temp"
+  stype: "bidding"
+  #当需要指定同步字段时要使用,比如同步到未登录用户只需要个别字段,同步全部字段请注释此行
+  #fields: ["are","autoid","bidamount","bidstatus","budget","buyer","buyerclass","city","comeintime","createtime","dataweight","detail","district","entidlist","href","id","multipackage","pici","projectcode","publishtime","s_subscopeclass","s_topscopeclass","site","subtype","title","topscopeclass","toptype"]
+  user: "jybid"
+  pwd: "Top2023_JEB01i@31"
+  size: 3
+
+# id支持时间19位格式和id24位格式---------id支持两种模式,不能混合使用
+#gtid: "650ea35ce17a7c80fbe231ed"
+gtid: "2023-09-25 00:00:00"
+lteid: "2023-09-25 20:00:00"
+#lteid: "650eb13de2d7d34fa0415373"
+
+#同步模式mode  1是初始模式源到目标  2双向同步   3是定时源到目标模式  4双向定时
+mode: 1
+# 数据连续模式 0默认 1最大id  2比较
+lastmode: 0
+# 空跑输出差异结果,不同步数据,false时表示不空跑且同步数据
+synctest: false 
+# 当为定时模式时,使用sync下的配置,支持多套定时方案,且lastmode使用下面的子配置
+sync: 
+  -
+    # 定时频率,每60秒执行一次
+    freq: 60
+    # 执行时,选定数据截止到10分钟之前
+    before: 600
+    # 数据同步模式,1为最目标端最大id
+    lastmode: 1
+    # 数据范围为数据截止时间的前300秒
+    scope: 300
+  -
+    freq: 3600
+    before: 600
+    lastmode: 2
+    scope: 7200

+ 5 - 3
main.go

@@ -150,9 +150,11 @@ func main() {
 					BinarySearch(Cfg.Ses, Cfg.Des, gid, eid, "atask")
 					log.Println("atask", "over...", "freq", obj.Freq)
 					//-----------------
-					gid1, eid1 := GetIds(gtid, lteid, Cfg.Ses, obj.Lastmode)
-					BinarySearch(Cfg.Des, Cfg.Ses, gid1, eid1, "atask")
-					log.Println("btask", "over...", "freq", obj.Freq)
+					if Cfg.Mode == 4 {
+						gid1, eid1 := GetIds(gtid, lteid, Cfg.Ses, obj.Lastmode)
+						BinarySearch(Cfg.Des, Cfg.Ses, gid1, eid1, "atask")
+						log.Println("btask", "over...", "freq", obj.Freq)
+					}
 					last := nt - time.Now().Unix()
 					if last > 0 {
 						time.Sleep(time.Second * time.Duration(last))