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?
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?
There is currently no fully available open source, free MYSQL distributed database service.
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>