0

I have installed mysqlnd_ms plugin , created the mysqlnd_ms.json with following configuration.

{
  "myapp": {
    "master": {
      "master_1": {
        "host": "mysql://drupal@1x4.xx6.x.1x9",
        "port":  3306,
        "user": "drupal",
        "password": "password",
        "db": "site2"
      }
    },
    "slave": {
      "slave_0": {
        "host": "mysql://drupal@1xx.1x1.xx9.2x1",
        "port":  3306,
        "user": "drupal",
        "password": "password",
        "db": "site1"
      }
    }
  }
}

its still not splitting the queries! how will drupal work withmynsqlnd. Do i have make edits in setting.php

  • What hostname do you have in the DB details in settings.php? – Clive Aug 18 '16 at 21:08
  • hostname = myapp this is my settings.php database array <pre>$databases = array ( 'default' => array ( 'default' => array ( 'database' => 'site2', 'username' => 'drupal', 'password' => 'password', 'host' => 'myapp', 'port' => '', 'driver' => 'mysql', 'prefix' => '', ), ), ); </pre> – Aditya Joshi Aug 18 '16 at 21:12
  • You've already done everything you need from a Drupal point of view then. Drupal uses that host name to create the PDO connection; the docs page for the plugin says that's all you need to do to use it – Clive Aug 18 '16 at 21:14
  • i am getting this error : Warning: PDO::exec(): php_network_getaddresses: getaddrinfo failed: Name or service not known in DatabaseConnection_mysql->__construct() (line 69 of /var/www/html/site2/includes/database/mysql/database.inc). – Aditya Joshi Aug 18 '16 at 21:16
  • I'd guess the plugin isn't installed/configured correctly then. Try a basic PHP page with a single connection to PDO, following the example on the docs page. If that doesn't work, you know it's the server and not Drupal – Clive Aug 18 '16 at 21:17
0

That extension's operations are transparent to the application, you only need to configure the host that the DB connection is setup with.

From a Drupal point of view, you just need to update the "host" entry for the relevant database in settings.php to match the name of your mysqlnd_ms application. From the looks of your config file that's myapp, so your database connection might look like this:

$databases['default']['default'] = array(
  'driver' => 'mysql',
  'database' => 'foo',
  'username' => 'bar',
  'password' => 'baz',
  'host' => 'myapp',
  'prefix' => '',
);

If that doesn't work, check that the extension is installed, configured, and enabled.

  • it got resolved , the mistake i did was "host": "mysql://drupal@1x4.xx6.x.1x9". it should be host ip alone "host": 1x4.xx6.x.1x9". Thanks for the help. Also Adding ' "lazy_connections": 0"' got rid of string related error "(mysqlnd_ms) string escaping doesn't work without established connection". Thanks for the help – Aditya Joshi Aug 19 '16 at 15:42
  • some how drush seems to be incompatible it gives me following error. No Drupal site found, only 'drush' cache was cleared. – Aditya Joshi Sep 16 '16 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.