Azkaban集群部署

时间:2022-11-20 16:52:48

一、部署模式

  • solo-server模式  (使用内置h2存储元数据);
  • two-server模式 (1个webServer,1个execServer在同一服务器上,使用mysql存储元数据);

  • multiple-executor模式   (1个webServer,多个execServer分布在不同服务上,使用mysql存储元数据);

本文选择第三种模式,即一台机器安装webServer服务,多台机器安装execServer.这种模式是使用最广泛的。

二、部署准备

(1)服务器三台

192.168.0.10 --azkaban-web-server
192.168.0.11 --azkaban-exec-server

配置ip对应关系:

znzd001: 192.168.0.10

znzd002: 192.168.0.11

(2)搭建MySQL

默认有一个mysql服务器,首先创建azkaban库,azkaban用户密码,并赋予远程连接。

 mysql> CREATE DATABASE azkaban;
mysql> CREATE USER 'azkaban'@'%' IDENTIFIED BY 'azkaban';
mysql> CREATE USER 'azkaban'@'localhost' IDENTIFIED BY 'azkaban';
mysql> grant all privileges on azkaban.* to 'azkaban'@'%' identified by 'azkaban';
mysql> grant all privileges on azkaban.* to 'azkaban'@'localhost' identified by 'azkaban';
mysql> flush privileges;

(3)下载最新azkaban源文件(azkaban-3.47.0.tar.gz),上传到192.168.0.10:/opt/下

三、开始部署

(1)解压缩文件azkaban-3.47.0.tar.gz

Azkaban集群部署

(2)进入目录执行下面代码编译源文件

./gradlew distTar

(3)将下面4个文件解压缩,文件如下:

/opt/azkaban-3.47.0/azkaban-web-server/build/distributions/azkaban-web-server-3.47.0-SNAPSHOT.tar.gz
/opt/azkaban-3.47.0/azkaban-web-server/build/distributions/azkaban-exec-server-3.47.0-SNAPSHOT.tar.gz
/opt/azkaban-3.47.0/azkaban-solo-server/build/distributions/azkaban-solo-server-0.1.0-SNAPSHOT.tar.gz
/opt/azkaban-3.47.0/azkaban-db/build/distributions/azkaban-db-0.1.0-SNAPSHOT.tar.gz

(4)导入建表语句

mysql -uroot -proot123
> SOURCE /opt/azkaban-3.47./azkaban-db/build/distributions/azkaban-db-0.1.-SNAPSHOT/create-all-sql-0.1.-SNAPSHOT.sql;

(5)构建Azkaban-web-server

Azkaban-web-server目录下分别新建目录:conf、plugins、extlib。

将azkaban-solo-server-0.1.0-SNAPSHOT的conf、plugins两个目录下的文件拷贝到Azkaban-web-server目录下。

mv /opt/azkaban-3.47./azkaban-web-server/build/distributions/azkaban-web-server-0.1.-SNAPSHOT /opt/Azkaban-web-server
cp -r /opt/azkaban-3.47./azkaban-solo-server/build/distributions/azkaban-solo-server-0.1.-SNAPSHOT/conf /opt/Azkaban-web-server/conf
cp -r /opt/azkaban-3.47./azkaban-solo-server/build/distributions/azkaban-solo-server-0.1.-SNAPSHOT/plugins /opt/Azkaban-web-server/plugins

(6)修改 /opt/Azkaban-web-server/conf/azkaban.properties 文件

# Azkaban Personalization Settings
azkaban.name=nyhadoop
azkaban.label=My Local Azkaban
azkaban.color=#FF3601
azkaban.default.servlet.path=/index
web.resource.dir=web/
default.timezone.id=Asia/Shanghai
# Azkaban UserManager class
user.manager.class=azkaban.user.XmlUserManager
user.manager.xml.file=conf/azkaban-users.xml
# Loader for projects
executor.global.properties=conf/global.properties
azkaban.project.dir=projects database.type=mysql
mysql.port=3306
mysql.host=10.46.67.33
mysql.database=azkaban
mysql.user=azkaban
mysql.password=azkaban
mysql.numconnections=100 # Velocity dev mode
velocity.dev.mode=false
# Azkaban Jetty server properties.
jetty.ssl.port=8443
jetty.use.ssl=true
jetty.port=8081
jetty.keystore=keystore
jetty.password=123456
jetty.keypassword=123456
jetty.truststore=keystore
jetty.trustpassword=123456
jetty.maxThreads=25
# Azkaban Executor settings
executor.port=12321
# mail settings
mail.sender=
mail.host=
# User facing web server configurations used to construct the user facing server URLs. They are useful when there is a reverse proxy between Azkaban web servers and users.
# enduser -> myazkabanhost:443 -> proxy -> localhost:8081
# when this parameters set then these parameters are used to generate email links.
# if these parameters are not set then jetty.hostname, and jetty.port(if ssl configured jetty.ssl.port) are used.
# azkaban.webserver.external_hostname=myazkabanhost.com
# azkaban.webserver.external_ssl_port=443
# azkaban.webserver.external_port=8081
job.failure.email=
job.success.email=
lockdown.create.projects=false
cache.directory=cache
# JMX stats
jetty.connector.stats=true
executor.connector.stats=true
# Azkaban plugin settings
azkaban.jobtype.plugin.dir=plugins/jobtypes
azkaban.use.multiple.executors=true
azkaban.executorselector.filters=StaticRemainingFlowSize,MinimumFreeMemory,CpuStatus
azkaban.executorselector.comparator.NumberOfAssignedFlowComparator=1
azkaban.executorselector.comparator.Memory=1
azkaban.executorselector.comparator.LastDispatched=1
azkaban.executorselector.comparator.CpuUsage=1

(7)配置jetty ssl

要记住设置的密码,这里密码统一设置为123456

keytool -keystore keystore -alias jetty -genkey -keyalg RSA

Enter keystore password: 输入密码
Re-enter new password: 再次输入密码
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=YY, OU=YY, O=YY, L=shanghai, ST=shanghai, C=CN correct?
[no]: y

(8)将生成的keystore文件 移动到/opt/Azkaban-web-server/目录下

(9)构建Azkaban-exec-server(192.168.0.11和192.168.0.12都有)

scp /opt/azkaban-3.47./azkaban-exec-server/build/distributions/azkaban-exec-server-0.1.-SNAPSHOT.tar.gz 192.168.0.11:/opt/
tar -zxvf azkaban-exec-server-0.1.-SNAPSHOT.tar.gz
mv azkaban-exec-server-0.1.-SNAPSHOT Azkaban-exec-server

192.168.0.11和192.168.0.12的opt目录下各上传一份azkaban-exec-server-0.1.0-SNAPSHOT.tar.gz。

(10)Azkaban-exec-server

Azkaban-exec-server目录下分别新建目录:conf、plugins、extlib。

将azkaban-solo-server-0.1.0-SNAPSHOT的conf、plugins两个目录下的文件拷贝到Azkaban-exec-server目录下,参考(5)。

编译conf/azkaban.properties文件

# Azkaban Personalization Settings
default.timezone.id=Asia/Shanghai
# Loader for projects
executor.global.properties=conf/global.properties
azkaban.project.dir=projects database.type=mysql
mysql.port=
mysql.host=10.46.67.33
mysql.database=azkaban
mysql.user=azkaban
mysql.password=azkaban
mysql.numconnections= # Azkaban Executor settings
executor.maxThreads=
executor.port=
executor.flow.threads=
# JMX stats
jetty.connector.stats=true
executor.connector.stats=true
# Azkaban plugin settings
azkaban.jobtype.plugin.dir=plugins/jobtypes

(11)分别在/opt/Azkaban-web-server/conf和/opt/Azkaban-exec-server/conf目录下创建log4j.properties文件

log4j.rootLogger=DEBUG,C
log4j.appender.C=org.apache.log4j.ConsoleAppender
log4j.appender.C.Target=System.err
log4j.appender.C.layout=org.apache.log4j.PatternLayout
log4j.appender.C.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{}:%L - %m%n

(12)分别修改在/opt/Azkaban-web-server/和/opt/Azkaban-exec-server/目录下plugins/jobtypes/commonprivate.properties文件

azkaban.native.lib=false
execute.as.user=false

四、Azkaban运行

(1)先启动执行器:分别在192.168.0.11和192.168.0.12的 /opt/Azkaban-exec-server目录下执行,启动日志写到了logs目录。

 ./bin/start-exec.sh

(2)再启动azkaban服务器

192.168.1.10下 /opt/Azkaban-web-server目录下执行

./bin/start-web.sh

(3)浏览器地址 https://192.168.1.10:8443查看服务界面,访问密码在azkaban-users.xml 里,可自行配置。

五、激活执行器

将MySQL中azkaban数据库中的executors激活,active若为0,要更新为1,表示激活执行器。

Azkaban集群部署

补充:

jetty.use.ssl=true,设置为true,访问链接要加https。

六、执行任务

(1)创建任务脚本

在192.168.1.11(znzd002)的home/mntc目录下创建脚本文件test.sh,内容如下:

#!/bin/bash
echo 'Hello World'

(2)创建azkaban的任务文件test.job,并打包为test.zip。

azkaban集群模式下要指定任务执行器,脚本在那个机器上就配置该机器的azkaban执行器ID, 查表executors,这里znzd002对应的执行器ID是10。

type=command
command=sh /home/dmbigdata/mntc/test.sh
#配置执行器id
useExecutor=10
retries=3
retry.backoff=30000

(3)上传test.zip后,Job内容明细如下:

Azkaban集群部署

(4)执行test.job,Run Job

Azkaban集群部署

(5)指定用哪个azkaban执行器,要在Flow中设置userExecutor参数,参数值指表executors中的执行器的ID。

Azkaban集群部署

(6)Schedule设置任务执行时间,比如每天2点执行一次

Azkaban集群部署

(7)查看认为日志

Azkaban集群部署

(8)日志明细

Azkaban集群部署

日志中打印了内容,任务执行成功!

原文链接:https://www.cnblogs.com/bujunpeng/p/9093124.html