You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Alex <my...@gmail.com> on 2018/07/19 23:47:38 UTC

Replicating bayes in mariadb over multiple systems

Hi,

I'm trying to configure bayes in mariadb to have a central database
that is replicated across multiple systems so they can all share the
same database.

I thought the best way to do that would be to have one master with
multiple slaves that all write to the master. I've configured the two
other systems as slaves and replicated the databases between them.

However, when the master goes off-line, the slaves are still looking
to the master. How can I configure it to either fallback to the local
replicated copy or otherwise configure it to be more resilient in case
of failure?

bayes_learn_to_journal 1
bayes_store_module              Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn                   DBI:mysql:bayesdb:db.example.com # master system
bayes_sql_username              amavis   # sitewide user
bayes_sql_password              password

I've also configured txrep in mariadb as part of this replication that
I would like to make more fault tolerant.

use_txrep                       1
txrep_factory                   Mail::SpamAssassin::SQLBasedAddrList
user_awl_dsn                    DBI:mysql:txrepdb:db.example.com
user_awl_sql_table              txrep
user_awl_sql_username           amavis
user_awl_sql_password           password

Thanks,
Alex

Re: Replicating bayes in mariadb over multiple systems

Posted by John Hardin <jh...@impsec.org>.
On Fri, 20 Jul 2018, Antony Stone wrote:

> On Friday 20 July 2018 at 01:47:38, Alex wrote:
>
>> I'm trying to configure bayes in mariadb to have a central database
>> that is replicated across multiple systems so they can all share the
>> same database.
>
> Give us a few more details about:
>
> - the version of MariaDB you're using
> - the distribution (and version) you've installed this on
> - the replication setup you're using between the "master" and the "slaves"

- whether or not you're using Autolearn (I don't want to make any 
assumptions)


-- 
  John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
  jhardin@impsec.org    FALaholic #11174     pgpk -a jhardin@impsec.org
  key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
   Back in 1969 the technology to fake a Moon landing didn't exist,
   but the technology to actually land there did.
   Today, it is the opposite.                               -- unknown
-----------------------------------------------------------------------
  Tomorrow: the 49th anniversary of Apollo 11 landing on the Moon

Re: Replicating bayes in mariadb over multiple systems

Posted by Antony Stone <An...@spamassassin.open.source.it>.
On Friday 20 July 2018 at 02:52:48, Alex wrote:

> Hi,
> 
> On Thu, Jul 19, 2018 at 8:05 PM, Antony Stone wrote:
> > On Friday 20 July 2018 at 01:47:38, Alex wrote:
> >> Hi,
> >> 
> >> I'm trying to configure bayes in mariadb to have a central database
> >> that is replicated across multiple systems so they can all share the
> >> same database.

> > If you want more than two machines, all replicating to each other, and
> > any of which can be written to, I would only consider doing this with
> > MariaDB + Galera, since the alternative (MySQL or MariaDB in
> > Master-Master ring- replication) is too fragile and difficult to recover
> > from breakages in the network connectivity (in my opinion).
> 
> I wasn't aware I needed Galera to do that.

It's certainly the easiest way to get multiple writeable masters set up.

> This ensures that all content is sync'd to all systems at all times?

Yes.

> >> How can I configure it to either fallback to the local replicated copy
> >> or otherwise configure it to be more resilient in case of failure?
> > 
> > It sounds like Galera (which is automatically installed if you're using
> > MariaDB 10.1 or later) is the solution to your problem.
> 
> Tips on how to get that going would be appreciated.

I found these helpful:

https://mariadb.com/kb/en/library/getting-started-with-mariadb-galera-cluster/

http://galeracluster.com/documentation-webpages/

> I followed the basic mariadb replication instructions

Okay, that'll be traditional MySQL-style Master-Slave replication (which can 
be extended easily enough to Master-Master for a single pair, but gets very 
"delicate" once you try to have more than two Masters which can be written 
to).

> This is on fedora28 x86_64.
>
> # rpm -q mariadb-server
> mariadb-server-10.2.16-1.fc27.x86_64

Looks good.  It's even a later version than I use with Debian Stretch.

> after using this guide to set up bayes in mariadb:
> https://svn.apache.org/repos/asf/spamassassin/branches/3.4/sql/README
> 
> No bayes autolearn.

Good luck :)


Antony.

-- 
Just when you think you're done, a cat floats by with buttered toast strapped 
to its back.

 - Steve Krug, "Don't make me think"

                                                   Please reply to the list;
                                                         please *don't* CC me.

Re: Replicating bayes in mariadb over multiple systems

Posted by Alex <my...@gmail.com>.
Hi,

On Thu, Jul 19, 2018 at 8:05 PM, Antony Stone
<An...@spamassassin.open.source.it> wrote:
> On Friday 20 July 2018 at 01:47:38, Alex wrote:
>
>> Hi,
>>
>> I'm trying to configure bayes in mariadb to have a central database
>> that is replicated across multiple systems so they can all share the
>> same database.
>
> Are you using Galera for the replication?

No.

>> I thought the best way to do that would be to have one master with
>> multiple slaves that all write to the master. I've configured the two
>> other systems as slaves and replicated the databases between them.
>
> That sounds like strange terminology - "slave" usually means a machine which
> replicates *from* a master, but can't write back to it.
>
> Two machines replicating to each other, either of which can be written to,
> would generally be called "master-master replication" (and can be done with
> MariaDB or MySQL, without using Galera).

I'm sorry I wasn't more clear. There's only one machine with a
database that can be written to. The other two are set to read-only
and are set to slaves of the single master.

> If you want more than two machines, all replicating to each other, and any of
> which can be written to, I would only consider doing this with MariaDB +
> Galera, since the alternative (MySQL or MariaDB in Master-Master ring-
> replication) is too fragile and difficult to recover from breakages in the
> network connectivity (in my opinion).

I wasn't aware I needed Galera to do that. This ensures that all
content is sync'd to all systems at all times?

>> However, when the master goes off-line, the slaves are still looking
>> to the master.
>
> What do you mean by "looking to"?  Are the slaves able to accept local
> updates, or are they dependent on the master to be able to resolve queries and
> apply updates to the DB?

No, the two slaves are configured as read-only.

>> How can I configure it to either fallback to the local replicated copy or
>> otherwise configure it to be more resilient in case of failure?
>
> It sounds like Galera (which is automatically installed if you're using
> MariaDB 10.1 or later) is the solution to your problem.

Tips on how to get that going would be appreciated.

> Give us a few more details about:
>
>  - the version of MariaDB you're using
>  - the distribution (and version) you've installed this on
>  - the replication setup you're using between the "master" and the "slaves"
>
> That may give us more ideas about how you can achieve what you want.

This is on fedora28 x86_64.

# rpm -q mariadb-server
mariadb-server-10.2.16-1.fc27.x86_64

I followed the basic mariadb replication instructions after using this
guide to set up bayes in mariadb:
https://svn.apache.org/repos/asf/spamassassin/branches/3.4/sql/README

No bayes autolearn.

Re: Replicating bayes in mariadb over multiple systems

Posted by Antony Stone <An...@spamassassin.open.source.it>.
On Friday 20 July 2018 at 01:47:38, Alex wrote:

> Hi,
> 
> I'm trying to configure bayes in mariadb to have a central database
> that is replicated across multiple systems so they can all share the
> same database.

Are you using Galera for the replication?

> I thought the best way to do that would be to have one master with
> multiple slaves that all write to the master. I've configured the two
> other systems as slaves and replicated the databases between them.

That sounds like strange terminology - "slave" usually means a machine which 
replicates *from* a master, but can't write back to it.

Two machines replicating to each other, either of which can be written to, 
would generally be called "master-master replication" (and can be done with 
MariaDB or MySQL, without using Galera).

If you want more than two machines, all replicating to each other, and any of 
which can be written to, I would only consider doing this with MariaDB + 
Galera, since the alternative (MySQL or MariaDB in Master-Master ring-
replication) is too fragile and difficult to recover from breakages in the 
network connectivity (in my opinion).

> However, when the master goes off-line, the slaves are still looking
> to the master.

What do you mean by "looking to"?  Are the slaves able to accept local 
updates, or are they dependent on the master to be able to resolve queries and 
apply updates to the DB?

> How can I configure it to either fallback to the local replicated copy or
> otherwise configure it to be more resilient in case of failure?

It sounds like Galera (which is automatically installed if you're using 
MariaDB 10.1 or later) is the solution to your problem.


Give us a few more details about:

 - the version of MariaDB you're using
 - the distribution (and version) you've installed this on
 - the replication setup you're using between the "master" and the "slaves"

That may give us more ideas about how you can achieve what you want.


Antony.

-- 
A user interface is like a joke.
If you have to explain it, it means it doesn't work.

                                                   Please reply to the list;
                                                         please *don't* CC me.