MergeServerLogic.lua 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. --合服逻辑
  2. --[=[
  3. 0.一般在跨服上进行合服, 所以需要把merge目录下所有文件更新到跨服上
  4. 1.更新MergeServerDefine.MERGE_DB_TB中要合并的数据库, 并备份数据库, 方法见 MergeServerDefine
  5. 2.[可选] 先执行一次start.sh, 再杀掉所有游戏服的进程。因为重启游戏服时会根据条件删除一些数据, 这样合服时要处理的数据就少了一些。
  6. 比较前面的游戏服的邮件数据可能有异常, 可先执行/server/cleanExpireMail.sh清理下异常的邮件(需要修改脚本中数据库范围)
  7. 3.将跨服的bin*文件 的/script 目录下的启动文件Main.lua暂时改为其他名字, MainMerger改为Main.lua,合服完毕后再改回来。
  8. 4.检查MergeServerDefine中的MERGE_DB_TB数据库名是否正确, 如果正确则和正常启动游戏一样启动游戏服, 开始进行合服
  9. 5.查看日志oss_merge, 是否有报错, 如果有报错则还原数据, 恢复见方法见 MergeServerDefine
  10. 6.修改mysql区服列表的 port, dbName, megre_server字段, 被合服的 port 和 dbname 要改为目标服一样, 被合服的 megre_server字段更新为1。
  11. sql见sdk数据库下查询中的updateMergeServerData(需要修改数据库范围)
  12. 7.修改linux上被合服的bin*文件名, 防止 start.sh 启动时会把被合服也启动起来。脚本见/server/changebinName.sh (需要修改脚本中范围)
  13. 8.合服完毕, 将步骤3修过的文件名改回原来的名字, 执行start.sh 启动游戏服。
  14. ]=]
  15. local LuaMongo = _G.lua_mongo
  16. local Config = require("Config")
  17. local Log = require("common.Log")
  18. local MergeServerDefine = require("merge.MergeServerDefine")
  19. local MoZhuExcel = require("excel.mozhu")
  20. local MailExcel = require("excel.mail")
  21. local TowerConfig = require("excel.huanjingTower").huanjingTower
  22. local Util = require("common.Util")
  23. local ItemDefine = require("bag.ItemDefine")
  24. local HuanJingTowerLogic = require("huanjingTower.HuanjingTowerLogic")
  25. local primaryKeyTable = {}
  26. --重复_id缓存表
  27. local repeatIdTb = {}
  28. --目标服和被合服所有玩家的名字缓存表
  29. local allNameTb = {}
  30. --同名数据
  31. local repeatName2Data = {}
  32. local num = 0
  33. --次元魔珠数据缓存表
  34. local mozhuDbCache = { roleList = {}, unionList = {}}
  35. --烟花加成时间
  36. local firesTimeCache = 0
  37. --恶魔之塔最高层数
  38. local towerMaxLevel = 0
  39. local towerHeadCache = {}
  40. local TOWER_LV_HEAD_MAX = HuanJingTowerLogic.TOWER_LV_HEAD_MAX
  41. --创建一个mongo连接实例
  42. local function clientMongoDb(addr)
  43. addr = addr or Config.DB_IP
  44. LuaMongo.client(addr)
  45. end
  46. --切换数据库
  47. local function chooseMongoDb(dbName)
  48. if not dbName or dbName == "" then
  49. print(string.format("数据库名错误, dbName = %s\n", dbName))
  50. return
  51. end
  52. LuaMongo.auth(dbName, Config.DB_USER, Config.DB_PASS)
  53. end
  54. --生成新的 _id
  55. local function generateNewId()
  56. local newId = LuaMongo.id()
  57. return newId
  58. end
  59. --清理部分缓存数据
  60. local function cleanCache()
  61. primaryKeyTable = {}
  62. repeatIdTb = {}
  63. allNameTb = {}
  64. repeatName2Data = {}
  65. mozhuDbCache = { roleList = {}, unionList = {}}
  66. firesTimeCache = 0
  67. towerHeadCache = {}
  68. end
  69. --写日志
  70. local function writeLog(tag, targetDb, sourceDb, sourceColl, info1, info2, docId, errInfo)
  71. local logInfo = string.format("tag: %s, targetDb: %s, sourceDb: %s, sourceColl: %s, info1: %s, info2: %s, docId: %s, errInfo: %s",
  72. tag, targetDb, sourceDb, sourceColl, info1, info2, docId, errInfo)
  73. Log.write(Log.LOGID_OSS_MERGE, logInfo)
  74. end
  75. -------------------------------------------------------------需要单独处理的部分数据---------------------------------------------------------------------
  76. ---------------------------------次元魔蛛/梼杌------------------------------------
  77. local MozhuQueryFiles = { [MergeServerDefine.KEY_CIYUAN_MOZHU] = 1}
  78. --读取
  79. local function loadMoZhuDB(sourceDb, collectionName)
  80. local targetCollection = sourceDb .. collectionName
  81. LuaMongo.find(targetCollection, nil, MozhuQueryFiles)
  82. local data = {}
  83. if not LuaMongo.next(data) then
  84. return nil
  85. end
  86. local targetMoZhuData = data.ciyuanMoZhu
  87. for uuid, roleData in pairs(targetMoZhuData.role or {}) do
  88. mozhuDbCache.roleList[uuid] = roleData
  89. end
  90. for uuid, unionData in pairs(targetMoZhuData.union or {}) do
  91. mozhuDbCache.unionList[uuid] = unionData
  92. num = num + 1
  93. end
  94. end
  95. --随机词条
  96. local function randomCiTiao(data)
  97. local weekTime = Util.getWeekStartTime(os.time())
  98. -- if data.citiaoTime and data.citiaoTime == weekTime then
  99. -- return
  100. -- end
  101. data.citiao = {}
  102. local citiao_rare_max
  103. if not citiao_rare_max then
  104. -- 防止策划删减 词条
  105. citiao_rare_max = 0
  106. for k, v in pairs(MoZhuExcel.citiao) do
  107. if v then
  108. citiao_rare_max = citiao_rare_max + v.quanzhong
  109. end
  110. end
  111. end
  112. local getRare = 0
  113. for i=1, 1 do
  114. local random = math.random(1, citiao_rare_max - getRare)
  115. for k, v in pairs(MoZhuExcel.citiao) do
  116. if not data.citiao[k] and random <= v.quanzhong then
  117. data.citiao[k] = i
  118. getRare = getRare + v.quanzhong
  119. break
  120. elseif not data.citiao[k] then
  121. -- 防止循环最后一个是 已经随机过的 导致 随机不出来
  122. random = random - v.quanzhong
  123. end
  124. end
  125. end
  126. data.citiaoTime = weekTime
  127. end
  128. --初始化魔珠db
  129. local function initMoZhuDB(data)
  130. data.time = os.time()
  131. data.unionRank = {}
  132. data.roleRank = {}
  133. data.role = {}
  134. data.union= {}
  135. --词条
  136. randomCiTiao(data)
  137. end
  138. --插入
  139. local function updateTargetMoZhuDB(targetDb)
  140. local collectionName = MergeServerDefine.COLLECTIONS[3]
  141. local targetCollection = targetDb .. collectionName
  142. LuaMongo.find(targetCollection, nil, MozhuQueryFiles)
  143. local data = {}
  144. if not LuaMongo.next(data) then
  145. return
  146. end
  147. if not data.ciyuanMoZhu then
  148. data.ciyuanMoZhu = {}
  149. initMoZhuDB(data.ciyuanMoZhu)
  150. end
  151. local targetMoZhuData = data.ciyuanMoZhu
  152. local roleRankLen = #targetMoZhuData.roleRank
  153. local unionRankLen = #targetMoZhuData.unionRank
  154. --玩家
  155. for uuid, roleData in pairs(mozhuDbCache.roleList) do
  156. targetMoZhuData.role[uuid] = roleData
  157. roleRankLen = roleRankLen + 1
  158. targetMoZhuData.roleRank[roleRankLen] = uuid
  159. end
  160. --公会
  161. for uuid, unionData in pairs(mozhuDbCache.unionList) do
  162. targetMoZhuData.union[uuid] = unionData
  163. unionRankLen = unionRankLen + 1
  164. targetMoZhuData.unionRank[unionRankLen] = uuid
  165. end
  166. --排序
  167. table.sort(targetMoZhuData.roleRank, function(a, b)
  168. local roleA = targetMoZhuData.role[a]
  169. local roleB = targetMoZhuData.role[b]
  170. return roleA.hurt > roleB.hurt
  171. end)
  172. table.sort(targetMoZhuData.unionRank, function(a, b)
  173. local unionA = targetMoZhuData.union[a]
  174. local unionB = targetMoZhuData.union[b]
  175. if unionA.hurt > unionB.hurt then
  176. return true
  177. elseif unionA.hurt == unionB.hurt then
  178. return unionA.time < unionB.time
  179. end
  180. return false
  181. end)
  182. --更新
  183. LuaMongo.update(targetCollection, {}, {
  184. ["$set"] = {
  185. [MergeServerDefine.KEY_CIYUAN_MOZHU] = targetMoZhuData
  186. },
  187. })
  188. mozhuDbCache = nil
  189. end
  190. ----------------------------------烟花加成时间------------------------------------
  191. local FireQueryFiles = { [MergeServerDefine.KEY_FIREWORKBONUS_TIME] = 1}
  192. --读取
  193. local function loadFireTimeData(sourceDb, collectionName)
  194. local targetCollection = sourceDb .. collectionName
  195. LuaMongo.find(targetCollection, nil, FireQueryFiles)
  196. local data = {}
  197. if not LuaMongo.next(data) then
  198. return nil
  199. end
  200. local now = os.time()
  201. local ti = data.fireWorksBonusTime
  202. if ti and ti > now then
  203. firesTimeCache = firesTimeCache + (ti - now)
  204. end
  205. end
  206. --更新目标库
  207. local function updateTargetFireTimeDB(targetDb)
  208. if firesTimeCache > 0 then
  209. local collectionName = MergeServerDefine.COLLECTIONS[3]
  210. local targetCollection = targetDb .. collectionName
  211. LuaMongo.find(targetCollection, nil, FireQueryFiles)
  212. local data = {}
  213. if not LuaMongo.next(data) then
  214. return
  215. end
  216. local now = os.time()
  217. local ti = data.fireWorksBonusTime
  218. if not ti or ti < now then
  219. ti = now + firesTimeCache
  220. else
  221. ti = ti + firesTimeCache
  222. end
  223. local maxTime = now + MergeServerDefine.FIRE_MAX_TIME
  224. ti = math.min(ti, maxTime)
  225. --更新
  226. LuaMongo.update(targetCollection, {}, {
  227. ["$set"] = {
  228. [MergeServerDefine.KEY_FIREWORKBONUS_TIME] = ti
  229. },
  230. })
  231. end
  232. end
  233. ----------------------------------恶魔之塔------------------------------------
  234. local queryTowerByLv = { lv = nil }
  235. local queryTowerFiles = { headList = 1 }
  236. local function calcTblLen(tb)
  237. local len = 0
  238. for _,_ in pairs(tb) do
  239. len = len + 1
  240. end
  241. return len
  242. end
  243. --加载目标库中tower集合中所有文档的headList
  244. local function loadTowerHeadData(targetDb)
  245. local collectionName = MergeServerDefine.COLLECTIONS[16]
  246. local targetCollection = targetDb .. collectionName
  247. towerMaxLevel = #TowerConfig
  248. for i=1,towerMaxLevel do
  249. queryTowerByLv.lv = i
  250. LuaMongo.find(targetCollection, queryTowerByLv, queryTowerFiles)
  251. local data = {}
  252. if LuaMongo.next(data) then
  253. towerHeadCache[i] = {
  254. subNum = TOWER_LV_HEAD_MAX,
  255. headList = data.headList
  256. }
  257. if data.headList and next(data.headList) then
  258. local len = calcTblLen(data.headList)
  259. if len < TOWER_LV_HEAD_MAX then
  260. towerHeadCache[i].subNum = TOWER_LV_HEAD_MAX - len
  261. end
  262. end
  263. end
  264. end
  265. end
  266. -- 把源库tower集合中的headList插入到目标库的headList中
  267. local function insertTargetTowerHeadCache(sourceDb, coll)
  268. local targetCollection = sourceDb .. coll
  269. for i=1,towerMaxLevel do
  270. local subNum = towerHeadCache[i].subNum
  271. if subNum > 0 then
  272. queryTowerByLv.lv = i
  273. LuaMongo.find(targetCollection, queryTowerByLv, queryTowerFiles)
  274. local data = {}
  275. if LuaMongo.next(data) then
  276. local headData = data.headList
  277. if headData and next(headData) then
  278. towerHeadCache[i].headList = towerHeadCache[i].headList or {}
  279. local targetHeadList = towerHeadCache[i].headList
  280. for k,v in pairs(headData) do
  281. targetHeadList[k] = v
  282. subNum = subNum - 1
  283. if subNum <= 0 then
  284. break
  285. end
  286. end
  287. towerHeadCache[i].subNum = subNum
  288. towerHeadCache[i].isChange = true
  289. end
  290. end
  291. end
  292. end
  293. end
  294. --更新目标库的headList
  295. local function updateTargetTowerHeadDB(targetDb)
  296. local collectionName = MergeServerDefine.COLLECTIONS[16]
  297. local targetCollection = targetDb .. collectionName
  298. for i=1,#towerHeadCache do
  299. local data = towerHeadCache[i]
  300. if data.isChange then
  301. --更新
  302. queryTowerByLv.lv = i
  303. LuaMongo.update(targetCollection, queryTowerByLv, { ["$set"] = { headList = data.headList }})
  304. end
  305. end
  306. end
  307. ---------------------------------------玩家同名------------------------------
  308. local NameQueryFiles = { ["name"] = 1 }
  309. --加载目标库所有玩家的名字
  310. local function loadTargetCharName(targetDb)
  311. local collectionName = MergeServerDefine.COLLECTIONS[1]
  312. local targetCollection = targetDb .. collectionName
  313. LuaMongo.find(targetCollection, nil, NameQueryFiles)
  314. while true do
  315. local data = {}
  316. if not LuaMongo.next(data) then
  317. break
  318. end
  319. allNameTb[data.name] = '1'
  320. end
  321. end
  322. --得到一个邮件数据
  323. local mailConfig = MailExcel.mail[MergeServerDefine.MAIL_ID]
  324. local function frontMail(receiverUuid)
  325. local mail = {}
  326. mail.type = 1
  327. mail.receiverUuid = receiverUuid
  328. mail.title = mailConfig.title
  329. mail.content = mailConfig.content
  330. mail.read = nil
  331. mail.senderName = mailConfig.title
  332. mail.head = 0
  333. mail.fbTime = nil
  334. mail.fbContent = nil
  335. mail.time = os.time()
  336. mail.get = nil
  337. mail.flag = 1
  338. mail.items = { { ItemDefine.ITEM_ZUANSHI_ID, MergeServerDefine.MAIL_NUM } }
  339. return mail
  340. end
  341. --给因同名而修改名字的玩家发送补偿邮件
  342. local function sendRepeatNameMail(targetDb)
  343. local coll = MergeServerDefine.COLLECTIONS[2]
  344. local targetCollection = targetDb .. coll
  345. for oldName, v in pairs(repeatName2Data) do
  346. local mail = frontMail(v.uuid)
  347. local _, err = pcall(LuaMongo.insert, targetCollection, mail)
  348. writeLog(MergeServerDefine.CHANGENAME_TAG, targetDb, v.sourceDb, coll, oldName, v.newName, v.uuid, err or "")
  349. end
  350. end
  351. --------------------------------更新合服时间------------------------------------
  352. local function updateMergeTime(targetDb)
  353. local targetCollection = targetDb .. MergeServerDefine.COLLECTIONS[3]
  354. local now = os.time()
  355. LuaMongo.update(targetCollection, {}, {
  356. ["$set"] = {
  357. [MergeServerDefine.KEY_MERGE_TIME] = now
  358. },
  359. })
  360. end
  361. ----------------------------------------------------------------------------------------------------------------------------------
  362. -----------------------------------------------------char集合中_id的重复检测和处理-------------------------------------------------
  363. --用于检测不同数据库的char集合中的_id是否有重复, 一般来说通过mongo生成的_id基本不会重复(暂时不用)
  364. local function primaryKeyRepeatCheck()
  365. print("================================检查char集合_id的重复性开始=======================================\n")
  366. local collectionName = MergeServerDefine.COLLECTIONS[1]
  367. for k, dbName in ipairs(MergeServerDefine.MERGE_DB_TB) do
  368. local targetCollection = dbName .. collectionName
  369. LuaMongo.find(targetCollection, nil, nil, {_id = 1})
  370. while true do
  371. local data = {}
  372. if not LuaMongo.next(data) then
  373. break
  374. end
  375. if k ~= 1 then
  376. if primaryKeyTable[data._id] then
  377. repeatIdTb[data._id] = generateNewId()
  378. Log.write(Log.LOGID_OSS_MERGE, string.format("result: %s, targetColl: %s, repeatId: %s, newId: %s",
  379. "Repeat", targetCollection, data._id, repeatIdTb[data._id]))
  380. else
  381. primaryKeyTable[data._id] = '1'
  382. end
  383. else
  384. primaryKeyTable[data._id] = '1'
  385. end
  386. end
  387. end
  388. print("================================检查char集合_id的重复性结束=======================================\n")
  389. end
  390. --好友集合
  391. local function handleFriend(data)
  392. if repeatIdTb[data.uuid1] then
  393. data.uuid1 = repeatIdTb[data.uuid1]
  394. end
  395. if repeatIdTb[data.uuid2] then
  396. data.uuid2 = repeatIdTb[data.uuid2]
  397. end
  398. end
  399. --邮件集合
  400. local function handleMail(data)
  401. if repeatIdTb[data.receiverUuid] then
  402. data.receiverUuid = repeatIdTb[data.receiverUuid]
  403. end
  404. end
  405. --公会集合
  406. local function handleUnion(data)
  407. local tb = {}
  408. for id, v in pairs(data.member) do
  409. if repeatIdTb[id] then
  410. tb[id] = v
  411. end
  412. end
  413. for id, v in pairs(tb) do
  414. data.member[id] = nil
  415. data.member[repeatIdTb[id]] = v
  416. end
  417. tb = {}
  418. for id, v in pairs(data.apply) do
  419. if repeatIdTb[id] then
  420. tb[id] = v
  421. end
  422. end
  423. for id, v in pairs(tb) do
  424. data.apply[id] = nil
  425. data.apply[repeatIdTb[id]] = v
  426. end
  427. if data.presidentUuid and repeatIdTb[data.presidentUuid] then
  428. data.presidentUuid = repeatIdTb[data.presidentUuid]
  429. end
  430. end
  431. --星空争霸集合
  432. local function handleStar(data)
  433. if repeatIdTb[data.uuid] then
  434. data.uuid = repeatIdTb[data.uuid]
  435. end
  436. end
  437. --单人竞技场集合
  438. local function handleJJC(data)
  439. if not data.monsterOutID and repeatIdTb[data._id] then
  440. data._id = repeatIdTb[data._id]
  441. end
  442. end
  443. --战斗视频集合
  444. local function handleVideo(data)
  445. local uuid = data.combatInfo.attacker.uuid
  446. if repeatIdTb[uuid] then
  447. data.combatInfo.attacker.uuid = repeatIdTb[uuid]
  448. end
  449. end
  450. ----------------------------------------------------合并数据----------------------------------------------------------
  451. local writeQueue = {}
  452. local function flushWriteQueue()
  453. for _, task in ipairs(writeQueue) do
  454. local ok, err = pcall(LuaMongo.insert, task.collection, task.data)
  455. if not ok then
  456. Log.write(Log.LOGID_OSS_MERGE, task.collection, err)
  457. end
  458. end
  459. writeQueue = {}
  460. end
  461. -- 每积累100条数据批量写入
  462. local function bufferedInsert(collection, data)
  463. table.insert(writeQueue, {collection=collection, data=data})
  464. if #writeQueue >= 100 then
  465. flushWriteQueue()
  466. end
  467. end
  468. local function processCollection(sourceDb, targetDb, coll)
  469. local sourceCollection = sourceDb .. coll
  470. local targetCollection = targetDb .. coll
  471. local errNum = 0
  472. local allNum = 0
  473. LuaMongo.find(sourceCollection, nil, {})
  474. while true do
  475. local data = {}
  476. if not LuaMongo.next(data) then
  477. break
  478. end
  479. --直接插入目标库
  480. local ok, err = pcall(LuaMongo.insert, targetCollection, data)
  481. if not ok then
  482. errNum = errNum + 1
  483. writeLog(MergeServerDefine.ERR_TAG, targetDb, sourceDb, coll, 1, 1, data._id, err)
  484. end
  485. allNum = allNum + 1
  486. end
  487. writeLog(MergeServerDefine.SUCC_TAG, targetDb, sourceDb, coll, allNum, errNum, "", "")
  488. end
  489. --合并char集合
  490. local function processCharColl(sourceDb, targetDb, coll)
  491. local sourceCollection = sourceDb .. coll
  492. local targetCollection = targetDb .. coll
  493. local errNum = 0
  494. local allNum = 0
  495. LuaMongo.find(sourceCollection, nil, {})
  496. while true do
  497. local data = {}
  498. if not LuaMongo.next(data) then
  499. break
  500. end
  501. --同名检测
  502. if allNameTb[data.name] then
  503. num = num + 1
  504. local newName = MergeServerDefine.NEW_NAME .. num
  505. --统计数据
  506. repeatName2Data[data.name] = {
  507. uuid = data._id,
  508. newName = newName,
  509. sourceDb = sourceDb,
  510. }
  511. --改名
  512. data.name = newName
  513. end
  514. allNameTb[data.name] = '1'
  515. --插入目标库
  516. local ok, err = pcall(LuaMongo.insert, targetCollection, data)
  517. if not ok then
  518. errNum = errNum + 1
  519. writeLog(MergeServerDefine.ERR_TAG, targetDb, sourceDb, coll, 1, 1, data._id, err)
  520. end
  521. allNum = allNum + 1
  522. end
  523. writeLog(MergeServerDefine.SUCC_TAG, targetDb, sourceDb, coll, allNum, errNum, "", "")
  524. end
  525. local function startMergeServer(dbList)
  526. assert(dbList and next(dbList), "====数据错误====")
  527. cleanCache()
  528. --目标集合数据库名
  529. local targetDb = dbList[1]
  530. loadTargetCharName(targetDb)
  531. loadTowerHeadData(targetDb)
  532. for i = 2, #dbList do
  533. local sourceDb = dbList[i]
  534. LuaMongo.auth(sourceDb, Config.DB_USER, Config.DB_PASS)
  535. for _, coll in ipairs(MergeServerDefine.COLLECTIONS) do
  536. if not MergeServerDefine.NO_INSERT_COLLECTIONS[coll] then
  537. print(string.format("========================开始处理集合: %s, %s\n", sourceDb, coll))
  538. if coll == MergeServerDefine.COLLECTIONS[1] then
  539. processCharColl(sourceDb, targetDb, coll)
  540. elseif coll == MergeServerDefine.COLLECTIONS[3] then
  541. loadMoZhuDB(sourceDb, coll)
  542. loadFireTimeData(sourceDb, coll)
  543. elseif coll == MergeServerDefine.COLLECTIONS[16] then
  544. insertTargetTowerHeadCache(sourceDb, coll)
  545. else
  546. processCollection(sourceDb, targetDb, coll)
  547. end
  548. end
  549. end
  550. end
  551. --处理那些需要单独处理的数据
  552. updateTargetMoZhuDB(targetDb)
  553. updateTargetFireTimeDB(targetDb)
  554. sendRepeatNameMail(targetDb)
  555. updateTargetTowerHeadDB(targetDb)
  556. updateMergeTime(targetDb)
  557. end
  558. --合服开始函数
  559. function Start()
  560. --创建mongo连接实例
  561. clientMongoDb()
  562. --检查char集合_id的重复性
  563. --primaryKeyRepeatCheck()
  564. print("========================合服开始=====================")
  565. for i, dbList in ipairs(MergeServerDefine.MERGE_DB_TB) do
  566. startMergeServer(dbList)
  567. end
  568. print("========================合服结束=====================")
  569. end