douzao9845 2015-11-30 04:30 采纳率: 0%
浏览 11

如何将múltiples服务器与同一个数据库连接?

I hired 46 VPS and today only one have with database, and another one like to slave(replica).

How i can connect to this two(or more) server for manage the same database?

For example: server #1 is down, so connect to server #2 or #3, #4, #5...

Right now i know it:

$connection=Mysqli_connect(...);

Maybe exists another method like to:

$connection=mysqli_connect_mutiserver(array(...));

I think un a loop to check ping and time response, and if some fail, this return the next good connection.

For(...){
    if(ping(...) and timing(...)){
        return $serverInfo;
    }
}

P.s: i'm sorry, right now i used my smartphone to post it(maybe dont show the code like to prettyprint.

  • 写回答

0条回答 默认 最新

      编辑
      预览

      报告相同问题?

      手机看
      程序员都在用的中文IT技术交流社区

      程序员都在用的中文IT技术交流社区

      专业的中文 IT 技术社区,与千万技术人共成长

      专业的中文 IT 技术社区,与千万技术人共成长

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

      客服 返回
      顶部