Maitiro ekuisa MariaDB Galera Cluster pane Ubuntu 16.04

Maitiro ekuisa MariaDB Galera Cluster pane Ubuntu 16.04

MariaDB Galera is a multi-master cluster yaMariaDB. Kubva MariaDB 10.1, iyo MariaDB Server uye MariaDB Galera Server mapakeji akabatanidzwa uye Galera mapakeji uye kwavo kutsamira vanozoiswa otomatiki kana uchiisa MariaDB. Parizvino, MariaDB Galera Cluster inongotsigira InnoDB / XtraDB injini yekuchengetedza. MuMariaDB 10.0 uye 5.5, iwe uchafanirwa kurodha pasi zvakasiyana. MariaDB Galera anowedzera redundancy kune saiti dhatabhesi. MuMariaDB Galera Cluster, akawanda maseva edhatabhesi akabatana pamwe chete uye anoramba achienderana.

MariaDB Galera inopa akawanda maficha, mamwe acho akanyorwa pazasi:

  1. Synchronous kudzokorora.
  2. Otomatiki node kujoina.
  3. Inoshanda-inoshanda yakawanda-tenzi topology.
  4. Yechokwadi yakafanana kudzokorora, padanho remutsara.
  5. Verenga uye nyora scalability, Mudiki mutengi latency.
  6. Yakundikana node, otomatiki kudonha kubva pasumbu.

Muchidzidzo ichi, isu tinotsanangura nzira yekumisikidza MariaDB Galera Cluster 10.1 ine 3 node inomhanya pane Ubuntu 16.04 server. Tichaedzawo kudzokorora dhatabhesi pakati penzvimbo dzese.

zvinodiwa

  • Node nhatu dzinomhanya Ubuntu 16.04 server.
  • Node1 ine static IP kero 192.168.0.102, Node2 ine static IP kero 192.168.0.103 uye Node3 ine static IP kero 192.168.0.104 inogadzirisa pane yako server.
  • Asiri-mudzi mushandisi aine sudo rombo ropafadzo kumisikidza pane ese maodhi.

kutanga

Kutanga, iwe unozofanirwa kugadzirisa ese maodhi pamwe neazvino vhezheni. Unogona kudzokorora dzese nemutemo unotevera:

sudo apt-get update -y
sudo apt-get upgrade -y

Tevere, tangazve iwo ese maodhi kuti ushandise shanduko idzi. Wobva wapinda mukati nemushandisi mushandisi uye enderera kunhanho inotevera.

Isa MariaDB Galera

MariaDB Server uye MariaDB Galera Server mapakeji akasanganiswa mune iyo vhezheni MariaDB 10.1. Nekutadza, MariaDB 10.1 haiwanike mune yakasarudzika Ubuntu repositories, saka iwe unozofanirwa kuwedzera MariaDB repository pane ese maodhi.

Kutanga, wedzera iyo MariaDB repository kiyi nemirairo inotevera:

sudo apt-kiyi zano -recv-makiyi -keyserver hkp: //keyserver.ubuntu.com: 80 0xF1656F24C74CD1D8

Tevere, wedzera iyo repository uye gadziridza iyo APT cache nemirairo inotevera:

sudo yekuwedzera-apt-repository 'deb [arch = amd64, i386, ppc64el] http://ftp.utexas.edu/mariadb/repo/10.1/ubuntu xenial main'
sudo apt-get update -y

Kamwe kana repository yagadziriswa, isa MariaDB nemirairo inotevera:

sudo apt-tora kuisa mariadb-server rsync -y

Iwo wekumusoro kuraira unoisa MariaDB neGalera uye akati wandei kutsamira. Izvo zvikamu zveGalera zvinoramba zvakagara kusvikira zvagadziriswa, kunge plugin kana injini yekuchengetedza. Kamwe iyo MariaDB yaiswa pane ese maodhi, iwe unogona kuenderera nekuchengetedza MariaDB.

Nokusingaperi MariaDB kuisirwa haina kuchengetedzwa, saka iwe uchafanirwa kuchengetedza MariaDB kuisirwa. Unogona kuita izvi nekumhanyisa iyo mysql_secure_installation script:

sudo mysql_secure_installation

Muchiitiko ichi, iwe unozobvunzwa kumisikidza mudzi password, bvisa vasingazivikanwe vashandisi, usarega midzi yekupinda uri kure uye kubvisa test database. Pindura mibvunzo yese sekuratidzwa pazasi:

Pinda password yazvino yemidzi (pinda pasina): Chinja iro password password? [Y / n] n Bvisa vashandisi vasingazivikanwe? [Y / n] Y Rega kubvumira midzi kupinda kure? [Y / n] Y Bvisa bvunzo dhatabhesi uye uwane kwariri? [Y / n] Y Dzorerazve matafura eropafadzo izvozvi? [Y / n] Y

Kamwe iyo MariaDB yakachengetedzwa pane ese maodhi, iwe unogona kuenderera kunhanho inotevera.

Setup MariaDB Cluster pane Node1

Kutanga, enda kuNode1 uye gadzira faira rekumisikidza yeGalera. Nekukanganisa, MariaDB inoverenga kumisikidzwa kubva /etc/mysql/conf.d/ dhairekitori. Kuti uite kudaro, mhanya unotevera kuraira:

sudo nano /etc/mysql/conf.d/galera.cnf

Wedzera mitsara inotevera:

[mysqld] binlog_format = ROW default-yekuchengetera-injini = innodb innodb_autoinc_lock_mode = 2 kusunga-kero = 0.0.0.0 # Galera Provider Kugadziriswa wsrep_on = ON wsrep_provider = / usr / lib / galera / libgalera_smm.so # Galera Cluster Confera "wsrep_cluster_address =" gcomm: //192.168.0.102,192.168.0.103,192.168.0.104 "# Galera Synchronization Configuration

Sevha iyo faira kana wapedza.

Cherechedza: 192.168.0.102 ndiyo IP kero yeNode1

Wedzera Node2 paGalera Cluster

Tevere, enda kuNode2 uye gadzira iyo yekumisikidza faira yeGalera:

sudo nano /etc/mysql/conf.d/galera.cnf

Wedzera mitsara inotevera:

[mysqld] binlog_format = ROW default-yekuchengetera-injini = innodb innodb_autoinc_lock_mode = 2 kusunga-kero = 0.0.0.0 # Galera Provider Kugadziriswa wsrep_on = ON wsrep_provider = / usr / lib / galera / libgalera_smm.so # Galera Cluster Confera "wsrep_cluster_address =" gcomm: //192.168.0.102,192.168.0.103,192.168.0.104 "# Galera Synchronization Configuration

Sevha iyo faira kana wapedza.

Cherechedza: 192.168.0.103 ndiyo IP kero yeNode2.

Wedzera Node3 paGalera Cluster

Tevere, enda kuNode3 uye gadzira iyo yekumisikidza faira yeGalera:

sudo nano /etc/mysql/conf.d/galera.cnf

Wedzera mitsara inotevera:

[mysqld] binlog_format = ROW default-yekuchengetera-injini = innodb innodb_autoinc_lock_mode = 2 kusunga-kero = 0.0.0.0 # Galera Provider Kugadziriswa wsrep_on = ON wsrep_provider = / usr / lib / galera / libgalera_smm.so # Galera Cluster Confera "wsrep_cluster_address =" gcomm: //192.168.0.102,192.168.0.103,192.168.0.104 "# Galera Synchronization Configuration

Sevha iyo faira kana wapedza.

Cherechedza: 192.168.0.104 ndiyo IP kero yeNode3.

Gadzira Firewall

Galera Cluster inoshandisa zvina zviteshi 3306 zveMySQL mutengi kubatana, 4444 yeHurumende Snapshot Transfer, 4567 yeGalera Cluster replication traffic uye 4568 yeExpensional State Transfer. Saka iwe unozofanirwa kubvumidza ese aya madoko uchishandisa iyo UFW firewall. Iwe unogona kuita izvi nekumhanyisa unotevera kuraira pane ese maodhi.

Kutanga, gonesa iyo UFW firewall nemirairo inotevera:

sudo ufw shandisa

Tevere, tendera iwo madoko ese nemirairo inotevera:

sudo ufw chirega 3306 / tcp
sudo ufw chirega 4444 / tcp
sudo ufw chirega 4567 / tcp
sudo ufw chirega 4568 / tcp
sudo ufw bvumira 4567 / udp

Iwe unogona ipapo kutarisa mamiriro eiyo firewall nemirairo inotevera:

sudo ufw chimiro

Kana iyo UFW firewall yagadziriswa pane ese maodhi, unogona kuenderera kunhanho inotevera.

Kutanga MariaDB Galera Cluster

Mushure mekubudirira kugadzirisa ese maodhi, enda kuNode1 uye utange Galera Cluster.

Pamberi peGalera isati yatanga, iwe unofanirwa kuona kuti MariaDB sevhisi inomiswa pane ese maodhi.

Mhanya unotevera kuraira pane ese maodhi.

sudo systemctl mira mysql

Zvino, tanga iyo Galera Cluster paNode1 nemirairo inotevera:

sudo galera_new_cluster

Zvino, tarisa kana sumbu racho riri kumhanya kana kuti kwete nemirairo inotevera:

mysql -u mudzi -p -e "ratidza chinzvimbo senge 'wsrep_cluster_size'"

Kana zvese zvanaka uchaona zvinotevera zvinobuda:

+ ---------------------- ------- + | Variable_name | Kukosha | + ---------------------- ------- + | wsrep_cluster_size | 1 | + ---------------------- ------- +

PaNode2, tanga iyo MariaDB sevhisi:

sudo systemctl tanga mysql

Unogona kutarisa chinzvimbo cheMariaDB sevhisi kunyangwe iri kushanda kana kwete nemirairo inotevera:

sudo systemctl chimiro mysql

Kana zvinhu zvose zvakanaka, unofanira kuona zvinotevera zvakabuda:

?? mariadb.service - MariaDB dhatabhesi server Yakatakurwa: yakatakura (/lib/systemd/system/mariadb.service; yakagoneswa; mutengesi preset: inogoneswa) Inoshanda: inoshanda (inomhanya) kubvira Sun 2017-09-17 10:11:20 EDT; 10min apfuura Maitiro: 715 ExecStartPost = / bin / sh -c systemctl isina kumisikidzwa-nharaunda _WSREP_START_POSITION (kodhi = yakabuda, chinzvimbo = 0 / SUCCESS) Maitiro: 713 ExecStartPost = / etc / mysql / debian-start (kodhi = yakabuda, chinzvimbo = 0 / SUCCESS) Maitiro: 545 ExecStartPre = / bin / sh -c [! -e / usr / bin / galera_recovery] && VAR = || VAR = `/ usr / bin / galera_recovery`; [$? -eq 0] && systemctl setha Maitiro: 535 ExecStartPre = / bin / sh -c systemctl isina kugadziriswa-nharaunda _WSREP_START_POSITION (kodhi = yakabuda, chinzvimbo = 0 / KUSVIRA) Maitiro: 514 ExecStartPre = / usr / bin / gadza -m 755 -o mysql -g mudzi -d / var / run / mysqld (kodhi = yakabuda, chinzvimbo = 0 / KUSVIRA) Main PID: 661 (mysqld) Mamiriro: "Kutora zvako SQL zvikumbiro izvozvi ..." Mabasa: 26 (muganho: 4915) CGroup: /system.slice/mariadb.service ?????? 661 / usr / sbin / mysqld Sep 17 10:11:11 debian systemd [1]: Kutanga server yeMariaDB ... Sep 17 10:11:15 debian mysqld [661]: 2017-09-17 10:11:15 140287134630464 [Cherechedzo] / usr / sbin / mysqld (mysqld 10.1.26-MariaDB-0 + deb9u1) kutanga senzira Sep 17 10:11:20 debian systemd [1]: Yakatanga MariaDB dura re database

Zvino, yako yechipiri node inofanira kunge yakangoerekana yabatana nesumbu. Unogona kuona izvozvo nemurairo unotevera:

mysql -u mudzi -p -e "ratidza chinzvimbo senge 'wsrep_cluster_size'"

Kana zvese zviri kushanda nemazvo, saizi remasumbu rinofanira kuiswa kumaviri:

+ ---------------------- ------- + | Variable_name | Kukosha | + ---------------------- ------- + | wsrep_cluster_size | 2 | + ---------------------- ------- +

PaNode3, tanga iyo MariaDB sevhisi:

sudo systemctl tanga mysql
mysql -u mudzi -p -e "ratidza chinzvimbo senge 'wsrep_cluster_size'"

Kana zvese zviri kushanda nemazvo, saizi remasumbu rinofanira kuiswa kumatatu:

+ ---------------------- ------- + | Variable_name | Kukosha | + ---------------------- ------- + | wsrep_cluster_size | 3 | + ---------------------- ------- +

Iwe sumbu rava kushanda nekutaurirana.

Kwayedza Dhatabhesi Kudzokorora

Zvino, ese maodhi ari online, inguva yekuyedza kudzokorora kwedhatabhesi kune iyo Galera Cluster. Ngatitangei nekugadzira dhatabhesi paNode1 uye titarise kana yakadzokororwa pane ese maodhi.

Kutanga, pinda muMariaDb koni pamwe nemirairo inotevera:

mysql -u root -p

Pinda yako password password uye gadzira dhatabhesi ine zita test_db:

MariaDB [(hapana)]> gadzira dhatabhesi test_db;
MariaDB [(hapana)]> ratidza dhatabhesi;

+ -------------------- + | Dhatabhesi | + -------------------- + | test_db | + -------------------- +

Zvino enda kuNode2 neNode3, wobva watarisa kudzokorora kuri kushanda kana kwete:

mysql -u root -p
MariaDB [(hapana)]> ratidza dhatabhesi;

+ -------------------- + | Dhatabhesi | + -------------------- + | test_db | + -------------------- +

Makorokoto! iwe wakabudirira kuisa uye kugadzirisa MariaDB Galera Cluster pane Ubuntu 16.04 server.

mhedziso

Ndinovimba iwe wave neruzivo rwakakwana rwekugadza nekugadzirisa MariaDB Galera Cluster pane Ubuntu 16.04. Iwe unogona ikozvino kukwidziridzwa zviri nyore kusvika kune akati wandei, kana kunyangwe gumi, enzvimbo dzakasiyana. Kana iwe uine chero kusahadzika kana kumwe kubvunza, ipapo tarisa chinongedzo Galera Cluster Doc

mabviro