Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate read and write databases in Magento

Tags:

magento

I can't find any examples online of how to configure two separate databases for Magento - one for read requests and one for write requests. I assume that this should happen in app/etc/local.xml but I don't know what the syntax is. Does anybody know the syntax or have a link to a blog post or something that my searching didn't turn up?

I'm running Magento 1.6.1.0

Thanks

like image 887
Max Avatar asked Jan 23 '12 12:01

Max


People also ask

What is a database sharding Magento 2?

The Magento 2 split database feature incorporates such sections of the platform as orders, checkout, and product data. Each one can possess its own master database which supports replication, so you can easily scale load from Magento 2 checkouts, browsing, or order management and merchandising activities.

What does FrontController do in magento2?

The FrontController class class searches through a list of routers, provided by the RouterList class, until it matches one that can process a request. When the FrontController finds a matching router, it dispatches the request to an action class returned by the router.

Which databases are supported by Magento?

Magento uses the MySQL database management system with an Entity-Attribute-Value (EAV) model that allows space-efficient data encoding. As of version 2.4, Magento supports MySQL 8, which is up to twice as fast as the previously supported version 5.7.


1 Answers

In your app/etc/local.xml fill <resources> in next way:

    <resources>
        <db>
            <table_prefix><![CDATA[]]></table_prefix>
        </db>
        <core_read>
            <connection>
                <use /> 
                <host><![CDATA[localhost]]></host>
                <username><![CDATA[root]]></username>
                <password><![CDATA[]]></password>
                <dbname><![CDATA[db_read_name]]></dbname>
                <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                <model><![CDATA[mysql4]]></model>
                <type><![CDATA[pdo_mysql]]></type>
                <pdoType><![CDATA[]]></pdoType>
                <active>1</active>
            </connection>
        </core_read>
        <core_write>
            <connection>
                <use />
                <host><![CDATA[localhost]]></host>
                <username><![CDATA[root]]></username>
                <password><![CDATA[]]></password>
                <dbname><![CDATA[db_write_name]]></dbname>
                <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
                <model><![CDATA[mysql4]]></model>
                <type><![CDATA[pdo_mysql]]></type>
                <pdoType><![CDATA[]]></pdoType>
                <active>1</active>
            </connection>
        </core_write>
    </resources>
like image 71
Dmytro Zavalkin Avatar answered Sep 24 '22 00:09

Dmytro Zavalkin