Multisite installation fails with shared tables

kwurzel - January 14, 2008 - 15:12
Project:Documentation
Component:Installation
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

With Drupal 6 RC 2 it isn't possible to install multisites.

Steps:
* Install Drupal with shared tables discribed in default.settings.php
* Copy settings.php to new foldes (sub.example.com) and edit table name (main_ --> sub_) and base_url
* Go to sub.example.com/install.php

Effect:
* new table (sub_) can't be created:

Warning: Table 'shared_sessions' already exists query: CREATE TABLE shared_sessions ( `uid` INT unsigned NOT NULL, `sid` VARCHAR(64) NOT NULL DEFAULT '', `hostname` VARCHAR(128) NOT NULL DEFAULT '', `timestamp` INT NOT NULL DEFAULT 0, `cache` INT NOT NULL DEFAULT 0, `session` LONGTEXT DEFAULT NULL, PRIMARY KEY (sid), INDEX timestamp (timestamp), INDEX uid (uid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: Table 'shared_authmap' already exists query: CREATE TABLE shared_authmap ( `aid` INT unsigned NOT NULL auto_increment, `uid` INT NOT NULL DEFAULT 0, `authname` VARCHAR(128) NOT NULL DEFAULT '', `module` VARCHAR(128) NOT NULL DEFAULT '', PRIMARY KEY (aid), UNIQUE KEY authname (authname) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: Table 'shared_role' already exists query: CREATE TABLE shared_role ( `rid` INT unsigned NOT NULL auto_increment, `name` VARCHAR(64) NOT NULL DEFAULT '', PRIMARY KEY (rid), UNIQUE KEY name (name) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: Table 'shared_users' already exists query: CREATE TABLE shared_users ( `uid` INT unsigned NOT NULL auto_increment, `name` VARCHAR(60) NOT NULL DEFAULT '', `pass` VARCHAR(32) NOT NULL DEFAULT '', `mail` VARCHAR(64) DEFAULT '', `mode` TINYINT NOT NULL DEFAULT 0, `sort` TINYINT DEFAULT 0, `threshold` TINYINT DEFAULT 0, `theme` VARCHAR(255) NOT NULL DEFAULT '', `signature` VARCHAR(255) NOT NULL DEFAULT '', `created` INT NOT NULL DEFAULT 0, `access` INT NOT NULL DEFAULT 0, `login` INT NOT NULL DEFAULT 0, `status` TINYINT NOT NULL DEFAULT 0, `timezone` VARCHAR(8) DEFAULT NULL, `language` VARCHAR(12) NOT NULL DEFAULT '', `picture` VARCHAR(255) NOT NULL DEFAULT '', `init` VARCHAR(64) DEFAULT '', `data` LONGTEXT DEFAULT NULL, PRIMARY KEY (uid), UNIQUE KEY name (name), INDEX access (access), INDEX created (created), INDEX mail (mail) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: Duplicate entry '' for key 2 query: INSERT INTO shared_users (name, mail) VALUES('', '') in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: Duplicate entry '1' for key 1 query: UPDATE shared_users SET uid = 1 WHERE name = 'placeholder-for-uid-1' in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: Duplicate entry 'anonymous user' for key 2 query: INSERT INTO shared_role (name) VALUES ('anonymous user') in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: Duplicate entry 'authenticated user' for key 2 query: INSERT INTO shared_role (name) VALUES ('authenticated user') in /home/kinoformat/public_html/includes/database.mysqli.inc on line 133

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/kinoformat/public_html/includes/database.mysqli.inc:133) in /home/kinoformat/public_html/includes/bootstrap.inc on line 967

Warning: Cannot modify header information - headers already sent by (output started at /home/kinoformat/public_html/includes/database.mysqli.inc:133) in /home/kinoformat/public_html/includes/bootstrap.inc on line 568

Warning: Cannot modify header information - headers already sent by (output started at /home/kinoformat/public_html/includes/database.mysqli.inc:133) in /home/kinoformat/public_html/includes/bootstrap.inc on line 569

Warning: Cannot modify header information - headers already sent by (output started at /home/kinoformat/public_html/includes/database.mysqli.inc:133) in /home/kinoformat/public_html/includes/bootstrap.inc on line 570

Warning: Cannot modify header information - headers already sent by (output started at /home/kinoformat/public_html/includes/database.mysqli.inc:133) in /home/kinoformat/public_html/includes/bootstrap.inc on line 571

*

Fatal error: Call to undefined function user_access() in /home/kinoformat/public_html/includes/theme.inc on line 1651<code>
  on sub.example.com
* <code>* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM video_menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in /home/kinoformat/public_html/includes/menu.inc on line 316.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY fit DESC LIMIT 0, 1' at line 1 query: SELECT * FROM video_menu_router WHERE path IN () ORDER BY fit DESC LIMIT 0, 1 in /home/kinoformat/public_html/includes/menu.inc on line 316.
when trying to run the installation again.

#1

catch - January 14, 2008 - 17:03
Version:6.0-rc2» 6.x-dev
Status:active» active (needs more info)

Did you follow this part of the instructions?

* To have all database names prefixed, set $db_prefix as a string:
*
*   $db_prefix = 'main_';
*
* To provide prefixes for specific tables, set $db_prefix as an array.
* The array's keys are the table names and the values are the prefixes.
* The 'default' element holds the prefix for any tables not specified
* elsewhere in the array. Example:
*
*   $db_prefix = array(
*     'default'   => 'main_',
*     'users'     => 'shared_',
*     'sessions'  => 'shared_',
*     'role'      => 'shared_',
*     'authmap'   => 'shared_',
*     'sequences' => 'shared_',
*   );

#2

kwurzel - January 15, 2008 - 12:24

Exactly, I took this array, adjusted the base_url and installed the first site. Then I copied the settings.php to the new site-folder, adjusted the base_url to the subdomain and run the installation from sub.example.com/install.php.

There is also a related issue at http://drupal.org/node/210070.

#3

catch - January 15, 2008 - 14:27

kwurzel: just to confirm, you should only have:

$db_prefix = 'sub_';

and no changes to the array if you're prefixing every table. You shouldn't need the array at all for either your example.com or sub.example.com install.

#4

kwurzel - January 15, 2008 - 16:25

Okay, I forgot to mention that I want to have two different sites with different settings/style/content, but with the same users/cookies.

So I used the array and just changed 'default'   => 'main_', in each case. I don't think that this would be possible without using a array, but I don't know. :-)

#5

catch - January 15, 2008 - 16:31
Title:Multisite installation broken» Multisite installation fails with shared tables
Priority:critical» normal
Status:active (needs more info)» active

OK so you're sharing tables then. That helps to track this down. Sharing tables hasn't been officially supported in previous Drupal versions, I'm not sure if that's changed for 6.x, but I'm downgrading to 'normal'.

There's also a good chance this is duplicate of: http://drupal.org/node/210238 (which is already critical)

#6

ScoutBaker - January 15, 2008 - 19:19

@catch: I don't think this is a duplicate of /node/210238. That issue appears to be a problem just getting the proper DB authentication working. kwurzel has obviously already gotten that portion working or the DB would not be getting updated to generate these errors.

#7

kwurzel - February 5, 2008 - 14:46

So am I on the right track that a multisite setup with shared tables won't be possible with Drupal 6.0? If that's the case, is there a possibility to sync eg. user tables of two independent installations via MySQL?

#8

TheoRichel - March 31, 2008 - 18:47

Wow that is heavy. I am using shared tables on Drupal 5.

TR

#9

kwurzel - April 23, 2008 - 15:26
Version:6.x-dev» 7.x-dev

#10

Damien Tournoud - April 23, 2008 - 15:41
Project:Drupal» Documentation
Version:7.x-dev»
Component:base system» Installation

Ok, this is probably a documentation issue: to install a new instance with shared tables, you have first to let drupal create all tables in the new prefix, and only then to point it to the shared tables.

What is not supported is updating or installing while sharing tables.

#11

Devis - May 2, 2008 - 18:08

Hi Damien,

what do you mean with

What is not supported is updating or installing while sharing tables.

?

I have two drupal-6.2 web sites sharing (code and) tables in this way:

First site:

$db_prefix = '';

Second site:

$db_prefix = array(
      'default' =>'',
      'accesslog'=> 'slave_',
      'blocks'=> 'slave_',
      'blocks_roles'=> 'slave_',
      'boxes' => 'slave_',
      'cache' => 'slave_',
      'cache_block'=> 'slave_',
      'cache_content'=> 'slave_',
      'cache_filter'=> 'slave_',
      'cache_form'=> 'slave_',
      'cache_menu'=> 'slave_',
      'cache_page'=> 'slave_',
      'cache_update'=> 'slave_',
      'cache_views'=> 'slave_',
      'menu_custom' => 'slave_',
      'menu_links' => 'slave_',
      'menu_router' => 'slave_',
      'variable' => 'slave_',
);

Do you mean I won't be able to upgrade modules in the future ?

thank you

#12

Damien Tournoud - May 2, 2008 - 18:19

Do you mean I won't be able to upgrade modules in the future ?

Yes exactly. You will have to fall-back to non-shared setup to perform upgrades. Moreover, you should not share cache_* tables, who knows how those could conflict?

#13

sepeck - May 2, 2008 - 18:38

wait what? how is this a documentation issue?

#14

Damien Tournoud - May 2, 2008 - 18:49

@sepeck: installation or upgrading with shared tables has never been supported, and just CAN'T work. There is nearly no documentation (or really outdated stuff for Drupal 4.7.x) on that matter in the official handbook, even to clarifies what's possible and want can't be done.

#15

Devis - May 2, 2008 - 23:05

I am not sharing cache table, but if it is not possibile to upgrade or install (automatically) it means that Drupal doesn't really support table sharing.
So by now multi-site just can be:

1) same code, different tables, different content for different domains
2) same code, same tables, same content for different domains

For table sharing I will have to monitor table structure during module upgrades... good luck to me.

I am checking "domain" project, but unfortunately it's still a beta, perhaps that will be a good solution.

#16

Damien Tournoud - May 2, 2008 - 23:43

@Devis: you can also use variable overrides (the $conf array in your settings.php) to selectively alter variables (for example the theme) of a multisite. So you can easily have:

3) same code, same tables, same content but a different configuration

#17

Cristian.Palmas - May 3, 2008 - 09:23

I just ran into this issue this morning with my Drupal 6.2 site configuration.
I tried to install different subdomains on my XAMPP configuration with shared tables in order to have different content and theme for each subdomain.

I believed that it was possible since I found how to set different table management using $db_prefix and $base_url ().

Anyway, I need a multi-site configuration in which I have have 6 sub domains and the www.domain.com is the front page to guide the user to sub1.domain.com, sub2.domain.com, and so on. Each subdomain has its own content, taxonomy, blocks and theme.
But I need to share the users for all the subdomains and some content and block too. E.g.: there are navigation links and footer content information to be always present in each page.

The question is: may I share at least some of this content along all the subdomains with tables?
Secondly: I now have a local www.domain.com and a sub1.domain.com working perfectly and sharing tables without problems. Instead, when I tried to install other two subdomains Drupal showed me errors like those reported by kwurzel. Why a subdomain works and the rest not?
Thanks in advance

 
 

Drupal is a registered trademark of Dries Buytaert.