How to implement php mysql distributed database?

WBOY
Release: 2016-10-22 00:14:15
Original
2299 people have browsed it

Recently I am working on a new project requirement. According to the requirements of the demander, the distributed database architecture needs to be taken into consideration. But I don't know much about this aspect.
Does a distributed database refer to multiple database servers, and then the business code uses a certain positioning method to write to one database, similar to a table splitting operation? Or a master-slave distributed database? If it's the former, how to position the server?

Reply content:

Recently I am working on a new project requirement. According to the requirements of the demander, the distributed database architecture needs to be taken into consideration. But I don't know much about this aspect.
Does a distributed database refer to multiple database servers, and then the business code uses a certain positioning method to write to one database, similar to a table splitting operation? Or a master-slave distributed database? If it's the former, how to position the server?

  1. There is currently no fully available open source, free MYSQL distributed database service.

  2. Multiple sharding implemented through hash, range, etc. is called sharding technology.

It is actually very simple to position the database.

<code class="php">$dbs = array(
    array("host"=>"127.0.0.1:3306"),
    array("host"=>"127.0.0.2:3306") 
);

$choose_db = $dbs[$data["id"] % count($dbs)]; //hash型sharding
//更多的还有range(按自增区间),date(按天,按月等)
//本质上来说,就是把不同的数据路由到不同的服务器。</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template