Home >Database >Mysql Tutorial >Some thoughts and designs on migrating data from mysql to hbase
Due to the development of business, using mysql to create indexes and search has caused the bottleneck of data flow to be stuck in the database io. For example, every time a full table is dumped, it will cause The pressure is too great, which takes a long time, and the current data volume has basically reached 100 million levels. If you want mysql to provide better services, you must consider sub-databases and tables in the next step; based on this In this case, consider using hbase for data storage, because the amount of data that hbase can bear is much larger than mysql, and the expansion of columns is also very convenient
In relational databases such as mysql, sqlserver, oracle, data is stored according to rows, as shown in the following figure:
But in hbase, all data is stored based on columns, as shown below:
The logical model of hbase is as follows:
Among them: com.cnn.ww corresponds to rowkey, which is equivalent to the concept of mysql's primary key
contents, anchor: These two correspond to the concept of column family. In terms of physical storage, data of the same column family is stored in the same file
cnnsi.com, mylook.ca: corresponds to Columns under the column family can be dynamically added in hbase
The corresponding grid data represents unit data, that is, corresponding to rowkey, cf: the specific value under column
Among them, tn: represents the timestamp, different versions of unit data
One of the storage structures is as follows:
The history of relational databases has been long, but when the amount of data expands, for example, for the mysql database, when the amount of data reaches hundreds of millions or more Sometimes, if you query according to the index, the effect may not be particularly obvious. In the end, you can only query according to the primary key, or gradually develop into a sub-database and sub-table model. However, sub-database and sub-table bring a lot of trouble to operation, maintenance and use. Big trouble; so at this time, the development of primary key of nosql database, nosql abbreviated as not only sql, gradually developed and expanded as the amount of data increased dramatically. Taking hbase in nosql as an example, it supports TB and PB data, and columns The expansion is particularly flexible
In fact, hbase can be regarded as the result of mysql sub-database and table sub-database, but the difference is that mysql sub-database is divided into The table supports indexes, etc., but hbase only supports rowkey as the primary key index. From the book, we can know that hbase data is stored according to columns, and when the data is too large, it will be split according to rows, as shown below :
The above are some thoughts and designs on migrating data from mysql to hbase. For more related content, please pay attention to the PHP Chinese website (www.php. cn)!