{"id":4163,"date":"2020-02-25T09:35:07","date_gmt":"2020-02-25T02:35:07","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=4163"},"modified":"2020-02-25T09:35:07","modified_gmt":"2020-02-25T02:35:07","slug":"mariadb-advance-mariadb-galera-cluster","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/mariadb-advance-mariadb-galera-cluster\/","title":{"rendered":"MariaDB Advance: MariaDB Galera Cluster"},"content":{"rendered":"<h1>MariaDB Galera l\u00e0 g\u00ec?<\/h1>\n<p><img decoding=\"async\" class=\"aligncenter\" title=\"galera_small\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/02\/img_5e5476821ee5c.png\" alt=\"galera_small\" \/><\/p>\n<p><span style=\"color: #ff0000;\">MariaDB Galera l\u00e0 c\u1ee5m m\u00e1y ch\u1ee7 \u0111\u1ed3ng b\u1ed9 cho MariaDB.\u00a0N\u00f3 ch\u1ec9 kh\u1ea3 d\u1ee5ng tr\u00ean Linux v\u00e0 ch\u1ec9 h\u1ed7 tr\u1ee3 c\u00e1c\u00a0c\u00f4ng c\u1ee5 l\u01b0u tr\u1eef\u00a0<a style=\"color: #ff0000;\" href=\"https:\/\/mariadb.com\/kb\/en\/xtradb-and-innodb\/\" rel=\"nofollow noopener\" target=\"_blank\">XtraDB \/ InnoDB<\/a>.<\/span><\/p>\n<h2 id=\"\u0110\u1eb7c_tr\u01b0ng\">\u0110\u1eb7c tr\u01b0ng<\/h2>\n<ul>\n<li>Synchronous replication<\/li>\n<li>C\u1ea5u tr\u00fac li\u00ean k\u1ebft Active-active multi-master<\/li>\n<li>\u0110\u1ecdc v\u00e0 ghi v\u00e0o b\u1ea5t k\u1ef3 node server<\/li>\n<li>Ki\u1ec3m so\u00e1t c\u00e1c node t\u1ef1 \u0111\u1ed9ng, c\u00e1c node l\u1ed7i s\u1ebd \u0111\u01b0\u1ee3c \u0111\u01b0\u1ee3c g\u1ee1 kh\u1ecfi cluster<\/li>\n<li>Th\u00eam node t\u1ef1 \u0111\u1ed9ng<\/li>\n<li>Nh\u00e2n r\u1ed9ng song song, v\u1edbi \u00a0ki\u1ec3u row level<\/li>\n<li>K\u1ebft n\u1ed1i m\u00e1y kh\u00e1ch tr\u1ef1c ti\u1ebfp, giao di\u1ec7n MariaDB b\u1ea3n \u0111\u1ecba<\/li>\n<\/ul>\n<h2 id=\"Nh\u1eefng_l\u1ee3i_\u00edch\">Nh\u1eefng l\u1ee3i \u00edch<\/h2>\n<p>C\u00e1c t\u00ednh n\u0103ng tr\u00ean mang l\u1ea1i m\u1ed9t s\u1ed1 l\u1ee3i \u00edch cho gi\u1ea3i ph\u00e1p ph\u00e2n c\u1ee5m DBMS, bao g\u1ed3m:<\/p>\n<ul>\n<li>Kh\u00f4ng c\u00f3 \u0111\u1ed9 tr\u1ec5 slave<\/li>\n<li>Kh\u00f4ng c\u00f3 transactions\u00a0b\u1ecb m\u1ea5t<\/li>\n<li>\u0110\u00e1p \u1ee9ng c\u1ea3 2 kh\u1eb3ng n\u0103ng l\u00e0 m\u1edf r\u1ed9ng v\u00e0 read &amp; write<\/li>\n<li>\u0110\u1ed9 tr\u1ec5 client nh\u1ecf h\u01a1n<\/li>\n<\/ul>\n<h2 id=\"Phi\u00ean_b\u1ea3n_Galera\">Phi\u00ean b\u1ea3n Galera<\/h2>\n<p>C\u1ee5m MariaDB Galera \u0111\u01b0\u1ee3c cung c\u1ea5p b\u1edfi:<\/p>\n<ul>\n<li>M\u00e1y ch\u1ee7 MariaDB.<\/li>\n<li>B\u1ea3n\u00a0v\u00e1\u00a0<a href=\"https:\/\/github.com\/codership\/mysql-wsrep\" rel=\"nofollow noopener\" target=\"_blank\">MySQL-wsrep<\/a>\u00a0cho M\u00e1y ch\u1ee7 MySQL v\u00e0 M\u00e1y ch\u1ee7 MariaDB \u0111\u01b0\u1ee3c ph\u00e1t tri\u1ec3n b\u1edfi\u00a0<a href=\"http:\/\/www.codership.com\/\" rel=\"nofollow noopener\" target=\"_blank\">Codership<\/a>\u00a0.\u00a0B\u1ea3n v\u00e1 hi\u1ec7n ch\u1ec9 h\u1ed7 tr\u1ee3 c\u00e1c h\u1ec7 \u0111i\u1ec1u h\u00e0nh gi\u1ed1ng Unix.<\/li>\n<li>C\u00e1c\u00a0<a href=\"https:\/\/github.com\/codership\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">Galera wsrep th\u01b0 vi\u1ec7n cung c\u1ea5p<\/a>\u00a0.<\/li>\n<\/ul>\n<p>Trong\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/what-is-mariadb-101\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.1<\/a>\u00a0tr\u1edf l\u00ean,\u00a0b\u1ea3n v\u00e1\u00a0<a href=\"https:\/\/github.com\/codership\/mysql-wsrep\" rel=\"nofollow noopener\" target=\"_blank\">MySQL-wsrep<\/a>\u00a0\u0111\u00e3 \u0111\u01b0\u1ee3c s\u00e1p nh\u1eadp v\u00e0o M\u00e1y ch\u1ee7 MariaDB.\u00a0\u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 c\u00f3 th\u1ec3 c\u00f3 \u0111\u01b0\u1ee3c ch\u1ee9c n\u0103ng c\u1ee7a MariaDB Galera Cluster b\u1eb1ng c\u00e1ch c\u00e0i \u0111\u1eb7t c\u00e1c g\u00f3i MariaDB Server ti\u00eau chu\u1ea9n v\u00e0\u00a0g\u00f3i\u00a0<a href=\"https:\/\/github.com\/codership\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">th\u01b0 vi\u1ec7n c\u1ee7a nh\u00e0 cung c\u1ea5p Galera wsrep<\/a>\u00a0.\u00a0Phi\u00ean b\u1ea3n\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">Galera<\/a>\u00a0sau\u00a0t\u01b0\u01a1ng \u1ee9ng v\u1edbi t\u1eebng phi\u00ean b\u1ea3n M\u00e1y ch\u1ee7 MariaDB:<\/p>\n<ul>\n<li>Trong\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/what-is-mariadb-104\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.4 tr\u1edf<\/a>\u00a0l\u00ean, MariaDB Galera Cluster s\u1eed d\u1ee5ng\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">Galera<\/a>\u00a04. \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0\u00a0b\u1ea3n v\u00e1\u00a0<a href=\"https:\/\/github.com\/codership\/mysql-wsrep\" rel=\"nofollow noopener\" target=\"_blank\">MySQL-wsrep<\/a>\u00a0l\u00e0 phi\u00ean b\u1ea3n 26 v\u00e0\u00a0<a href=\"https:\/\/github.com\/codership\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">th\u01b0 vi\u1ec7n nh\u00e0 cung c\u1ea5p Galera wsrep<\/a>\u00a0l\u00e0 phi\u00ean b\u1ea3n 4.<\/li>\n<li>Trong\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/what-is-mariadb-103\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.3 tr\u1edf v\u1ec1<\/a>\u00a0tr\u01b0\u1edbc, MariaDB Galera Cluster s\u1eed d\u1ee5ng\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">Galera<\/a>\u00a03. \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0\u00a0b\u1ea3n v\u00e1\u00a0<a href=\"https:\/\/github.com\/codership\/mysql-wsrep\" rel=\"nofollow noopener\" target=\"_blank\">MySQL-wsrep<\/a>\u00a0l\u00e0 phi\u00ean b\u1ea3n 25 v\u00e0\u00a0<a href=\"https:\/\/github.com\/codership\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">th\u01b0 vi\u1ec7n nh\u00e0 cung c\u1ea5p Galera wsrep<\/a>\u00a0l\u00e0 phi\u00ean b\u1ea3n 3.<\/li>\n<\/ul>\n<h3 id=\"Galera_4\">Galera 4<\/h3>\n<p>B\u1ea3ng sau li\u1ec7t k\u00ea t\u1eebng phi\u00ean b\u1ea3n c\u1ee7a\u00a0nh\u00e0 cung c\u1ea5p\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">Galera<\/a>\u00a04 wsrep v\u00e0 b\u1ea3ng li\u1ec7t k\u00ea phi\u00ean b\u1ea3n MariaDB n\u00e0o \u0111\u01b0\u1ee3c ph\u00e1t h\u00e0nh l\u1ea7n \u0111\u1ea7u ti\u00ean. N\u1ebfu b\u1ea1n mu\u1ed1n c\u00e0i \u0111\u1eb7t\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/galera\/\" rel=\"nofollow noopener\" target=\"_blank\">Galera<\/a>\u00a04 b\u1eb1ng\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/yum\/\" rel=\"nofollow noopener\" target=\"_blank\">yum<\/a>\u00a0,\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/installing-mariadb-deb-files\/#installing-mariadb-with-apt\" rel=\"nofollow noopener\" target=\"_blank\">apt<\/a>\u00a0ho\u1eb7c\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/installing-mariadb-with-zypper\/\" rel=\"nofollow noopener\" target=\"_blank\">zypper<\/a>\u00a0, th\u00ec g\u00f3i \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 galera-4 .<\/p>\n<div class=\"cstm-style centered darkheader-nospace-borders\">\n<table>\n<tbody>\n<tr>\n<th>Phi\u00ean b\u1ea3n Galera<\/th>\n<th>\u0110\u01b0\u1ee3c ph\u00e1t h\u00e0nh trong phi\u00ean b\u1ea3n MariaDB<\/th>\n<\/tr>\n<tr>\n<td><strong>26.4.4<\/strong><\/td>\n<td><a href=\"https:\/\/mariadb.com\/kb\/en\/mariadb-1051-release-notes\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.5.1<\/a><\/td>\n<\/tr>\n<tr>\n<td><strong>26.4.3<\/strong><\/td>\n<td><a href=\"https:\/\/mariadb.com\/kb\/en\/mariadb-1050-release-notes\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.5.0<\/a>\u00a0,\u00a0<a href=\"https:\/\/mariadb.com\/kb\/en\/mariadb-1049-release-notes\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.4.9<\/a><\/td>\n<\/tr>\n<tr>\n<td><strong>26.4.2<\/strong><\/td>\n<td><a href=\"https:\/\/mariadb.com\/kb\/en\/mariadb-1044-release-notes\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.4.4<\/a><\/td>\n<\/tr>\n<tr>\n<td><strong>26.4.1<\/strong><\/td>\n<td><a href=\"https:\/\/mariadb.com\/kb\/en\/mariadb-1043-release-notes\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.4.3<\/a><\/td>\n<\/tr>\n<tr>\n<td><strong>26.4.0<\/strong><\/td>\n<td><a href=\"https:\/\/mariadb.com\/kb\/en\/mariadb-1042-release-notes\/\" rel=\"nofollow noopener\" target=\"_blank\">MariaDB 10.4.2<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p><span style=\"color: #ff0000;\">Ch\u00fa \u00fd: H\u01b0\u1edbng d\u1eabn n\u00e0y ch\u1ec9 \u00a0th\u1ef1c hi\u1ec7n tr\u00ean m\u00e1y ch\u1ee7 MariaDB stable hi\u1ec7n t\u1ea1i l\u00e0 10.4 v\u00e0 galera 4, do v\u1eady c\u00e1c phi\u00ean b\u1ea3n MariaDB \u00a0c\u0169 h\u01a1n s\u1ebd c\u00f3 c\u00e1ch c\u00e0i kh\u00e1c m\u00e0 t\u00f4i s\u1ebd kh\u00f4ng \u0111\u1ec1 c\u1eadp \u0111\u1ebfn. C\u00e1c h\u01b0\u1edbng d\u1eabn d\u01b0\u1edbi \u0111\u00e2y s\u1ebd r\u1ea5t ng\u1eafn g\u1ecdn v\u00e0 chi ti\u1ebft, vui l\u00f2ng \u0111\u1ecdc k\u1ef9 \u0111\u1ec3 tr\u00e1nh\u00a0 kh\u00f4ng kh\u1edfi t\u1ea1o \u0111\u01b0\u1ee3c Galera.<\/span><\/p>\n<p>H\u01b0\u1edbng d\u1eabn n\u00e0y th\u1ef1c hi\u1ec7n tr\u00ean c\u01a1 s\u1edf m\u00e1y ch\u1ee7 nh\u01b0 sau:<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 96px;\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 25%; height: 24px;\">T\u00ean<\/td>\n<td style=\"width: 25%; height: 24px;\">IP<\/td>\n<td style=\"width: 25%; height: 24px;\">H\u1ec7 \u0111i\u1ec1u h\u00e0nh<\/td>\n<td style=\"width: 25%; height: 24px;\">Phi\u00ean b\u1ea3n MariaDB<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 25%; height: 24px;\">node1<\/td>\n<td style=\"width: 25%; height: 24px;\">103.130.218.7<\/td>\n<td style=\"width: 25%; height: 24px;\">CentOS 7<\/td>\n<td style=\"width: 25%; height: 24px;\">MariaDB 10.4<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 25%; height: 24px;\">node2<\/td>\n<td style=\"width: 25%; height: 24px;\">103.130.218.26<\/td>\n<td style=\"width: 25%; height: 24px;\">CentOS 7<\/td>\n<td style=\"width: 25%; height: 24px;\">MariaDB 10.4<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 25%; height: 24px;\">node3<\/td>\n<td style=\"width: 25%; height: 24px;\">103.130.219.13<\/td>\n<td style=\"width: 25%; height: 24px;\">CentOS 7<\/td>\n<td style=\"width: 25%; height: 24px;\">MariaDB 10.4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"C\u00e1c_port_m\u1ea1ng_c\u1ea7n_m\u1edf_tr\u00ean_c\u1ee5m\">C\u00e1c port m\u1ea1ng c\u1ea7n m\u1edf tr\u00ean c\u1ee5m<\/h2>\n<ul>\n<li><strong>Standard MariaDB Port<\/strong> (default: 3306) D\u00e0nh cho c\u00e1c k\u1ebft n\u1ed1i\u00a0 MySQL client.<\/li>\n<li><strong>Galera Replication Port<\/strong> (default: 4567) D\u00e0nh cho traffic truy c\u1eadp replication Galera,\u00a0 s\u1eed d\u1ee5ng c\u1ea3 truy\u1ec1n t\u1ea3i UDP v\u00e0 TCP tr\u00ean c\u1ed5ng n\u00e0y.<\/li>\n<li><strong>IST Port<\/strong> (default: 4568) D\u00e0nh cho chuy\u1ec3n tr\u1ea1ng th\u00e1i t\u0103ng d\u1ea7n.<\/li>\n<li><strong>SST Port<\/strong> (default: 4444) D\u00e0nh cho t\u1ea5t c\u1ea3 c\u00e1c ph\u01b0\u01a1ng th\u1ee9c <a href=\"https:\/\/mariadb.com\/kb\/en\/introduction-to-state-snapshot-transfers-ssts\/\" rel=\"nofollow noopener\" target=\"_blank\">State Snapshot Transfer<\/a> .<\/li>\n<\/ul>\n<h2 id=\"C\u00e0i_\u0111\u1eb7t_MariaDB_Galera_Cluster\">C\u00e0i \u0111\u1eb7t MariaDB Galera Cluster<\/h2>\n<p>\u0110\u1ec3 s\u1eed d\u1ee5ng MariaDB Galera Cluster, c\u00f3 hai g\u00f3i ch\u00ednh m\u00e0 b\u1ea1n c\u1ea7n c\u00e0i \u0111\u1eb7t:<\/p>\n<ol>\n<li>Phi\u00ean b\u1ea3n MariaDB Server h\u1ed7 tr\u1ee3 Galera Cluster.<\/li>\n<li>Th\u01b0 vi\u1ec7n\u00a0 Galera wsrep.<\/li>\n<\/ol>\n<p>C\u00e0i \u0111\u1eb7t MariaDB, galera, rsync tr\u00ean c\u00e1c m\u00e1y ch\u1ee7 b\u1eb1ng l\u1ec7nh sau(ch\u00fa \u00fd l\u00e0 t\u1ea5t c\u1ea3 m\u00e1y ch\u1ee7)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\"># C\u00e0i \u0111\u1eb7t yum repo\r\ncurl -sS https:\/\/downloads.mariadb.com\/MariaDB\/mariadb_repo_setup | bash -s -- --mariadb-server-version=\"mariadb-10.4\"\r\n\r\n# c\u00e0i \u0111\u1eb7t MariaDB v\u00e0 c\u00e1c g\u00f3i c\u1ea7n thi\u1ebft.\r\nyum install MariaDB-server MariaDB-client galera-4 rsync lsof -y\r\n# trong qu\u00e1 t\u00ecnh c\u00e0i \u0111\u1eb7t  nh\u1ea5n \"y\" \u0111\u1ec3 ch\u1ea5p nh\u1eadn c\u00e0i \u0111\u1eb7t c\u00e1c g\u00f3i.\r\n\r\n# c\u00e0i \u0111\u1eb7t mysql_secure_installation tr\u00ean node \u0111\u1ea7u ti\u00ean, c\u00e1c node kh\u00e1c kh\u00f4ng c\u1ea7n c\u00e0i.\r\nsystemctl start mariadb\r\nsystemctl enable mariadb\r\nmysql_secure_installation\r\nsystemctl stop mariadb<\/pre>\n<p>Sau khi c\u00e0i \u0111\u1eb7t ho\u00e0n t\u1ea5t, b\u1ea1n kh\u00f4ng kh\u1edfi \u0111\u1ed9ng v\u00e0 ti\u1ebfn h\u00e0nh thi\u1ebft l\u1eadp trong file my.cnf c\u1ee7a c\u00e1c m\u00e1y ch\u1ee7 nh\u01b0 sau(ch\u00fa \u00fd thay \u0111\u1ed5i IP v\u00e0 t\u00ean node trong ph\u1ea7n &#8220;Galera Node Configuration&#8221; t\u00f9y theo m\u1ed7i server):<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[mariadb]\r\n\r\nbind-address=0.0.0.0\r\nbinlog_format=ROW\r\ndefault_storage_engine=InnoDB\r\ninnodb_autoinc_lock_mode=2\r\nquery_cache_size=0\r\n\r\n\r\n# Galera Provider Configuration\r\nwsrep_on=ON\r\nwsrep_provider=\/usr\/lib64\/galera-4\/libgalera_smm.so\r\n\r\n# Galera Cluster Configuration\r\nwsrep_cluster_name=\"mariadb_cluster\"\r\nwsrep_cluster_address= \"gcomm:\/\/103.130.218.7,103.130.218.26,103.130.219.13\"\r\n\r\n# Galera Synchronization Configuration\r\nwsrep_sst_method=rsync\r\n\r\n# Galera Node Configuration\r\nwsrep_node_address=103.130.218.7\r\nwsrep_node_name=node1<\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: 24pt;\">Kh\u1edfi \u0111\u1ed9ng MariaDB Galera Cluster<\/span><\/p>\n<p>Sau khi c\u1ea5u h\u00ecnh ho\u00e0n t\u1ea5t nh\u01b0 tr\u00ean, ch\u00fang ta truy c\u1eadp node1 v\u00e0 ch\u1ea1y l\u1ec7nh sau \u0111\u1ec3 kh\u1edfi \u0111\u1ed9ng Galera (ch\u00fa \u00fd kh\u1edfi \u0111\u1ed9ng Galera tr\u00ean node1 s\u1ebd kh\u1edfi \u0111\u1ed9ng MariaDB n\u00ean kh\u00f4ng ph\u1ea3i ch\u1ea1y l\u1ec7nh \u0111\u1ec3 start MariaDB n\u1eefa).<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">galera_new_cluster<\/pre>\n<p>n\u1ebfu ch\u1ea1y l\u1ec7nh tr\u00ean kh\u00f4ng nh\u1eadn \u0111\u01b0\u1ee3c k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 t\u1ee9c l\u00e0 \u0111\u00e3 kh\u1edfi t\u1ea1o galera th\u00e0nh c\u00f4ng, ta c\u00f3 th\u1ec3 ch\u1ea1y l\u1ec7nh sau \u0111\u1ec3 ki\u1ec3m tra c\u00f3 bao nhi\u00eau node \u0111ang tham gia trong galera.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">MariaDB [(none)]&gt; SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';\r\n+--------------------+-------+\r\n| Variable_name      | Value |\r\n+--------------------+-------+\r\n| wsrep_cluster_size | 1     |\r\n+--------------------+-------+\r\n1 row in set (0.001 sec)<\/pre>\n<p>Nh\u01b0 v\u1eady l\u00e0 node1 \u0111\u00e3 ho\u1ea1t \u0111\u1ed9ng trong galera, ti\u1ebfp \u0111\u1ebfn ta truy c\u1eadp node 2 v\u00e0 kh\u1edfi \u0111\u1ed9ng MariaDB, Galera s\u1ebd t\u1ef1 include c\u00e1c node v\u00e0o Galera.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@node2db ~]# systemctl start mariadb<\/pre>\n<p>V\u00e0 ti\u1ebfp t\u1ee5c kh\u1edfi \u0111\u1ed9ng MariaDB tr\u00ean node3<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@node3db ~]# systemctl start mariadb<\/pre>\n<p>N\u1ebfu kh\u00f4ng c\u00f3 l\u1ed7i g\u00ec th\u00ec node2 v\u00e0 node3 \u0111\u00e3 \u0111\u01b0\u1ee3c th\u00eam v\u00e0o Galera, ch\u00fang ta ki\u1ec3m tra l\u1ea1i th\u1eed nh\u00e9:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">MariaDB [(none)]&gt; SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size';\r\n+--------------------+-------+\r\n| Variable_name      | Value |\r\n+--------------------+-------+\r\n| wsrep_cluster_size | 3     |\r\n+--------------------+-------+\r\n1 row in set (0.001 sec)<\/pre>\n<p>Nh\u01b0 v\u1eady l\u00e0 Galera \u0111\u00e3 \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh ho\u00e0n t\u1ea5t, ta ki\u1ec3m tra ho\u1ea1t \u0111\u1ed9ng\u00a0 \u0111\u01a1n gi\u1ea3n b\u1eb1ng c\u00e1ch t\u1ea1o ra 1 database tr\u00ean node1 v\u00e0 sau \u0111\u00f3 l\u1ea7n l\u01b0\u1ee3t ki\u1ec3m tra tr\u00ean node2 v\u00e0 node3 xem database m\u1edbi t\u1ea1o c\u00f3 \u0111\u01b0\u1ee3c \u0111\u1ed3ng b\u1ed9 sang c\u00e1c node n\u00e0y hay kh\u00f4ng<\/p>\n<p>Tr\u00ean node1 kh\u1edfi t\u1ea1o database name l\u00e0 &#8220;test_galera&#8221;:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@node1db ~]# mysql\r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 21\r\nServer version: 10.4.12-MariaDB MariaDB Server\r\n\r\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB [(none)]&gt; create database test_galera;\r\nQuery OK, 1 row affected (0.004 sec)<\/pre>\n<p>&nbsp;<\/p>\n<p>Tr\u00ean node2 ki\u1ec3m tra xem c\u00f3 database name &#8220;test_galera&#8221; hay kh\u00f4ng:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@node2db ~]# mysql\r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 14\r\nServer version: 10.4.12-MariaDB MariaDB Server\r\n\r\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB [(none)]&gt; show databases;\r\n+--------------------+\r\n| Database           |\r\n+--------------------+\r\n| information_schema |\r\n| mysql              |\r\n| performance_schema |\r\n| test_galera        |\r\n+--------------------+\r\n4 rows in set (0.001 sec)<\/pre>\n<p>&nbsp;<\/p>\n<p>Tr\u00ean node3 ki\u1ec3m tra xem c\u00f3 database name &#8220;test_galera&#8221; hay kh\u00f4ng:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">[root@node3db ~]# mysql\r\nWelcome to the MariaDB monitor.  Commands end with ; or \\g.\r\nYour MariaDB connection id is 13\r\nServer version: 10.4.12-MariaDB MariaDB Server\r\n\r\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.\r\n\r\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\r\n\r\nMariaDB [(none)]&gt; show databases;\r\n+--------------------+\r\n| Database           |\r\n+--------------------+\r\n| information_schema |\r\n| mysql              |\r\n| performance_schema |\r\n| test_galera        |\r\n+--------------------+\r\n4 rows in set (0.001 sec)<\/pre>\n<p>&nbsp;<\/p>\n<p>Nh\u01b0 v\u1eady l\u00e0 d\u1eef li\u1ec7u \u0111\u00e3 \u0111\u1ed3ng b\u1ed9 tr\u00ean c\u00e1c node server. C\u1ea5u h\u00ecnh MariaDB galera cluster ho\u00e0n t\u1ea5t t\u1ea1i \u0111\u00e2y. C\u00e1c v\u1ea5n \u0111\u1ec1 li\u00ean quan \u0111\u1ebfn vi\u1ec7c\u00a0 cluster, m\u1edf r\u1ed9ng cluster s\u1ebd \u0111\u01b0\u1ee3c tr\u00ecnh b\u00e0y trong c\u00e1c b\u00e0i sau.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MariaDB Galera l\u00e0 g\u00ec? MariaDB Galera l\u00e0 c\u1ee5m m\u00e1y ch\u1ee7 \u0111\u1ed3ng b\u1ed9 cho MariaDB.\u00a0N\u00f3 ch\u1ec9 kh\u1ea3 d\u1ee5ng tr\u00ean Linux v\u00e0 ch\u1ec9 h\u1ed7 tr\u1ee3 c\u00e1c\u00a0c\u00f4ng c\u1ee5 l\u01b0u tr\u1eef\u00a0XtraDB \/ InnoDB. \u0110\u1eb7c tr\u01b0ng Synchronous replication C\u1ea5u tr\u00fac li\u00ean k\u1ebft Active-active multi-master \u0110\u1ecdc v\u00e0 ghi v\u00e0o b\u1ea5t k\u1ef3 node server Ki\u1ec3m so\u00e1t c\u00e1c node t\u1ef1 \u0111\u1ed9ng, c\u00e1c node [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[5156],"class_list":["post-4163","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-mariadb"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=4163"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4163\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=4163"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=4163"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=4163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}