markt-de / puppet-galera

Puppet Module to setup Galera/XtraDB clusters on MySQL/MariaDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

should not designate one node as master

maxadamo opened this issue · comments

Hi Frank.

there is no concept of "master" that can be pre-assigned, and that can always be used to bootstrap the cluster.
There is one node in the cluster which can be considered safe to bootstrap. This node is the last node that was alive in the cluster and it can be determined by grepping as following:

grep safe_to_bootstrap ~mysql/grastate.dat 
safe_to_bootstrap: 0

If it's 1 you can bootstrap from that node.
Of course you can bootstrap for whatever node, but the risk of loosing data is considerably high, depending how long the last node was alive, while the other nodes were down!!

For you reference: Galera Safe To Bootstrap

Hope it helps!

@maxadamo Thanks! I'm aware of this issue. From a historical standpoint I guess this feature exists in this module to make it possible to bootstrap a new cluster.

I take your report as an opportunity to think about how this feature could be improved for existing clusters. If you're able to help with this, do not hesitate to suggest code changes by submitted a pull request.

I can understand.... TBH, I was investigating your modules, since it's not easy to find a proper solution.
I have my own tool, and my own module galera_proxysql

but I'm using a puppet exec, with my wrapper with the following command:

command => 'galera_wizard.py -bn -f || galera_wizard.py -jn -f',

which means: try to bootstrap or try to join.
I do also have a fact, checking the status on the port 9200.

There is a possibility to use PuppetDB. I have seen it in some other module. But while it's possible to store some information information on there it's still not easy to combine together all the moving parts.
Let's see where we get :)

Maybe this approach could be extended to support also this type of scenario: #118 (comment)

I was considering using grastate.dat in order to not bootstrap from the wrong node. However, this would require to know the location of datadir, but this is either set by puppetlabs/mysql or by a custom config. So there's no reliable way to determine the datadir and hence no way to query grastate.dat.

So I've decided to abandon this idea for now. In my experience the current mode of operation has not caused any issues in ~5 years. If someone wants to play it extra safe it would always be possible to set bootstrap_command to something like /bin/false.

I'm going to close this issue now. If someone has a solution to the formentioned problem or has a better idea, please let me know (or better: submit a pull request :)).