{"id":2488,"date":"2016-08-12T11:21:47","date_gmt":"2016-08-12T15:21:47","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2488"},"modified":"2016-10-01T19:39:03","modified_gmt":"2016-10-01T23:39:03","slug":"install-galera-ubuntu-16","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/","title":{"rendered":"How to install Galera on Ubuntu 16"},"content":{"rendered":"<p>MySQL Galera is a plugin that transforms MySQL from a single-server database engine, into a clustered solution with synchronous replication and sophisticated conflict resolution. With Galera installed, MySQL can be scaled out like a more traditional app server. While MySQL clients work as if connected to a single database instance, they are in fact interacting with a cluster that spans multiple database nodes, providing high availability and transparent failover.<\/p>\n<h2>Getting Started<\/h2>\n<p>Confirm that you have the following before you follow this guide:<br \/>\n\u2022 1 Node (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>) running Ubuntu 16.<br \/>\n\u2022 Root access to the node or one sudo non-root user<\/p>\n<h2>Tutorial<\/h2>\n<p>A Galera installation isn&#8217;t nearly as useful without multiple nodes, please be aware that you must always have an odd number of node to have a quorum for a production use. This example will simulate a cluster by running two distinct local instances on separate IPs. For production use, you&#8217;ll perform this installation on several separate servers that can communicate directly with each other<\/p>\n<p>Begin by installing the software-properties package. This gives us a command for easily installing Ubuntu Personal Package Archives (PPAs), separate repositories which users and teams use for providing custom software or updates to existing packages.<\/p>\n<p><code>apt-get install software-properties-common -y<br \/>\napt-key adv --recv-keys --keyserver hkp:\/\/keyserver.ubuntu.com:80 0xF1656F24C74CD1D8<\/code><\/p>\n<p>We&#8217;ll then use a utility shipped as part of the software-properties package to add the MariaDB PPA. This repository contains the Galera plugin.<\/p>\n<p><code>add-apt-repository 'deb [arch=amd64,i386,ppc64el] http:\/\/ftp.utexas.edu\/mariadb\/repo\/10.1\/ubuntu xenial main'<\/code><\/p>\n<p>The repository is installed, but you&#8217;ll need to update the list of available packages. You must also install the MariaDB server package.<\/p>\n<p><code>apt-get update<br \/>\napt-get install mariadb-server rsync -y<\/code><\/p>\n<p>Galera needs a configuration file. Let&#8217;s create that.<\/p>\n<p><code>nano \/etc\/mysql\/conf.d\/galera.cnf<\/code><\/p>\n<p><code class=\"gris\">[mysqld]<br \/>\n#mysql settings<br \/>\nbinlog_format=ROW<br \/>\ndefault-storage-engine=innodb<br \/>\ninnodb_autoinc_lock_mode=2<br \/>\ninnodb_doublewrite=1<br \/>\nquery_cache_size=0<br \/>\nquery_cache_type=0<br \/>\nbind-address=0.0.0.0<br \/>\n#galera settings<br \/>\nwsrep_on=ON<br \/>\nwsrep_provider=\/usr\/lib\/galera\/libgalera_smm.so<br \/>\nwsrep_cluster_name=\"test_cluster\"<br \/>\nwsrep_cluster_address=gcomm:\/\/10.0.0.119,10.0.0.120<br \/>\nwsrep_sst_method=rsync<\/code><\/p>\n<p>In this example, we&#8217;ll use the IPs 10.0.0.119 and 10.0.0.120.<\/p>\n<p>Before Galera can start, we need to ensure that MySQL is stopped on both nodes.<\/p>\n<p><code>systemctl stop mysql.service<\/code><\/p>\n<p>On the first node, start the Galera cluster.<\/p>\n<p><code>galera_new_cluster<\/code><\/p>\n<p>Having done this, we need to ensure that the cluster is in fact running so our second node has something to which to connect.<\/p>\n<p><code>mysql -u root -p -e \"show status like 'wsrep_cluster_size'\"<\/code><\/p>\n<p>If things are working, you should see this:<\/p>\n<p><code class=\"gris\">+--------------------+-------+<br \/>\n| Variable_name      | Value |<br \/>\n+--------------------+-------+<br \/>\n| wsrep_cluster_size | 1     |<br \/>\n+--------------------+-------+<\/code><\/p>\n<p>On the second node, launch the MySQL daemon.<\/p>\n<p><code>systemctl start mysql.service<\/code><\/p>\n<p>The second node should have automatically linked to the cluster. We&#8217;ll verify that here.<\/p>\n<p><code>mysql -u root -p -e \"show status like 'wsrep_cluster_size'\"<\/code><\/p>\n<p>If everything is running, you should see this:<\/p>\n<p><code class=\"gris\">+--------------------+-------+<br \/>\n| Variable_name      | Value |<br \/>\n+--------------------+-------+<br \/>\n| wsrep_cluster_size | 2    |<br \/>\n+--------------------+-------+<\/code><\/p>\n<p>Great. Let&#8217;s create a database and see if it propagates across the Galera cluster. Run this command on your first node:<\/p>\n<p><code>mysql -u root -p<\/code><\/p>\n<p><code class=\"gris\">create database galera_test;<br \/>\nshow databases like 'galera_test';<br \/>\n+------------------------+<br \/>\n| Database (galera_test) |<br \/>\n+------------------------+<br \/>\n| galera_test            |<br \/>\n+------------------------+<br \/>\n1 row in set (0.00 sec)<\/code><\/p>\n<p>Now we verify that the change has appeared on the second node.<\/p>\n<p><code>mysql -u root -p<\/code><\/p>\n<p><code class=\"gris\">show databases like 'galera_test';<br \/>\n+------------------------+<br \/>\n| Database (galera_test) |<br \/>\n+------------------------+<br \/>\n| galera_test            |<br \/>\n+------------------------+<br \/>\n1 row in set (0.00 sec)<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>While this is only an example cluster, what you&#8217;ve learned here can easily be scaled up to several, or even dozens, of distinct nodes. If you enjoyed this article, be sure to share it with your friends so they too can build highly-available MySQL clusters!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>MySQL Galera is a plugin that transforms MySQL from a single-server database engine, into a clustered solution with synchronous replication and sophisticated conflict resolution. With Galera installed, MySQL can be scaled out like a more traditional app server. While MySQL clients work as if connected to a single database instance, they are in fact interacting<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,75],"tags":[],"class_list":["post-2488","post","type-post","status-publish","format-standard","hentry","category-database","category-ha-clustering"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to install Galera on Ubuntu 16 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to install Galera on your Ubuntu 16 server. Read now &amp; Setup your own clustered solution with synchronous replication!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to install Galera on Ubuntu 16 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to install Galera on your Ubuntu 16 server. Read now &amp; Setup your own clustered solution with synchronous replication!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-08-12T15:21:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-10-01T23:39:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/\",\"name\":\"How to install Galera on Ubuntu 16 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-08-12T15:21:47+00:00\",\"dateModified\":\"2016-10-01T23:39:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to install Galera on your Ubuntu 16 server. Read now & Setup your own clustered solution with synchronous replication!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to install Galera on Ubuntu 16\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to install Galera on Ubuntu 16 - Globo.Tech","description":"This tutorial will show you how to install Galera on your Ubuntu 16 server. Read now & Setup your own clustered solution with synchronous replication!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/","og_locale":"en_US","og_type":"article","og_title":"How to install Galera on Ubuntu 16 - Globo.Tech","og_description":"This tutorial will show you how to install Galera on your Ubuntu 16 server. Read now & Setup your own clustered solution with synchronous replication!","og_url":"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/","og_site_name":"Globo.Tech","article_published_time":"2016-08-12T15:21:47+00:00","article_modified_time":"2016-10-01T23:39:03+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/","url":"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/","name":"How to install Galera on Ubuntu 16 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-08-12T15:21:47+00:00","dateModified":"2016-10-01T23:39:03+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to install Galera on your Ubuntu 16 server. Read now & Setup your own clustered solution with synchronous replication!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/install-galera-ubuntu-16\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to install Galera on Ubuntu 16"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2488","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2488"}],"version-history":[{"count":3,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2488\/revisions"}],"predecessor-version":[{"id":2970,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2488\/revisions\/2970"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}