Azkaban 4.0.0 系列(一)-- Solo-Server

下载

链接

https://github.com/azkaban/azkaban/releases/4.0.0.tar.gz

解压

tar -xzvf 4.0.0.tar.gz -C 自定义目标目录

修改azkaban-4.0.0目录下的build.gradle文件

找到初始配置信息
maven{
    url 'https://linkedin.bintray.com/maven'
}

进行修改
maven {
    url 'https://linkedin.jfrog.io/artifactory/open-source/'
}

原有的仓库地址在国内访问会非常缓慢,甚至不能访问,造成编译过程报错。

修改 nodejs 相关配置

进入到/..../azkaban-4.0.0/azkaban-web-server目录中,打开build.gradle文件,将node选项中的download配置值设为false
node {
    // Version of node to use.
    version = '8.10.0'

    // Version of npm to use.
    npmVersion = '5.6.0'

    // Base URL for fetching node distributions (change if you have a mirror).
    distBaseUrl = 'https://nodejs.org/dist'

    // If true, it will download node using above parameters.
    // If false, it will try to use globally installed node.
    download = false

    // Set the work directory for unpacking node
    workDir = file("${project.buildDir}/nodejs")

    // Set the work directory where node_modules should be located
    nodeModulesDir = file("${project.projectDir}")
}

如果不修改的话,azkaban在编译的过程中就会去下载 node-8.10.0,大概率会因为网络问题使下载失败,从而导致编译失败。
我们本机需要准备好node环境(笔者在编译的时候遇到过,node环境已经存在,但是提示 npm not found 的报错信息,尝试多次后无果,最后将虚拟机重启解决。)

修改azkaban-db代码,以支持Mysql8.X系列数据库

进入/..../azkaban-4.0.0/azkaban-db/src/main/java/azkaban/db目录,修改MySQLDataSource.java
  @Inject
  public MySQLDataSource(final Props props, final DBMetrics dbMetrics) {
    super();
    this.dbMetrics = dbMetrics;

    final int port = props.getInt("mysql.port");
    final String host = props.getString("mysql.host");
    final String dbName = props.getString("mysql.database");
    final String user = props.getString("mysql.user");
    final String password = props.getString("mysql.password");
    final int numConnections = props.getInt("mysql.numconnections");
    
    //加上mysql的驱动类配置项,如果没有配置则默认是mysql5.x
    //-----------------begin-----------------------
    String driverName = props.getString("mysql.driverName");
    if(driverName == null){
        driverName = "com.mysql.jdbc.Driver";
    }
    //-----------------end-----------------------
    
    final String url = "jdbc:mysql://" + (host + ":" + port + "/" + dbName);
    addConnectionProperty("useUnicode", "yes");
    addConnectionProperty("characterEncoding", "UTF-8");
    
    //setDriverClassName(com.mysql.jdbc.Driver);
    
    //修改成从配置中读取驱动类名
    addConnectionProperty("useSSL", "false");
    setDriverClassName(driverName);
    
    setUsername(user);
    setPassword(password);
    setUrl(url);
    setMaxTotal(numConnections);
    setValidationQuery("/* ping */ select 1");
    setTestOnBorrow(true);
  }

azkaban 默认支持MySQL5.x版本,可以根据需要,决定是否让其适配5.x及8.x

编译

提前准备好 gradle-4.6-all.zip

下载链接:https://services.gradle.org/distributions/gradle-4.6-all.zip

整合到Azkaban中,目标目录如下: 
    /..../azkaban-4.0.0/gradle/wrapper/

修改配置文件 gradle-wrapper.properties :

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
# distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip   #(注释掉这一行)
distributionUrl=gradle-4.6-all.zip   # (添加该行内容)

指令

cd /..../azkaban-4.0.0/

./gradlew build installDist

可能会出现 test failed 的提示,使用如下参数跳过测试。

./gradlew build installDist -x test

不出意外,编译会顺利进行。

启动 Solo-Server

指令

cd /..../azkaban-4.0.0/azkaban-solo-server/build/install/azkaban-solo-server

sh ./bin/start-solo.sh

服务检查指令:jps
返回:AzkabanSingleServer

浏览器访问:
http://本机ip:8081/

用户名/密码:azkaban/azkaban

案例

文件准备

mkdir first_azkaban_project && cd first_azkaban_project

vi basic.flow    (添加文件内容)

nodes:
  - name: jobA
    type: command
    config:
      command: echo "This is an echoed text."

vi flow20.project   (添加文件内容)

azkaban-flow-version: 2.0

打包:

zip -r Archive.zip .     (在 first_azkaban_project 下)

如果没有 zip 指令,使用 yum install zip -y 进行安装

将生成的zip包拉取到本地,上传到提前创建好的项目中,运行即可。

posted on 2023-01-07 14:42  地球上的小东西  阅读(294)  评论(0编辑  收藏  举报