Apache ZooKeeper the Stackable Way
source link: https://devops.datenkollektiv.de/apache-zookeeper-the-stackable-way.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Welcome to the second part of our series "Hello, Stackable Data Platform" an introduction to the Stackable Data Platform - it's about Apache ZooKeeper.
This document describes how to use:
- Stackable Operator for Apache ZooKeeper to operate a tool for distributed coordination.
Apache ZooKeeper - Apache ZooKeeper is an effort to develop and maintain an open-source server which enables highly reliable distributed coordination
Install Apache ZooKeeper itself
As in the forerunner Stackable Building-Block Authorization-as-Code we'll use helmfile
to get started quickly:
# Stackable Operator for Apache ZooKeeper # https://docs.stackable.tech/home/getting_started.html#_installing_stackable_operators repositories: # helm repo add stackable-devel https://repo.stackable.tech/repository/helm-dev/ - name: stackable-devel url: 'https://repo.stackable.tech/repository/helm-dev/' releases: # helm install zookeeper-operator stackable-devel/zookeeper-operator --version 0.9.0-mr338 - name: zookeeper-operator devel: true chart: stackable-devel/zookeeper-operator # https://repo.stackable.tech/#browse/search/helm=name.raw%3Dzookeeper-operator version: "0.9.0-mr338" installed: true
Tip: Please find the
helm
commands provided as inline documentation, in case you prefer plain helm commands.
$ kubectl apply -f k8s/zookeeper-cluster.yaml zookeepercluster.zookeeper.stackable.tech/stackable-zookeeper created
$ kubectl get pods NAME READY STATUS RESTARTS AGE stackable-zookeeper-operator-9c4694444-rhvvh 1/1 Running 0 8m44s zookeeper-stackablezookeeper-server-default-zookeep-2r7lf 1/1 Running 0 2m8s zookeeper-stackablezookeeper-server-default-zookeep-6r42q 1/1 Running 0 69s zookeeper-stackablezookeeper-server-default-zookeep-ndc5c 0/1 ContainerCreating 0 23s
Test the ZooKeeper Installation
The easiest way seems to jump into the ZooKeeper pod.
Inspired by ZooKeeper Getting Started Guide you could run basic checks inside the pod like:
$ ZOOKEEPER_NAME=$(kubectl --kubeconfig ${WORKDIR}/tmp/stackable-cluster-kubeconfig.yaml get pods \ --selector app.kubernetes.io/name=zookeeper -o json \ | jq -r '.items[0].metadata.name') $ kubectl --kubeconfig ${WORKDIR}/tmp/stackable-cluster-kubeconfig.yaml \ exec --stdin --tty ${ZOOKEEPER_NAME} \ -- /bin/bash -c "bin/zkCli.sh -server 127.0.0.1:2181"
You should get a similar output with a prompt at the end:
... Connecting to 127.0.0.1:2181 ... Welcome to ZooKeeper! ... [zk: 127.0.0.1:2181(CONNECTED) 0]
You can try such a command with the following output:
[zk: 127.0.0.1:2181(CONNECTED) 0] ls / [zookeeper]
More ZooKeeper commands to explore the installation:
create /zk_test my_data
get /zk_test
delete /zk_test
First Contact with Spring Boot
A basic Spring Cloud Zookeeper app only needs a few dependecies:
dependencies { implementation 'org.springframework.cloud:spring-cloud-starter-zookeeper' implementation 'org.apache.curator:curator-framework:5.1.0' }
...then you can list the ZooKeeper content with a CommandLineRunner
:
@SpringBootApplication public class ZooKeeperList implements CommandLineRunner { private static final Logger LOG = LoggerFactory.getLogger(ZooKeeperList.class); public static void main(String[] args) { SpringApplication.run(ZooKeeperList.class, args); } @Override public void run(String... args) throws Exception { CuratorFramework curator = CuratorFrameworkFactory.builder() .retryPolicy(new RetryOneTime(500)) .connectString("localhost:2181").build(); curator.start(); List<String> children = curator.getChildren().forPath("/"); for (String child : children) { LOG.info("Found child: {}", child); } } }
Without further ado, this results in:
... Found child: zookeeper Found child: druid Found child: zk_test ...
Hint: For more details please check Spring Cloud Zookeeper - documentation
👏 Congratulations! The first tool of your modern data platform is up and running. The next installment of this series will tackle an Apache Kafka installation. Stay tuned...
Additional resources
🙌 Photo by Anthony Yin on Unsplash
Recommend
-
27
README.md Popbox.js Popbox.js is a tiny javascript plugin for creating stackable modals. It is fully customizable and dependency free.
-
4
Stackable Raspberry Pi HAT provides up to 64 Resistance Temperature Detectors Jul 28, 2020 — by Eric Brown —...
-
11
vue-modal A customizable, stackable, and lightweight modal component for Vue. vue-modal is designed with web applications in mind and tries to stick as much as possible to the accessibility best practices set i...
-
4
HyperJuice Stackable 体验:可以合体的充电头,能代替我的拖板吗 去年,充电厂牌 HyperJuice 推出了一个可纵向叠加的 GaN 充电头方案 HyperJuice Stackable GaN Charger,并在 kickstarter 上开启了众筹。 最近,...
-
6
i.MX8M Plus powered Pico-ITX has stackable expansion board Aug 13, 2021 — by Eric Brown — 234 views
-
2
Home Menu...
-
5
Home Menu...
-
2
Hyper Recalls HyperJuice GaN Stackable Chargers and 130W Battery Pack Due to Fire Risk MacRumors
-
5
Hyper officially recalls its stackable (and overheating) GaN chargers after allHyper officially recalls its stackable (and overheating) GaN chargers after all / One of its 130W USB-C battery packs is also aff...
-
2
Get 30% off stretch-link and stackable metal Apple Watch bands
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK