Page tree
Skip to end of metadata
Go to start of metadata

 

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

mysql -u username -h MASTER_SERVER_IP -p
mysql -u username -h SLAVER_SERVER_IP -p

If you can't connect to Master or Slaver server, you can follow this https://support.rackspace.com/how-to/mysql-connect-to-your-database-remotely/ to update it.

3. Change phpFox configuration.

Update file PF.Base/file/settings/server.sett.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'
    ] 
];
  • No labels