One database per virtualhost

Hi all!

I'm using Ejabberd 2.0.2 with a MySQL database. It works well, but I would want to have a database by each domain to be able to have names repeated between domains. Is it possible?

Thanks in advance.

Regards,
Daniel

Use host_config option

Yes, using host_config you can define options that are specific to some vhost. Check the ejabberd Guide.

In your case, instead of one database for all vhosts:

{hosts, ["example.com", "example.org", "example.net"]}.
{odbc_server, {mysql, "example.com", "test", "root", "password"}}.

You should define one database for each vhost:

{hosts, ["example.com", "example.org", "example.net"]}.

{host_config, "example.com", [
  {odbc_server, {mysql, "example.com", "test", "root", "password"}}
]}.

{host_config, "example.org", [
  {odbc_server, {mysql, "example.org", "test", "root", "password"}}
]}.

{host_config, "example.net", [
  {odbc_server, {mysql, "example.net", "test", "root", "password"}}
]}.

Inconsistency in the web interface

Thanks for your reply, badlop.

It works, but nevertheless in the listing of domains/registered users/online users, I see zero registered users although I have users registered in both domains. In fact, by means of web interface I can see the registered users that I have in each of them and the correct amount of users who are connected. Some idea of the cause by which this inconsistency takes place?

In case it serves, the process that I used to leave the two operational bases was the following one:

  • To export the current database (with name ejabberd).
  • Erase it.
  • To create a new database with the name of my public domain.
  • To import the dump in that database erasing the users of my internal domain.
  • To create a new database with the name of my internal domain.
  • To create the local accounts for users on my LAN.

Regards,
Daniel

No idea of reason. It works for me

I don't know what could be the problem. It works for me, I tried ejabberd 2.0.2 with this config:

{hosts, ["localhost"]}.

{auth_method, odbc}.
{host_config, "localhost", [
  {odbc_server, {mysql, "localhost", "ejadb", "ejauser", "ejapass"}}
]}.

And I see the correct number of registered users of "localhost" in both pages:
http://localhost:5280/admin/vhosts/
http://localhost:5280/admin/server/localhost/stats/

It's strange...

Thanks for your reply, badlop.

I'm using a similar configuration:

{hosts, [ "hermes.freesoftware.org", "sysadminhaiku.com.ar" ]}.

{auth_method, odbc}.

{host_config, "sysadminhaiku.com.ar", [
  {odbc_server, {mysql, "sysadminhaiku.com.ar", "sysadminhaiku", "ejabberd", "pass1"}}
]}.

{host_config, "hermes.freesoftware.org", [
  {odbc_server, {mysql, "hermes.freesoftware.org", "freesoftware", "ejabberd", "pass2"}}
]}.

But I get in https://10.1.0.4:5281/admin/vhosts/

Domain                   registered users connected users
hermes.freesoftware.org   0                     2
sysadminhaiku.com.ar      0                     0

And the stats for freesoftware.org shows:

Registered users:       0
Connected users:        2

Erasing the databases and creating these again I obtain the same results.

A doubt about creation of databases:

By each database, I execute the following commands:

# mysql -D database -p -u ejabberd < ~/download/ejabberd/src/odbc/mysql.sql
# mysql -D database -p -u root < ~/download/ejabberd-modules/mod_archive/trun/src/mod_archive_odbc_mysql.sql

Commenting the first two lines in mod_archive_odbc_mysql.sql:

-- CREATE DATABASE IF NOT EXISTS ejabberd CHARACTER SET utf8 COLLATE utf8_general_ci;
-- USE ejabberd;

This procedure is correct?

Regards,
Daniel

Syndicate content