MODOP – QEMU HA – Partie 1 – Installation Cluster ZooKeeper

Inventaire

Host : node01-zookeeper

  • Disque /dev/sda: 32 Go
  • IP : 172.17.186.20
  • RAM :2Go
  • vCPU : 2
  • OS : RockyLinux 8

Host : node02-zookeeper

  • Disque /dev/sda: 32 Go
  • IP : 172.17.186.21
  • RAM :2Go
  • vCPU : 2
  • OS : RockyLinux 8

Host : node03-zookeeper

  • Disque /dev/sda: 32 Go
  • IP : 172.17.186.22
  • RAM :2Go
  • vCPU : 2
  • OS : RockyLinux 8

Le pool du Cluster

Mise à jour de la machine (3 noeuds)

[root@node0X-zookeeper ~]# yum update -y

Désactiver SELinux (3 noeuds)

[root@node0X-zookeeper ~]# vi /etc/selinux/config

Installation JAVA (3 noeuds)

[root@node0X-zookeeper ~]# yum -y install java-1.8.0-openjdk

User zooKeeper (3 noeuds)

[root@node0X-zookeeper ~]# useradd zk -m
[root@node0X-zookeeper ~]# passwd zk
[root@node0X-zookeeper ~]# usermod -aG wheel zk

Installation Apache-zookeeper (3 noeuds)

[root@node0X-zookeeper ~]# dnf install wget nc -y

[root@node0X-zookeeper ~]# cd /tmp
[root@node0x-zookeeper tmp]# wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.0/apache-zookeeper-3.8.0-bin.tar.gz
[root@node0x-zookeeper tmp]# tar -xvf apache-zookeeper-3.8.0-bin.tar.gz -C /opt
[root@node0x-zookeeper tmp]# cd /opt
[root@node0x-zookeeper opt]# mv apache-zookeeper-3.8.0-bin zookeeper

Installation Firewalld (3 noeuds)

[root@node0X-zookeeper ~]# firewall-cmd --add-port={2181,2888,3888}/tcp --permanent --zone=public
[root@node0X-zookeeper ~]# firewall-cmd --reload
[root@node0X-zookeeper ~]# firewall-cmd --list-all

Configuration standalone zookeeper (node01)

[root@node01-zookeeper opt]# cd zookeeper/conf

[root@node01-zookeeper conf]# vi zoo.cfg
tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=172.17.186.20:2888:3888

[root@node01-zookeeper opt]# chown -R zk.zk /opt/zookeeper

Création de ID Machine (node01)

[root@node01-zookeeper conf]# mkdir /var/lib/zookeeper
[root@node01-zookeeper conf]# touch /var/lib/zookeeper/myid
[root@node01-zookeeper conf]# echo '1' > /var/lib/zookeeper/myid
[root@node01-zookeeper conf]# chown -R zk.zk /var/lib/zookeeper

CHECK Fonctionnement Standalone NODE 01 – CLI

Start Service (node01)

[root@node01-zookeeper conf]# cd ../bin
[root@node01-zookeeper bin]# ./zkServer.sh start

Check port Open (node01)

[root@node01-zookeeper bin]# netstat -antp

Check Status (node01)

[root@node01-zookeeper bin]# ./zkServer.sh status

Check Connect server Standalone (node01)

[root@node01-zookeeper bin]# ./zkCli.sh -server 127.0.0.1:2181

[root@node01-zookeeper bin]# ./zkServer.sh stop

Création du service pour ZooKeeper ( 3 noeuds)

[root@node0x-zookeeper bin]# cd ~
[root@node0x-zookeeper ~]# vi /etc/systemd/system/zk.service

[Unit]
Description=Zookeeper Daemon
Documentation=http://zookeeper.apache.org
Requires=network.target
After=network.target

[Service] 
Type=forking
WorkingDirectory=/opt/zookeeper
ExecStart=/opt/zookeeper/bin/zkServer.sh start /opt/zookeeper/conf/zoo.cfg
ExecStop=/opt/zookeeper/bin/zkServer.sh stop /opt/zookeeper/conf/zoo.cfg
ExecReload=/opt/zookeeper/bin/zkServer.sh restart /opt/zookeeper/conf/zoo.cfg
TimeoutSec=30
Restart=on-failure

[Install]
WantedBy=default.target

[root@node0x-zookeeper ~]# systemctl daemon-reload

Démarrage du Service (node01)

[root@node01-zookeeper ~]# systemctl start zk.service
[root@node01-zookeeper ~]# systemctl status zk.service

[root@node01-zookeeper ~]# systemctl stop zk.service

Installation Zookeeper mode Cluster ( 3 noeuds)

Création fichier du fichier zoo.conf cluster ( 3 noeuds)

[root@node0x-zookeeper ~]# vi /opt/zookeeper/conf/zoo.cfg

tickTime=2000
dataDir=/var/lib/zookeeper
clientPort=2181
initLimit=5
syncLimit=2
server.1=172.17.186.20:2888:3888
server.2=172.17.186.21:2888:3888
server.3=172.17.186.22:2888:3888

[root@node0x-zookeeper ~]# chown -R zk.zk /opt/zookeeper/conf/zoo.cfg

Création de ID Machine ( 3 noeuds)

[root@node0x-zookeeper ~]# mkdir /var/lib/zookeeper
[root@node0x-zookeeper ~]# touch /var/lib/zookeeper/myid

Node1
[root@node01-zookeeper ~]# echo '1' > /var/lib/zookeeper/myid

Node2
[root@node02-zookeeper ~]# echo '2' > /var/lib/zookeeper/myid

Node3
[root@node03-zookeeper ~]# echo '3' > /var/lib/zookeeper/myid

[root@node0x-zookeeper ~]# chown -R zk.zk /var/lib/zookeeper

Démarrage du Service ( 3 noeuds)

[root@node0x-zookeeper ~]# systemctl start zk.service
[root@node0x-zookeeper ~]# systemctl status zk.service


Node01


Node02


Node03

[root@node0x-zookeeper ~]# systemctl enable zk.service

Check Cluster

Côté logs

[root@node01-zookeeper ~]#tail –f /opt/zookeeper/logs/zookeeper--server-node01-zookeeper.out

Côté statut

[root@node01-zookeeper ~]# /opt/zookeeper/bin/zkServer.sh status

[root@node02-zookeeper ~]# /opt/zookeeper/bin/zkServer.sh status

[root@node03-zookeeper ~]# /opt/zookeeper/bin/zkServer.sh status

Check avec module

[root@node0x-zookeeper ~]# systemctl stop zk.service
[root@node0x-zookeeper ~]# echo "4lw.commands.whitelist=stat, ruok, conf, isroi, mntr" >> /opt/zookeeper/conf/zoo.cfg

[root@node0x-zookeeper ~]# systemctl start zk.service
[root@node01-zookeeper ~]# echo stat | nc localhost 2181

[root@node01-zookeeper ~]# echo conf | nc localhost 2181

[root@node01-zookeeper ~]# echo mntr | nc localhost 2181

[root@node01-zookeeper ~]# /opt/zookeeper/bin/zkCli.sh -server 172.17.186.20:2181,172.17.186.21:2181,172.17.186.22:2181

Views: 9

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *