Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Requires: phpFox version >= 4.3.0

MySQL replication is a process that allows you to easily maintain multiple copies of a MySQL data by having them copied automatically from a master to a slave database. This can be helpful for many reasons including

...

facilitating backup solution for the data,a way to analyze it without using the main database, or simply as a means to scale out.

1. Setup Master and Slaver Mysql server.

There are many tutorials to setup master and slaver mysql server. You can reference these link:

 

https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql

https://dev.mysql.com/doc/refman/5.7/en/replication-setup-slaves.html

This tutorial requires advanced knowledge. We recommend you get professionals to do this if you are not at an advanced level.

...

2. Test connection between php server and MySQL server.

Login ssh to php server, then try to connect to Master and Slaver server

Code Block
bash
bash

mysql -u username -h MASTER_SERVER_IP -p
Code Block
bash
bash

mysql -u username -h SLAVER_SERVER_IP -p

...

Update file PF.Base/file/settings/server.sett.php

Code Block
php
php

<?php
$_CONF['db']['driver'] = 'mysqli'; 
$_CONF['db']['host'] = 'master_server_ip'; // host
$_CONF['db']['user'] = 'username';
$_CONF['db']['pass'] = 'pass';
$_CONF['db']['name'] = 'name';
$_CONF['db']['prefix'] = 'phpfox_';
$_CONF['db']['port'] = '3306';

$_CONF['db']['slave'] = true;
$_CONF['db']['slave_servers'] = [ 
    [
     'host'=>'slave_ip',
     'user'=>'slave_user',
     'pass'=>'slave_pass',
     'port'=>'slave_port'
    ] 
];