Docker Cookbook


DATA: Building a MySQL Galera Cluster on a Docker Network | 319



Download 6,31 Mb.
Pdf ko'rish
bet248/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   244   245   246   247   248   249   250   251   ...   260
Bog'liq
Docker Cookbook

10.5 DATA: Building a MySQL Galera Cluster on a Docker Network | 319


The 
consul-server
machine is currently used by Docker Network, but this may
change. Currently we use this Consul server as a key-value store; the Docker engine
on each host uses it to store information about each host. As a reminder, check the
Vagrantfile and see the 
DOCKER_OPTS
specified at start-up; you will see that we also
define a default overlay network called 
multihost
.
Once the machines are up
ssh
to the first one and start the first node of your Galera
cluster by using the image 
erkules/galera:basic
. You can check the 
reference
 to see
what is in the Dockerfile used to build this image.
Let’s do it:
$ vagrant ssh mysql-1
$ docker run -d --name node1 -h node1 erkules/galera:basic \
--wsrep-cluster-name=local-test \
--wsrep-cluster-address=gcomm://
Get on host 
mysql-2
and start two additional Galera nodes. Note that you use the
node name 
node1
for the cluster address. This will work because Docker Network will
automatically properly define the 
/etc/hosts
file and it will contain the IP address of
node1

node2
, and 
node3
. Since the three containers are in the same overlay, they will
be able to reach one another without any port mapping, container linking, or other
more complex network setup:
$ vagrant ssh mysql-2
$ docker run --detach=true --name node2 -h node2 erkules/galera:basic \
--wsrep-cluster-name=local-test \
--wsrep-cluster-address=gcomm://node1
$ docker run --detach=true --name node3 -h node3 erkules/galera:basic \
--wsrep-cluster-name=local-test \
--wsrep-cluster-address=gcomm://node1
Back on 
mysql-1
, you will see that after a short time, the two nodes started on
mysql-2
have automatically joined the cluster:
$ docker exec -ti node1 mysql -e 'show status like "wsrep_cluster_size"'
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 3 |
+--------------------+-------+
And indeed the 
/etc/hosts
file on the 
node1
container has the IP address of the other
two nodes:
$ docker exec -ti node1 cat /etc/hosts
...
172.21.0.6 node1.multihost
172.21.0.6 node1
172.21.0.8 node2
172.21.0.8 node2.multihost

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   244   245   246   247   248   249   250   251   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish