{"id":288,"date":"2022-08-04T13:23:47","date_gmt":"2022-08-04T13:23:47","guid":{"rendered":"https:\/\/wqrld.net\/blog\/?p=288"},"modified":"2022-08-04T13:23:47","modified_gmt":"2022-08-04T13:23:47","slug":"mariadb-clustering-with-galera","status":"publish","type":"post","link":"https:\/\/wqrld.net\/blog\/mariadb-clustering-with-galera\/","title":{"rendered":"MariaDB clustering with galera"},"content":{"rendered":"\n<p>Some notes for myself written down publicly in the hopes that they might help some future person.<\/p>\n\n\n\n<p><strong>It is highly recommended to have the cluster on a vlan\/vswitch!<\/strong><br>Galera does not implement it&#8217;s own security for the cluster ports. See the vlan part at the bottom of this document if you do not have vlans setup yet.<\/p>\n\n\n\n<p>In this example the following IPs are used:<br>Local machine: 192.168.100.1<br>Another cluster node: 192.168.100.2<\/p>\n\n\n\n<p><strong>Make sure mariadb is off before starting!<\/strong><\/p>\n\n\n\n<p>edit <code>\/etc\/mysql\/mariadb.conf.d\/60-galera.cnf<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;galera]\nwsrep_on = ON\nwsrep_provider = \/usr\/lib\/galera\/libgalera_smm.so\nwsrep_cluster_address = \"gcomm:\/\/192.168.100.1,192.168.100.2\"\nwsrep_provider_options=\"gmcast.listen_addr=tcp:\/\/192.168.100.1:4567;ist.recv_addr=192.168.100.1:4568\"\nbinlog_format = row\nwsrep_cluster_name=\"galeracluster\"\ndefault_storage_engine = InnoDB\nwsrep_node_address = 192.168.100.1\ninnodb_autoinc_lock_mode = 2\nwsrep_sst_receive_address=192.168.100.1:4444\nbind-address = 192.168.100.1<\/code><\/pre>\n\n\n\n<p>If this is the first node in the cluster, or all nodes in the cluster are currently down, you have to run <br><code>galera_new_cluster<\/code> to bootstrap the cluster again. Otherwise you can just start the mariadb service through systemd.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Now you&#8217;re good to go! <br>While everything should work now, if you want to read more about galera you can do so <a href=\"https:\/\/mariadb.com\/kb\/en\/getting-started-with-mariadb-galera-cluster\/\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Addendum: Vlans<\/h2>\n\n\n\n<p>You should keep the cluster on a vlan for security reasons. This can be done in netplan by editing \/etc\/netplan\/(yourconfig).yaml and adding:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  vlans:\r\n    enp0s31f6.4001:\r\n      id: 4001\r\n      link: enp0s31f6\r\n      mtu: 1400\r\n      addresses:\r\n        - 192.168.100.1\/24<\/code><\/pre>\n\n\n\n<p>Here enp0s31f6 is the interface name, 4001 is the vlan id, and 192.168.100.1 is the ip to assign to the local box.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some notes for myself written down publicly in the hopes that they might help some future person. It is highly recommended to have the cluster on a vlan\/vswitch!Galera does not implement it&#8217;s own security for the cluster ports. See the vlan part at the bottom of this document if you do not have vlans setup &hellip; <a href=\"https:\/\/wqrld.net\/blog\/mariadb-clustering-with-galera\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MariaDB clustering with galera&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-288","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/posts\/288","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/comments?post=288"}],"version-history":[{"count":3,"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/posts\/288\/revisions"}],"predecessor-version":[{"id":291,"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/posts\/288\/revisions\/291"}],"wp:attachment":[{"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/media?parent=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/categories?post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wqrld.net\/blog\/wp-json\/wp\/v2\/tags?post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}