qcubed icon indicating copy to clipboard operation
qcubed copied to clipboard

mysql master slave support for qcubed

Open olegabr opened this issue 11 years ago • 5 comments

The topic: http://qcu.be/content/mysql-master-slave-support-qcodo. @nleung asked for the support of this feature in qcubed.

The qcodo-based article with code: http://sujee.net/tech/articles/qcodo-master-slave/ The qcodo-based site that utilizes this technique: http://www.uloop.com/

The original post from @nleung:

"So I tried adding that driver: QMySqli5MasterSlaveDatabase.class.php I get the following error: PHP Fatal error: Cannot override final method QDatabaseBase::Query() in /2.1.0/includes/qcubed/_core/database/QMySqli5MasterSlaveDatabase.class.php on line 12

Does anyone know why this wouldn't work?

Thanks!"

It seems that the driver code should be updated for use with qcubed.

olegabr avatar Jan 26 '13 19:01 olegabr

Looking at the code, Query cannot be overridden because it is labeled as 'final'. It appears that the correct place to override is ExecuteQuery, as Query is a kind of wrapper for that function to deal with database profiling.

When that article was written (2008), Query was the function to override. Looks like in 2010, Alex made some changes for profiling. So, see if you can override ExecuteQuery instead.

spekary avatar Jan 29 '13 18:01 spekary

I dislike the current implementation with two databases configured and so on. There should be one database with special settings, like we now use for caching solution:

define("CACHE_PROVIDER_CLASS", null);
define ('CACHE_PROVIDER_OPTIONS' , serialize(
    array(
         array('host' => '127.0.0.1', 'port' => 11211, ),
         //array('host' => '10.0.2.2', 'port' => 11211, ), // adds a second server
    )
) );

The current database initialization scheme should be revisited to allow more flexible configurations like this master-slave one.

olegabr avatar Feb 04 '13 19:02 olegabr

I've placed it to the v3.1 milestone because it needs breaking changes in DB initialization code.

olegabr avatar Jan 10 '16 22:01 olegabr

This is pushed back to the major QQuery rework project in 5.0

spekary avatar Mar 19 '17 19:03 spekary

@olegabr why not use something like maxscale or better yet proxysql?

This way, qcubed can simply work with a single mysql instance, and proxysql can distribute queries to the slaves, and insert and updates to the master.

matthiaz avatar Mar 20 '17 07:03 matthiaz