On the game of synthesis service data

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

The original.:

Our game last week after the first data service. Say simply, is to merge the 2 databases in a database, let the game player to play 2 server.

The process is simply be struck with fright, eventually completing tasks.

All the technical details of the share of synthesis service.

Requirement specification:


The 2 game player with the server, the first external is invariant to game player, including the login the game URL, the role of the game; but physically, it is a database server.

Simply put, a service by a service entrance landing game player, playing a game account; two service game player with two service entrance landing, play two account,

Even though I'm only 1 accounts, but different landing entrance, still can use different game account for the game.

Database design


In order to realize the integrated service, the first table primary key must all use code generation, and use server code as a prefix.

For example, one of my service table primary key is 001GMxxxxxxxxxxxxxxxx. Two is the 002GMxxxxxxxxxxxxxxxx. This combined service time, do not need to preprocess the data. Direct import.

Secondly, the use of platform user use one account, login different clothes, to obtain different account, so the game to game player table, were distinguished by the server code, for example:


:Usercode key

:The username platform account

:The servercode server code

So, according to the incoming username+servercode know anything server account.

In the game, game player through the nickname to identify each other, so the combined service time, must to the nickname is modified, to prevent duplication, so all nicknames must add the suffix. Our solution is to add the suffix.X.

With these 3 aspects that, combined service will become simple. (simple. . )

In the service process


1 for database analysis

To prepare work before. So first of all to the database table structure analysis, judge what table structure need clothes, what can be ignored.

Our game has more than 60 tables, of which only 27 tables need to be merged, the other is a configuration table, the log table, do not need to merge.

2 data backup

It goes without saying that, first of all to the full database backup, prevent operating errors, cause loss of data. A new backup database is in the MySQL, and then use the bult insert replication, quickly. Of course, when the backup log table for volume, big, you can skip.

3 data reduction

This part is very important, a webpage game has close to 80% of the account is dead, so he service when must first filter out the dead number. The rules are as follows: level is less than 10, no charge, last login time larger than 30 day, all clear.

Then, is the 27 tables mentioned above, and be eliminated account data, also clean.

The removal is very large, I have a table close to the 30W data, the results of a Qing Qing 20W, super comfortable.

4 data detection

This part is also very important, because we second server configuration was wrong, did not use the server code as the primary key, and a service led to conflicting data exist, it is necessary to detect the 27 table primary key, judge whether the prefix 002, if not, must be manually corrected.

5 data correction

The main existing primary key conflict data is modified, you can use SQL, about 30~60 minutes of time, I use SQL, e.g. update XXX set PK = concat ('001', substring (PK, 4)), data repair.

Of course, before restoration, need for structure analysis, can not be missed, especially foreign key associations.

6 data export

Don't try to combined service using code mode, speed is too slow. I use SQLYog, all of the table is derived, which is inserted into the configuration for Bult Insert, into the very fast.

7 data into the test

When, eventually leading to test, have a look whether there are problems derived from SQL.

8 Introduction.

The complete, integrated service success.

The seemingly simple steps, but a lot of problems. Next I will indicate the actual deployment of trap.

Combined service test of survival


Table 1 clothes don't match

I close the service time, found the table always guide does not go in, suggesting that the primary key repeat. Impossible. From the table into a non repetitive primary key will be prompted to repeat?

Check for a long time, take 1 primary key is 21 bits, 2 primary key is 22 bits, the results into 22 primary key automatically omitted the last one, naturally have a primary key repeat. . .

2 SQLYog damn bug

SQLYog change the table structure and table structure does not correspond to the actual unexpectedly. I modified the char (100), but the database to see, or char (21). The final had to use the command line modification. .

Hey. The key, these tools are always looking for trouble.

3 SQLYog import error no hint

The tool is also damn, I use the Navicat and SQLYog operation.

The 4 part data dynamically generated, unable to bulk import

For example, the arena rank, not allowed to appear the same ranking. So the data needs to be generated automatically when the game player landing. This type of data is dynamically generated, not through mass correction, need to be completed by the game logic.

Therefore, combined service time, the data will not participate in the merger.

Combined service Adventures


Said so much theoretical knowledge, then say that my clothes after. Originally in the testing machine all smooth, less than 2 hours with the. But the real operation, but it took 8 hours. . . .

Start smoothly, more than 3 hours to do data backup, delete, modify. But import when found always prompt primary key conflict, so we find the reason, 1 hours in the past, only to find that the table does not match the structure. Dizzy.

Then guide the data, 4 hours later, the service. A running game player, complaints, said Chinese garbled, loss, loss of military equipment.

The loss of equipment, generals, I spent 1 hours to check, the original is a potential key still lost the last 1 parts, resulting in No. This time, I can't stop, so I compare the 2 database difference table, generating a bunch of update SQL, and then manually operation. But SQL discovery, SQLYog will get stuck, the game will be blocked. I had to drive more than 10 SQLYog, using the parallel method, the SQL split into 50 groups, manual operation.. Dead tired.

The generals name garbled, when generating SQL files, code format error. But the generals data close to 3W, can not be manually updated, so I wrote a program update, background update. It took 1 hours.

Finally the game Exception less, could take breath, results of operation says, game player recharge failure! I check the original code, recharge interface without the use of servercode to distinguish the game player account, and negligence.

The very next day, operation and complained, chamber of Commerce to collect resources fail, go back to check, only to find that the leakage of the primary key account chamber of commerce is revised, and negligence.



Already the rehearsal ahead of 2 days, no problem, but on the battlefield was riddled with errors.

If you are too detailed, will lead to slow development. If not fully prepared, and a lot of problems. This is a case of be in a nice hobble. Finally, I tend to quickly prepare, quick fix solution.

After all, the rehearsal time can not find the problem, give more time may not be found. Not as directly on the battlefield, adjust to changing circumstances.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Fannie at November 18, 2013 - 5:47 PM