1. 程式人生 > >azkabin的安裝與除錯

azkabin的安裝與除錯

Git上下載原始碼:

地址:https://github.com/azkaban/azkaban

 

解壓原始碼到/home:

unzip /home/azkaban-master.zip -d /home/

 

編譯原始碼:

 

 

安裝:

在安裝咯hadoop、hive、sqoop等的機子上安裝,好測試是否okay。先安裝azkban web server:

解壓azkaban-web-server-2.5.0.tar.gz 到azkaban目錄中,並重新命名為webserver:

 

[[email protected]

home]# mkdir /usr/local/azkaban

[[email protected] home]# tar -zxvf ./azkaban-web-server-2.5.0.tar.gz /usr/local/azkaban/

[[email protected] home]# mv /usr/local/azkaban/azkaban-web-2.5.0 /usr/local/azkaban/webserver

 

Azkaban執行伺服器的安裝:

解壓azkaban-executor-server-2.5.0.tar.gz到azkaban目錄中並改名為executor

[[email protected] home]# tar -zxvf /home/azkaban-executor-server-2.5.0.tar.gz -C /usr/local/azkaban/

[[email protected] home]# mv /usr/local/azkaban/azkaban-executor-2.5.0/ /usr/local/azkaban/executor

 

 

Azkaban資料庫指令碼執行:

解壓azkaban-sql-script-2.5.0.tar.gz並將解壓目錄下的create-all-sql-2.5.0.sql指令碼匯入到mysql中:

[[email protected] home]# tar -zxvf /home/azkaban-sql-script-2.5.0.tar.gz

[[email protected] home]# mysql -uroot -proot

mysql> create database azkaban;

Query OK, 1 row affected (0.01 sec)

mysql> use azkaban;

Database changed

mysql> source /home/azkaban-2.5.0/create-all-sql-2.5.0.sql;

 

建立ssl並配置:在webserver目錄下

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

命令如下:密碼為azkaban

[[email protected] azkaban]# 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]:  cz

Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=cz correct?

  [no]:  y

 

Enter key password for <jetty>

(RETURN if same as keystore password):  

Re-enter new password:

 

完成上述工作後,將在當前目錄生成 keystore 證書檔案,將keystore 考貝到 azkaban web伺服器根目錄中的bin目錄下.如:cp keystore azkaban/webserver。

[[email protected] azkaban]# cp ./keystore /user/local/azkaban/webserver  原則上只要安裝根目錄有即可,可以不cp

 

 

配置檔案

注:先配置好伺服器節點上的時區

1、先生成時區配置檔案Asia/Shanghai,用互動式命令 tzselect 即可

2、拷貝該時區檔案,覆蓋系統本地時區配置

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

3.配置檔案的修改

azkaban web伺服器配置

進入azkaban web伺服器安裝目錄 conf目錄

 

修改azkaban.properties檔案

命令vi azkaban.properties

內容說明如下:

 

azkaban 執行器配置

進入執行器安裝目錄conf,修改azkaban.properties

vi azkaban.properties

內容說明如下:

#Azkaban Personalization Settings

azkaban.name=Test

azkaban.label=My Local Azkaban

azkaban.color=#FF3601

azkaban.default.servlet.path=/index

web.resource.dir=/opt/app/azkaban/webserver/web/

default.timezone.id=Asia/Shanghai

 

#Azkaban UserManager class

user.manager.class=azkaban.user.XmlUserManager

user.manager.xml.file=/opt/app/azkaban/webserver/conf/azkaban-users.xml

 

#Loader for projects

executor.global.properties=/opt/app/azkaban/executor/conf/global.properties

azkaban.project.dir=projects

 

database.type=mysql

mysql.port=3306

mysql.host=had01

mysql.database=azkaban

mysql.user=root

mysql.password=root

mysql.numconnections=100

 

# Velocity dev mode

velocity.dev.mode=false

 

# Azkaban Jetty server properties.

jetty.maxThreads=25

jetty.ssl.port=8443

jetty.port=8081

jetty.keystore=keystore

jetty.password=000000

jetty.keypassword=000000

jetty.truststore=keystore

jetty.trustpassword=000000

 

# Azkaban Executor settings

executor.port=12321

 

# mail settings

mail.sender=

mail.host=

job.failure.email=

job.success.email=

 

lockdown.create.projects=false

 

cache.directory=cache

 

使用者配置:

進入azkaban web伺服器conf目錄,修改azkaban-users.xml

vi azkaban-users.xml 增加 管理員使用者

<azkaban-users>

<user username="azkaban" password="azkaban" roles="admin" groups="azkaban" />

<user username="metrics" password="metrics" roles="metrics"/>

<user username="admin" password="admin" roles="metrics,admin"/>

<role name="admin" permissions="ADMIN" />

<role name="metrics" permissions="METRICS"/>

</azkaban-users>

 

修改executor下的azkaban.properties

#Azkaban

default.timezone.id=Asia/Shanghai

 

# Azkaban JobTypes Plugins

azkaban.jobtype.plugin.dir=plugins/jobtypes

 

#Loader for projects

executor.global.properties=/opt/app/azkaban/executor/conf/global.properties

azkaban.project.dir=projects

 

database.type=mysql

mysql.port=3306

mysql.host=had01

mysql.database=azkaban

mysql.user=root

mysql.password=root

mysql.numconnections=100

 

# Azkaban Executor settings

executor.maxThreads=50

executor.port=12321

executor.flow.threads=30

 

啟動webserver:

[[email protected] azkaban]# ./webserver/bin/azkaban-web-start.sh

1、啟動報錯:

Caused by: java.lang.IllegalArgumentException: User xml file conf/azkaban-users.xml doesn't exist.

將配置檔案中的路徑寫成絕對路徑。user.manager.xml.file=/usr/local/azkaban/webserver/conf/azkaban-users.xml

2、啟動警告:

2018/12/13 17:37:50.320 +0800 WARN [log] [Azkaban] failed [email protected]:8443: java.io.FileNotFoundException: /usr/local/azkaban/keystore (No such file or directory)

重新copy keystore:cp /home/keystore /user/local/azkaban/  (原則是隻需要放到azkaban的安裝目錄,不放啟動會報錯:/usr/local/azkaban/keystore (No such file or directory))

3、啟動執行器報錯:

Exception in thread "main" java.io.FileNotFoundException: conf/global.properties (No such file or directory)

4、將配置檔案中寫成絕對路徑:

executor.global.properties=/usr/local/azkaban/executor/conf/global.properties

5、訪問報錯:

javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?

檢查將azkaban.properties的web配置成絕對目錄:web.resource.dir=/usr/local/azkaban/webserver/web/

 

啟動成功後登陸介面如下:

輸入配置的使用者名稱和密碼登入即可。

 

啟動時可能web頁面不能載入,點選頁面的高階------繼續載入即可

 

 

azkabin執行案例

1.一個job依賴於另一個job的執行

建立first.job檔案

新增內容

type=command

command=echo "hello"

 

建立second.sh檔案

新增如下內容

#!/bin/bash

echo "hello azkaban" >> /datas/data2.log

 

建立depends.job檔案

新增如下的內容

type=command

dependencies=first

command=bash second.sh

打包zip

上傳到azkabin執行

 

定時任務的執行

按execute按鈕之後,點選下面的scheduce進行時間的設定即可

 

  1. AZKABIN執行sql語句

資料

student.uid     student.xi      student.fuid

1       1       1

1       1       3

2       1       10

2       2       11

1       1       4

1       2       5

1       2       6

2       1       7

2       1       8

2       1       9

1       1       2

2       2       12

2       2       13

 

 

書寫sql檔案

test.sql

use default;

select

*

from

(

select

uid,

xi,

mycon,

row_number() over(partition by uid,xi order by mycon desc) as myrow

from

(

select

uid,

xi,

count(fuid) over(partition by uid,xi) as mycon

from

student

) t1

) t2 where myrow<=1;

 

書寫job檔案

# hivef.job

type=command

command=/opt/app/hive-1.2.2/bin/hive -S -f 'test.sql'