Introduction à azkaban et introduction au déploiement, principe et utilisation d'azkaban

Introduction à azkaban et introduction au déploiement, principe et utilisation d'azkaban

Introduction à Azkaban

Azkaban est un service de planification de tâches simple, composé de trois parties : le serveur Web, le serveur de base de données et le serveur exécuteur.
Azkaban est un projet Java open source de Linkedin, un planificateur de tâches de workflow par lots. Utilisé pour exécuter un ensemble de tâches et de processus dans un ordre spécifique au sein d'un flux de travail.
Azkaban définit un format de fichier KV pour établir des dépendances entre les tâches et fournit une interface utilisateur Web facile à utiliser pour maintenir et suivre votre flux de travail.

Site officiel du projet : https://azkaban.github.io/

Caractéristiques d’Azkaban

1. Interface utilisateur Web
2. Pratique pour télécharger le flux de travail
3. Pratique pour définir la relation entre les tâches
4. Planification du flux de travail
5. Authentification/autorisation
6. Possibilité de supprimer et de redémarrer le flux de travail
7. Modularisation et mécanisme de plug-in enfichable
8. Espace de travail du projet
9. Journalisation et audit des flux de travail et des tâches

installation et déploiement d'Azkaban

Préparation:

L'installation et le déploiement nécessitent 3 composants :

azkaban-executor-server-2.5.0.tar.gz
azkaban-sql-script-2.5.0.tar.gz
azkaban-web-server-2.5.0.tar.gz

Adresse de connexion de partage de disque réseau : https://pan.baidu.com/s/1mMuIuVv9Ji6yO2A2b8Ibrg
Code d'extraction : seld
[Remarque :] Déployez le service mysql à l'avance. L'installation de mysql n'est pas présentée ici.

Installer les composants :

# 上传安装包
wangting@ops01:/opt/software/azkaban >ll
total 22612
-rw-r--r-- 1 root root 11157302 May 16 10:45 azkaban-executor-server-2.5.0.tar.gz
-rw-r--r-- 1 root root     1928 May 16 10:45 azkaban-sql-script-2.5.0.tar.gz
-rw-r--r-- 1 root root 11989669 May 16 10:45 azkaban-web-server-2.5.0.tar.gz
# 创建应用目录,利于解压多组件都在一个管理目录中
wangting@ops01:/opt/software/azkaban >mkdir /opt/module/azkaban
wangting@ops01:/opt/software/azkaban >tar -xf azkaban-executor-server-2.5.0.tar.gz -C /opt/module/azkaban/
wangting@ops01:/opt/software/azkaban >tar -xf azkaban-sql-script-2.5.0.tar.gz -C /opt/module/azkaban/
wangting@ops01:/opt/software/azkaban >tar -xf azkaban-web-server-2.5.0.tar.gz -C /opt/module/azkaban/
wangting@ops01:/opt/software/azkaban >ls /opt/module/azkaban/
azkaban-2.5.0  azkaban-executor-2.5.0  azkaban-web-2.5.0
wangting@ops01:/opt/software/azkaban >
wangting@ops01:/opt/software/azkaban >cd /opt/module/azkaban/
wangting@ops01:/opt/module/azkaban >ll
total 12
drwxrwxr-x 2 wangting wangting 4096 May 16 10:48 azkaban-2.5.0
drwxrwxr-x 7 wangting wangting 4096 May 16 10:47 azkaban-executor-2.5.0
drwxrwxr-x 8 wangting wangting 4096 May 16 10:48 azkaban-web-2.5.0
# 改名,易于管理和切换目录
wangting@ops01:/opt/module/azkaban >mv azkaban-executor-2.5.0 executor
wangting@ops01:/opt/module/azkaban >mv azkaban-web-2.5.0 server
wangting@ops01:/opt/module/azkaban >ll
total 12
drwxrwxr-x 2 wangting wangting 4096 May 16 10:48 azkaban-2.5.0
drwxrwxr-x 7 wangting wangting 4096 May 16 10:47 executor
drwxrwxr-x 8 wangting wangting 4096 May 16 10:48 server
wangting@ops01:/opt/module/azkaban >
# azkaban-2.5.0目录下sql文件用于后面azkaban数据库项目初始化
wangting@ops01:/opt/module/azkaban >ls azkaban-2.5.0/
create.active_executing_flows.sql  create.execution_flows.sql  create.project_events.sql  create.project_permissions.sql  create.project_versions.sql  create.triggers.sql     update-all-sql-2.2.sql
create.active_sla.sql              create.execution_jobs.sql   create.project_files.sql   create.project_properties.sql   create.properties.sql        database.properties     update.execution_logs.2.1.sql
create-all-sql-2.5.0.sql           create.execution_logs.sql   create.project_flows.sql   create.projects.sql             create.schedules.sql         update-all-sql-2.1.sql  update.project_properties.2.1.sql
# 查看本机IP 和mysql服务是否正常运行着
wangting@ops01:/opt/module/azkaban >ifconfig eth0 |grep "inet "
        inet 11.8.37.50  netmask 255.255.255.0  broadcast 11.8.37.255
wangting@ops01:/opt/module/azkaban >netstat -tnlpu|grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      -                   
# 登录mysql
wangting@ops01:/opt/module/azkaban >mysql -uroot -pwangting
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37069
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 创建azkaban库
mysql> create database azkaban;
Query OK, 1 row affected (0.00 sec)

mysql> use azkaban;
Database changed
mysql> show tables;
Empty set (0.00 sec)
# 初始化
mysql> source /opt/module/azkaban/azkaban-2.5.0/create-all-sql-2.5.0.sql
mysql> show tables;
+------------------------+
| Tables_in_azkaban      |
+------------------------+
| active_executing_flows |
| active_sla             |
| execution_flows        |
| execution_jobs         |
| execution_logs         |
| project_events         |
| project_files          |
| project_flows          |
| project_permissions    |
| project_properties     |
| project_versions       |
| projects               |
| properties             |
| schedules              |
| triggers               |
+------------------------+
15 rows in set (0.00 sec)
# 完成退出
mysql> exit
Bye
wangting@ops01:/opt/module/azkaban >
wangting@ops01:/opt/module/azkaban >cd server
wangting@ops01:/opt/module/azkaban/server >pwd
/opt/module/azkaban/server

# 生成认证  keystore jetty 都是配置文件中对应的名称
wangting@ops01:/opt/module/azkaban/server >keytool -keystore keystore -alias jetty -genkey -keyalg RSA
Enter keystore password:  			# wangting   密码可以自定义
Re-enter new password: 				# wangting	 重复密码
What is your first and last name?		# 回车
  [Unknown]:  
What is the name of your organizational unit?	# 回车
  [Unknown]:  
What is the name of your organization?		# 回车
  [Unknown]:  
What is the name of your City or Locality?	# 回车
  [Unknown]:  
What is the name of your State or Province?	# 回车
  [Unknown]:  
What is the two-letter country code for this unit?	# 回车
  [Unknown]:  
Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?		# y
  [no]:  y

Enter key password for <wangting>
	(RETURN if same as keystore password):  	# 回车 

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore keystore -destkeystore keystore -deststoretype pkcs12".
wangting@ops01:/opt/module/azkaban/server >
# 查看一下时区
wangting@ops01:/opt/module/azkaban/server >cat /etc/localtime 
TZifǚ^	??ˊ??л>???-???????fp???|?? i ~?!I}"g? #)_$G %|&'e &??G (р~pCDTCSTTZif2 
                                                                      6C)????ǚ^????	?????????ˊ????@????л>????{?????-????"????????????????fp??????????|?? i ~?!I}"g? #)_$G %|&'e &??G (рq?LMTCDTCST
CST-8

# 最后需要时CST-8,如果不是CST-8 东八区时区需要调置

wangting@ops01:/opt/module/azkaban/server >cd conf/
# 更改server配置
wangting@ops01:/opt/module/azkaban/server/conf >ls
azkaban.properties  azkaban-users.xml
wangting@ops01:/opt/module/azkaban/server/conf >vim azkaban.properties 
default.timezone.id=Asia/Shanghai			# 改成Asia/Shanghai

database.type=mysql
mysql.port=3306
mysql.host=11.8.37.50						# IP改成mysql部署的ip
mysql.database=azkaban						# 刚才创建的azkaban库
mysql.user=root
mysql.password=wangting
mysql.numconnections=100

# Azkaban Jetty server properties.
jetty.maxThreads=25
jetty.ssl.port=8443
jetty.port=8081
jetty.keystore=keystore					   # keytool执行时对应的keystore
jetty.password=wangting					   # 密码都改成刚才设置的密码
jetty.keypassword=wangting
jetty.truststore=keystore
jetty.trustpassword=wangting

# 添加用户,相当于注册功能
wangting@ops01:/opt/module/azkaban/server/conf >vim azkaban-users.xml 

<azkaban-users>
        <user username="azkaban" password="azkaban" roles="admin" groups="azkaban" />
        <user username="metrics" password="metrics" roles="metrics"/>
        <user username="wangting" password="wangting" roles="admin, metrics"/>			# 可自定义用户名密码,用于界面登录使用

        <role name="admin" permissions="ADMIN" />
        <role name="metrics" permissions="METRICS"/>
</azkaban-users>

# 更改executor配置
wangting@ops01:/opt/module/azkaban/server/conf >cd /opt/module/azkaban/executor/conf/
wangting@ops01:/opt/module/azkaban/executor/conf >ls
azkaban.private.properties  azkaban.properties  global.properties
wangting@ops01:/opt/module/azkaban/executor/conf >vim azkaban.properties 

#Azkaban
default.timezone.id=Asia/Shanghai				# 改成Asia/Shanghai

# Azkaban JobTypes Plugins
azkaban.jobtype.plugin.dir=plugins/jobtypes

#Loader for projects
executor.global.properties=conf/global.properties
azkaban.project.dir=projects

database.type=mysql								# 数据库更改
mysql.port=3306
mysql.host=11.8.37.50
mysql.database=azkaban
mysql.user=root
mysql.password=wangting
mysql.numconnections=100

# Azkaban Executor settings
executor.maxThreads=50
executor.port=12321
executor.flow.threads=30

Démarrez le service :

wangting@ops01:/opt/module/azkaban/executor/conf >cd /opt/module/azkaban/server/
wangting@ops01:/opt/module/azkaban/server >bin/azkaban-web-start.sh 
Using Hadoop from /opt/module/hadoop-3.1.3
Using Hive from /opt/module/hive
bin/..
2021/05/16 11:26:42.425 +0800 INFO [log] [Azkaban] Started [email protected]:8443
2021/05/16 11:26:42.425 +0800 INFO [AzkabanWebServer] [Azkaban] Server running on ssl port 8443.

wangting@ops01:/opt/module/azkaban/server >cd /opt/module/azkaban/executor/
wangting@ops01:/opt/module/azkaban/executor >bin/azkaban-executor-start.sh 
wangting@ops01:/opt/module/azkaban/server >cd /opt/module/azkaban/executor/
wangting@ops01:/opt/module/azkaban/executor >bin/azkaban-executor-start.sh 
Using Hadoop from /opt/module/hadoop-3.1.3
Using Hive from /opt/module/hive
bin/..
Starting AzkabanExecutorServer on port 12321 ...
2021/05/16 11:29:20.076 +0800 INFO [log] [Azkaban] Started [email protected]:12321
2021/05/16 11:29:20.076 +0800 INFO [AzkabanExecutorServer] [Azkaban] Azkaban Executor Server started on port 12321

Visites de pages

Insérer la description de l'image ici

Insérer la description de l'image ici

Insérer la description de l'image ici

​ Une fois la connexion réussie, le processus de déploiement est terminé.

Introduction à l'utilisation d'Azkaban

​ projets : la partie la plus importante est de créer un projet et tous les flux s'exécuteront dans le projet.

​ planification : afficher les tâches planifiées

Exécution : affiche les tâches en cours d'exécution

historique : afficher l'historique des tâches en cours d'exécution

tâche indépendante unique

1. Créer un projet

​Créer un projet

projet_1

Informations descriptives
Insérer la description de l'image ici

2. Définir un travail

La manière dont la tâche est exécutée et ce qu'elle fait spécifiquement est définie dans le fichier de travail.

# 本地新建一个command.job文件,文件中的内容末尾不要有空格,内容如下:

# command.job
type=command
command=mkdir /opt/module/ztdata_0516


Insérer la description de l'image ici

3. Regroupez le fichier de définition de travail dans un package zip

Après avoir modifié le fichier command.job, utilisez un logiciel de compression pour le regrouper dans un fichier zip, tel que command.zip.

4. Téléchargez le package compressé de tâches dans le projet

Insérer la description de l'image ici

Après le téléchargement, si vous souhaitez voir le contenu de la tâche, vous pouvez afficher et analyser le contenu de la tâche dans la commande job.
Insérer la description de l'image ici

5. Afficher les tâches et exécuter des tâches

Cliquez sur la tâche de commande dans Flows pour accéder à l'interface spécifique de la tâche. Execute Flow peut exécuter la tâche.
Insérer la description de l'image ici

[Remarque :] Étant donné que l'opération d'interface est utilisée, les fichiers pertinents peuvent être modifiés, créés et compressés directement sur l'ordinateur Windows local.

6. Enregistrements de tâches historiques

Une fois la tâche exécutée, vous pouvez afficher l'historique de la tâche dans l'historique ;
Insérer la description de l'image ici

7. Vérifier les résultats de l'exécution

wangting@ops01:/opt/module >ll
total 52
drwxrwxr-x  5 wangting wangting 4096 May 16 10:51 azkaban
drwxrwxr-x  2 wangting wangting 4096 Apr  4 11:01 datas
drwxr-xr-x 12 wangting wangting 4096 Apr 24 16:37 flume
-rw-rw-r--  1 wangting wangting   30 Apr 25 11:33 group.log
drwxr-xr-x 12 wangting wangting 4096 Mar 12 11:38 hadoop-3.1.3
drwxrwxr-x  8 wangting wangting 4096 May 10 11:55 hbase
drwxrwxr-x 11 wangting wangting 4096 Apr  2 15:14 hive
drwxr-xr-x  7 wangting wangting 4096 Apr 29 11:07 kafka
drwxr-xr-x  5 wangting wangting 4096 Jun 27  2018 phoenix
drwxrwxr-x  3 wangting wangting 4096 Apr 10 16:25 tez
drwxrwxr-x  5 wangting wangting 4096 Apr  2 15:03 tez-0.9.2_bak0410
drwxr-xr-x  8 wangting wangting 4096 Mar 25 11:02 zookeeper-3.5.7
drwxrwxr-x  2 wangting wangting 4096 May 16 11:51 ztdata_0516
wangting@ops01:/opt/module >

Une fois la tâche terminée, vérifiez : Dans le répertoire /opt/module/, un nouveau répertoire ztdata_0516 a été créé avec succès, indiquant que la tâche a été suspendue et exécutée avec succès.

Flux de travail à tâches multiples

[Remarque :] Les expériences ultérieures ne prendront plus de captures d'écran une par une et le processus est le même que celui de l'exemple 1.

Créer un projet

Créer un projet

projet_2

Informations descriptives

Définir les tâches du poste

Créer 2 fichiers de tâches localement

un.emploi

# one.job
type=command
command=mkdir /opt/module/one

deux.emploi

# two.job
type=command
dependencies=one
command=touch /opt/module/one/two.txt

[Remarque :] dependencies=one signifie que la tâche de travail 2 dépend de la tâche 1. La définition de ce paramètre signifie qu'elles sont exécutées séquentiellement et que deux doivent être exécutées une fois la première terminée.

Regroupez le fichier de définition de travail dans un package zip

Le nom du fichier zip est arbitraire
Insérer la description de l'image ici

Télécharger le package compressé de tâches dans le projet

Sur la page d'accueil, cliquez sur la barre de pagination Projets ci-dessus, ouvrez le projet project_2, Télécharger dans le coin supérieur droit ; puis téléchargez le fichier zip.

effectuer des tâches

Cliquez sur Flux, cliquez sur deux tâches principales et exécutez après avoir entré

Résultats de validation

wangting@ops01:/opt/module >ll
total 56
drwxrwxr-x  5 wangting wangting 4096 May 16 10:51 azkaban
drwxrwxr-x  2 wangting wangting 4096 Apr  4 11:01 datas
drwxr-xr-x 12 wangting wangting 4096 Apr 24 16:37 flume
-rw-rw-r--  1 wangting wangting   30 Apr 25 11:33 group.log
drwxr-xr-x 12 wangting wangting 4096 Mar 12 11:38 hadoop-3.1.3
drwxrwxr-x  8 wangting wangting 4096 May 10 11:55 hbase
drwxrwxr-x 11 wangting wangting 4096 Apr  2 15:14 hive
drwxr-xr-x  7 wangting wangting 4096 Apr 29 11:07 kafka
drwxrwxr-x  2 wangting wangting 4096 May 16 12:34 one
drwxr-xr-x  5 wangting wangting 4096 Jun 27  2018 phoenix
drwxrwxr-x  3 wangting wangting 4096 Apr 10 16:25 tez
drwxrwxr-x  5 wangting wangting 4096 Apr  2 15:03 tez-0.9.2_bak0410
drwxr-xr-x  8 wangting wangting 4096 Mar 25 11:02 zookeeper-3.5.7
drwxrwxr-x  2 wangting wangting 4096 May 16 11:51 ztdata_0516
wangting@ops01:/opt/module >cd one/
wangting@ops01:/opt/module/one >ls
two.txt
wangting@ops01:/opt/module/one >

Une fois la tâche terminée, vérifiez : Dans le répertoire /opt/module/, un nouveau répertoire a été créé avec succès, indiquant que la tâche 1 a été suspendue et exécutée avec succès.

Entrez dans le répertoire One et affichez avec succès le fichier two.txt, indiquant que la tâche 2 a été suspendue et exécutée avec succès.

Appeler un script de tâche pour exécuter la tâche

L'écriture d'un processus de simulation sur le serveur est compliquée, comme appeler un script pour exécuter hive, hdfs, etc. Tâches de script métier :

/opt/module/test >vim test_azkaban.sh

wangting@ops01:/opt/module/test >vim test_azkaban.sh 

#!/bin/bash
echo "123"
echo "123123"
echo "123123123"
ls -l /opt/module/ >> /opt/module/test/shell_log_0516.log
hdfs dfs -ls / >> /opt/module/test/shell_log_0516.log
NOW=`date|awk -F" " '{print $4}'`
echo "当前时间: $NOW"

wangting@ops01:/opt/module/test >chmod +x test_azkaban.sh 

Créer un projet

Créer un projet

projet_3

Informations descriptives

Définir les tâches du poste

# run_bash.job
type=command
command=bash /opt/module/test/test_azkaban.sh

Regroupez le fichier de définition de travail dans un package zip

Idem que le cas ci-dessus

Télécharger le package compressé de tâches dans le projet

Sur la page d'accueil, cliquez sur la barre de pagination Projets ci-dessus, ouvrez le projet project_3, Télécharger dans le coin supérieur droit ; puis téléchargez le fichier zip.

effectuer des tâches

Cliquez sur Flux, cliquez sur run_bash de la tâche principale et exécutez après avoir entré

Résultats de validation

wangting@ops01:/opt/module/test >ll
total 8
-rw-rw-r-- 1 wangting wangting 1801 May 16 12:49 shell_log_0516.log
-rwxrwxr-x 1 wangting wangting  226 May 16 12:44 test_azkaban.sh
wangting@ops01:/opt/module/test >
# 查看输出内容是否有遍历目录和查看hdfs根目录的内容
wangting@ops01:/opt/module/test >cat shell_log_0516.log 
total 60
drwxrwxr-x  5 wangting wangting 4096 May 16 10:51 azkaban
drwxrwxr-x  2 wangting wangting 4096 Apr  4 11:01 datas
drwxr-xr-x 12 wangting wangting 4096 Apr 24 16:37 flume
-rw-rw-r--  1 wangting wangting   30 Apr 25 11:33 group.log
drwxr-xr-x 12 wangting wangting 4096 Mar 12 11:38 hadoop-3.1.3
drwxrwxr-x  8 wangting wangting 4096 May 10 11:55 hbase
drwxrwxr-x 11 wangting wangting 4096 Apr  2 15:14 hive
drwxr-xr-x  7 wangting wangting 4096 Apr 29 11:07 kafka
drwxrwxr-x  2 wangting wangting 4096 May 16 12:34 one
drwxr-xr-x  5 wangting wangting 4096 Jun 27  2018 phoenix
drwxrwxr-x  2 wangting wangting 4096 May 16 12:49 test
drwxrwxr-x  3 wangting wangting 4096 Apr 10 16:25 tez
drwxrwxr-x  5 wangting wangting 4096 Apr  2 15:03 tez-0.9.2_bak0410
drwxr-xr-x  8 wangting wangting 4096 Mar 25 11:02 zookeeper-3.5.7
drwxrwxr-x  2 wangting wangting 4096 May 16 11:51 ztdata_0516
2021-05-16 12:49:16,801 INFO  [main] Configuration.deprecation (Configuration.java:logDeprecation(1395)) - No unit for dfs.client.datanode-restart.timeout(30) assuming SECONDS
Found 10 items
drwxr-xr-x   - wangting supergroup          0 2021-03-17 11:44 /20210317
drwxr-xr-x   - wangting supergroup          0 2021-03-19 10:51 /20210319
drwxr-xr-x   - wangting supergroup          0 2021-04-24 17:05 /flume
-rw-r--r--   3 wangting supergroup  338075860 2021-03-12 11:50 /hadoop-3.1.3.tar.gz
drwxr-xr-x   - wangting supergroup          0 2021-05-13 15:31 /hbase
drwxr-xr-x   - wangting supergroup          0 2021-04-04 11:07 /test.db
drwxr-xr-x   - wangting supergroup          0 2021-03-19 11:14 /testgetmerge
drwxr-xr-x   - wangting supergroup          0 2021-04-10 16:23 /tez
drwx------   - wangting supergroup          0 2021-04-02 15:14 /tmp
drwxr-xr-x   - wangting supergroup          0 2021-04-02 15:25 /user
wangting@ops01:/opt/module/test >

Une fois la tâche terminée, vérifiez : Dans le répertoire /opt/module/test, le fichier shell_log_0516.log a été créé avec succès, indiquant que la tâche run_bash a été suspendue et exécutée avec succès.

Je suppose que tu aimes

Origine blog.csdn.net/wt334502157/article/details/116891032
conseillé
Classement