as you may already mentioned, I’ve got a blog (hey, you are here ^^)… creating a blog sounds very easy today – there are lots of websites offering free blogs, you just have to choose. But if you are a nerd like me, you may have a bit more to do…
In my daily work, high availebility is one of the main topics… and although I wouldn’t call this blog important enough to be always on… well I’m a nerd, so I’m going to cluster everything 😉
I already run two small Servers with VMware, so I just created two new virtual Machines.
I have choosen the latest Ubuntu LTS… the setup is well documented, so I’m not going to repeat it here.
now the funny part begins 😉 If i had the choice i would have installed an oracle DB – but unfortunately it’s not for free. So I’m going for the 2nd best solution – mysql. First i had to decide which cluster technologie to use – either the “master slave replication” or “galera cluster”… translated to oracle terms it means do dataguard or RAC. OK, Galera is not like RAC because it’s a shared nothing architecture! Sounds pretty cool, so Galera, prepare yourself to be used by me 😛
Since Galera works best with MarianDB, I made a small adjustment regarding the used product, but MariaDB is a fork of mysql and almost all products able to run on mysql should work on MariaDB (as you can see, wordpress works fine ^^) And just to confirm my decision, I found the announcement that MariaDB 10.1 and higher are including the galera binaries… perkt. So you only have to add the MariaDB repository to the packet management and just run the installer. And to make it easy, on the project website is a very good documentation what commands to execute depending on your OS and designated db version…
so i just entered
apt install mariadb-server
on both servers and had two running MariaDB databases running… but wait – I don’t want two databases but just one cluster! But everything is working as it should, unlike Oracle you are linking the databases afterwards… sounds wired, but it works.
so we just have to create a galera configuration
vi /etc/mysql/conf.d/galera.cnf [mysqld] binlog_format=ROW default-storage-engine=innodb innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 # Galera Provider Configuration wsrep_on=ON wsrep_provider=/usr/lib/galera/libgalera_smm.so # Galera Cluster Configuration wsrep_cluster_name="<CLUSTER_NAME>" wsrep_cluster_address="gcomm://<SERVER 1>,<SERVER 2>" # Galera Synchronization Configuration wsrep_sst_method=rsync # Galera Node Configuration wsrep_node_address="<LOCAL IP>" wsrep_node_name="<LOCAL HOSTNAME>"
of course you have to replace the values in the brackets with something suiteble for your environment. If you are using names for “wsrep_cluster_address”, make sure you can resolve the names – otherwiese use IP’s.
now we have to stop mysql and create a new cluster…
systemctl stop mysql # on all Nodes! galera_new_cluster # on first node only! systemctl stop mysql && systemctl start mysql
to check if all is working you can execute this SQL:
mysql -u root -p -e "SHOW STATUS LIKE 'wsrep_cluster_size'"
the output should be the number of cluster members – and should of course work on all nodes.
if you want some more details – i found this site with a step by step guide and a lot of explanations.
… will be continued