了解和学习DS并行和在DS JOB中应用配置文件优化并行

body { margin: 0 auto; font: 13px / 1 Helvetica, Arial, sans-serif; color: rgba(68, 68, 68, 1); padding: 5px }
h1, h2, h3, h4 { color: rgba(17, 17, 17, 1); font-weight: 400 }
h1, h2, h3, h4, h5, p { margin-bottom: 16px; padding: 0 }
h1 { font-size: 28px }
h2 { font-size: 22px; margin: 20px 0 6px }
h3 { font-size: 21px }
h4 { font-size: 18px }
h5 { font-size: 16px }
a { color: rgba(0, 153, 255, 1); margin: 0; padding: 0; vertical-align: baseline }
a:link, a:visited { text-decoration: none }
a:hover { text-decoration: underline }
ul, ol { padding: 0; margin: 0 }
li { line-height: 24px; margin-left: 30px }
li ul, li ul { margin-left: 24px }
ul, ol { font-size: 14px; line-height: 20px; max-width: 98% }
p { font-size: 14px; line-height: 20px; max-width: 98%; margin-top: 3px }
pre { padding: 0 4px; max-width: 98%; white-space: pre-wrap; font-family: Consolas, Monaco, Andale Mono, monospace; line-height: 1.5; font-size: 13px; border: 1px solid rgba(221, 221, 221, 1); background-color: rgba(247, 247, 247, 1); border-radius: 3px }
code { font-family: Consolas, Monaco, Andale Mono, monospace; line-height: 1.5; font-size: 13px; border: 1px solid rgba(221, 221, 221, 1); background-color: rgba(247, 247, 247, 1); border-radius: 3px }
pre code { border: 0 }
aside { display: block; float: right; width: 390px }
blockquote { border-left: 0.5em solid rgba(64, 170, 83, 1); padding: 0 2em; margin-left: 0; max-width: 98% }
blockquote cite { font-size: 14px; line-height: 20px; color: rgba(191, 191, 191, 1) }
blockquote cite:before { content: “— ” }
blockquote p { color: rgba(102, 102, 102, 1); max-width: 98% }
hr { height: 1px; border-top: 1px dashed rgba(0, 102, 204, 1); border-right: none; border-bottom: none; border-left: none }
button, input, select, textarea { font-size: 100%; margin: 0; vertical-align: baseline; *vertical-align: middle }
button, input { line-height: normal; *overflow: visible }
{ border: 0; padding: 0 }
button, input[type=”button”], input[type=”reset”], input[type=”submit”] { cursor: pointer; -webkit-appearance: button }
input[type=”checkbox”], input[type=”radio”] { cursor: pointer }
input:not([type=”image”]), textarea { -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box }
input[type=”search”] { -webkit-appearance: textfield; -webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box }
{ -webkit-appearance: none }
label, input, select, textarea { font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif; font-size: 13px; font-weight: normal; line-height: normal; margin-bottom: 18px }
input[type=”checkbox”], input[type=”radio”] { cursor: pointer; margin-bottom: 0 }
input[type=”text”], input[type=”password”], textarea, select { display: inline-block; width: 210px; padding: 4px; font-size: 13px; font-weight: normal; line-height: 18px; height: 18px; color: rgba(128, 128, 128, 1); border: 1px solid rgba(204, 204, 204, 1); -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px }
select, input[type=”file”] { height: 27px; line-height: 27px }
textarea { height: auto }
{ color: rgba(191, 191, 191, 1) }
{ color: rgba(191, 191, 191, 1) }
input[type=”text”], input[type=”password”], select, textarea { -webkit-transition: border linear 0.2s, box-shadow linear 0.2s; -moz-transition: border linear 0.2s, box-shadow linear 0.2s; transition: border 0.2s linear, box-shadow 0.2s linear; -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1) }
input[type=”text”]:focus, input[type=”password”]:focus, textarea:focus { outline: none; border-color: rgba(82, 168, 236, 0.8); -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6); -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6) }
button { display: inline-block; padding: 4px 14px; font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); box-shadow: inset 0 1px rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); background-color: rgba(0, 100, 205, 1); background-repeat: repeat-x; background-image: linear-gradient(0deg, rgba(4, 156, 219, 1), rgba(0, 100, 205, 1)); color: rgba(255, 255, 255, 1); text-shadow: 0 -1px rgba(0, 0, 0, 0.25); border-top: 1px solid rgba(0, 0, 0, 0.1); border-right: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(0, 0, 0, 0.25); border-left: 1px solid rgba(0, 0, 0, 0.1); -webkit-transition: 0.1s linear all; -moz-transition: 0.1s linear all; transition: all 0.1s linear }
button:hover { color: rgba(255, 255, 255, 1); background-position: 0 -15px; text-decoration: none }
button:active { -webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); -moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05); box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05) }
{ padding: 0; border: 0 }
table { border-spacing: 0; border: 1px solid rgba(204, 204, 204, 1) }
td, th { border: 1px solid rgba(204, 204, 204, 1); padding: 5px }
pre .literal, pre .comment, pre .template_comment, pre .diff .header, pre .javadoc { color: rgba(0, 128, 0, 1) }
pre .keyword, pre .css .rule .keyword, pre .winutils, pre .javascript .title, pre .nginx .title, pre .subst, pre .request, pre .status { color: rgba(0, 0, 255, 1); font-weight: bold }
pre .number, pre .hexcolor, pre .python .decorator, pre .ruby .constant { color: rgba(0, 0, 255, 1) }
pre .string, pre .tag .value, pre .phpdoc, pre .tex .formula { color: rgba(221, 17, 68, 1) }
pre .title, pre .id { color: rgba(153, 0, 0, 1); font-weight: bold }
pre .javascript .title, pre .lisp .title, pre .clojure .title, pre .subst { font-weight: normal }
pre .class .title, pre .haskell .type, pre .vhdl .literal, pre .tex .command { color: rgba(68, 85, 136, 1); font-weight: bold }
pre .tag, pre .tag .title, pre .rules .property, pre .django .tag .keyword { color: rgba(0, 0, 128, 1); font-weight: normal }
pre .attribute, pre .variable, pre .lisp .body { color: rgba(0, 128, 128, 1) }
pre .regexp { color: rgba(0, 153, 38, 1) }
pre .class { color: rgba(68, 85, 136, 1); font-weight: bold }
pre .symbol, pre .ruby .symbol .string, pre .lisp .keyword, pre .tex .special, pre .prompt { color: rgba(153, 0, 115, 1) }
pre .built_in, pre .lisp .title, pre .clojure .built_in { color: rgba(0, 134, 179, 1) }
pre .preprocessor, pre .pi, pre .doctype, pre .shebang, pre .cdata { color: rgba(153, 153, 153, 1); font-weight: bold }
pre .deletion { background: rgba(255, 221, 221, 1) }
pre .addition { background: rgba(221, 255, 221, 1) }
pre .diff .change { background: rgba(0, 134, 179, 1) }
pre .chunk { color: rgba(170, 170, 170, 1) }
pre .markdown .header { color: rgba(136, 0, 0, 1); font-weight: bold }
pre .markdown .blockquote { color: rgba(136, 136, 136, 1) }
pre .markdown .link_label { color: rgba(136, 136, 255, 1) }
pre .markdown .strong { font-weight: bold }
pre .markdown .emphasis { font-style: italic }

DataStage序列文章

DataStage 一、安装
DataStage 二、InfoSphere Information Server进程的启动和停止
DataStage 三、配置ODBC
DataStage 错误集(持续更新)
DataStage 四和五因为包含大量图片发布不便,有兴趣学习和研究者请联系索要!!!
DataStage 六、安装和部署集群环境

1 配置文件的用途

配置文件在DS运行时第一时间被读取,如果JOB属性中设置了$APT_CONFIG_FILE参数,则DS读取该参数中配置的配置文件信息;如果没有配置则读取项目属性$APT_CONFIG_FILE参数中配置的配置文件信息;如果没有则读取默认的配置文件default.apt;配置文件告诉了DS怎么分配所需要的系统资源,如逻辑处理节点信息、temporary store、dataset storage,在某些情况同样可以在配置文件中配置更高级的资源信息,如buffer storage;使用配置文件的好处在于可以在修改了配置文件(比如增加节点或增加其它资源)的情况不修改或重新设计JOB,使其保持可用状态,而处理这些你仅仅需要在job属性或项目属性中设置$APT_CONFIG_FILE参数。在创建配置文件时我们主要要考虑的两个重要因素有:逻辑处理节点和优化并行。

2 逻辑处理节点(Logical Processing Node)

在并行作业中配置文件可以定义一个或多个逻辑处理节点,这些定义的逻辑节点信息会在并行作业运行时由Engine分配使用,如下面的逻辑节点定义:

{
    node "node1"
    {
        fastname "dsconductor01"
        pools ""
        resource disk "/disk2/IBM/EngineTier/Server/Datasets" {pools ""}
        resource scratchdisk "/disk2/IBM/EngineTier/Server/Scratch" {pools ""}
    }
    node "node2"
    {
        fastname "dsconductor01"
        pools ""
        resource disk "/disk2/IBM/EngineTier/Server/Datasets" {pools ""}
        resource scratchdisk "/disk2/IBM/EngineTier/Server/Scratch" {pools ""}
    }
}

注意:处理节点node1和node2是逻辑节点不是物理节点,它不代表物理CPU的个数,可以在一个物理机器中定义一个或多个逻辑节点。逻辑节点的定义决定了在并行作用运行时可以产生多少个并行进程和有多少的资源可用,等同于Unix上的物理进程数,逻辑节点越多产生的进程和使用的内存或磁盘空间(如排序操作)就越多。在IBM的官方文档中建议创建逻辑节点的个数为物理CUP数的一半,当然这还要取决于系统配置、资源可用性、资源共享、硬件和JOB设计,比如如果JOB需要高的IO操作或者要从数据库中获取大量的数据,这时可能要考虑定义多个逻辑节点来完成操作。

3 优化并行(Optimizing parallelism)

并行的个数取决于在配置文件中配置的逻辑处理节点个数,并行应该在考虑系统和JOB设计的情况下进行优化而不是最大化,并行数越多可能会很好的分布负载,但同时也增加了系统的进程数和资源的消耗,背后也隐示的增加了系统整体负载;所以并非并行越多越好,所以一定要综合考虑CPU、内存、磁盘、JOB方面因素,使并行对系统的影响和效率可维护。
**注意:如果stage中包含联结或者sort,你可能会使用Partition,比如Hash分区,如果数据的量接近等于分区数,比如下面的数据:

在这样的情况下等量的并行数会显著提高整体的性能。

3 创建配置文件示例

当安装DS时系统默认创建default.apt文件,并且该配置文件默认应用于创建的DS项目,该文件创建的规则:

  • 逻辑节点数=1/2的物理CUP个数
  • disk和scratchdisk 使用DS安装目录下的子目录

你要创建新的配置文件去优化并行作业,使其能够充分的使用硬件资源和系统资源,因为不同的job所需要的资源是不一样的,比如说JOB中包含排序和保存数据到磁盘文件的stage,需要高的IO操作,这时根据系统情况分配多个scratchdisk可以显著提高排序效率。做为示例我做了这样一个job;

Select_bigData 从源表中读取一张包含1亿数据的表;
Sort_bigData 对源表的数据进行复杂的排序操作;
Tran_bigData 对排好序的数据进行转换;
最后将数据保存到目标表。
我为该job定义了一个config file:

/* beging of config */
{
    node "node1"
    {
        fastname "domain01"
        pools ""
        resource disk "/Data/SHAREDATA/Datasets" {pools ""}
        resource scratchdisk "/Data/scratch01" {pools ""}
    }
    node "node2"
    {
        fastname "domain01"
        pools ""
        resource disk "/Data/SHAREDATA/Datasets" {pools ""}
        resource scratchdisk "/Data/scratch02" {pools ""}
    }

    node "node3"
    {
        fastname "domain01"
        pools ""
        resource disk "/Data/SHAREDATA/Datasets" {pools ""}
        resource scratchdisk "/Data/scratch03" {pools ""}
    }
    node "node4"
    {
        fastname "domain01"
        pools ""
        resource disk "/Data/SHAREDATA/Datasets" {pools ""}
        resource scratchdisk "/Data/scratch04" {pools ""}
    }
}/* end of entire config */

在config file 中包含4个逻辑节点,so 当运行job时ds会创建4个进程并行处理;4个逻辑节点中分别分配了不同的scratchdisk,这样并行进程即可将数据以集合的方式分别写入4个scratchdisk中完成排序操作。so 在job开始前,检查了系统的ds进程情况,只有一个正在连接的dsapi_slave;

 phantom printer segments!
 DSnum Uid       Pid   Ppid  C Stime Tty      Time     Command
  sywu     12431 12430  0 11:02 ?        00:00:07 dsapi_slave 7 6 0 4

当job启动运行时,ds便读取配置文件,然后计算和分配资源; 

4 phantom printer segments!
 DSnum Uid       Pid   Ppid  C Stime Tty      Time     Command
 49932 sywu     15604 15564  0 11:52 ?        00:00:00 phantom DSD.OshMonitor Clu
 49937 sywu     15599 15564  0 11:52 ?        00:00:00 phantom SH -c \'/software/I
 49972 sywu     15564 12431  1 11:52 ?        00:00:00 phantom DSD.RUN ClusterRea
 53105 sywu     12431 12430  0 11:02 ?        00:00:10 dsapi_slave 7 6 0 4

这些并行进程同时处理不同的操作:

[domain01:dsadm]ps -ef|grep 15604
sywu     15604 15564  0 11:52 ?        00:00:00 phantom DSD.OshMonitor ClusterReadBigDataAndSaveToTab 15603 MSEVENTS.FALSE
dsadm    16816 17037  0 11:52 pts/0    00:00:00 grep 15604
[domain01:dsadm]ps -ef|grep 15599
sywu     15599 15564  0 11:52 ?        00:00:00 phantom SH -c \'/software/IBM/InformationServer/Server/DSEngine/bin/OshWrapper RT_SCTEMP/ClusterReadBigDataAndSaveToTab.fifo RT_SC3/OshExecuter.sh R DUMMY  -f RT_SC3/OshScript.osh -monitorport 13400 -pf RT_SC3/jpfile -impexp_charset UTF-8 -string_charset UTF-8 -input_charset UTF-8 -output_charset UTF-8 -collation_sequence OFF\'
sywu     15602 15599  0 11:52 ?        00:00:00 /software/IBM/InformationServer/Server/DSEngine/bin/OshWrapper RT_SCTEMP/ClusterReadBigDataAndSaveToTab.fifo RT_SC3/OshExecuter.sh R DUMMY -f RT_SC3/OshScript.osh -monitorport 13400 -pf RT_SC3/jpfile -impexp_charset UTF-8 -string_charset UTF-8 -input_charset UTF-8 -output_charset UTF-8 -collation_sequence OFF
dsadm    16819 17037  0 11:53 pts/0    00:00:00 grep 15599
[domain01:dsadm]ps -ef|grep 15564
sywu     15564 12431  0 11:52 ?        00:00:00 phantom DSD.RUN ClusterReadBigDataAndSaveToTab 0/0/1/0/0/0/0/
sywu     15599 15564  0 11:52 ?        00:00:00 phantom SH -c \'/software/IBM/InformationServer/Server/DSEngine/bin/OshWrapper RT_SCTEMP/ClusterReadBigDataAndSaveToTab.fifo RT_SC3/OshExecuter.sh R DUMMY  -f RT_SC3/OshScript.osh -monitorport 13400 -pf RT_SC3/jpfile -impexp_charset UTF-8 -string_charset UTF-8 -input_charset UTF-8 -output_charset UTF-8 -collation_sequence OFF\'
sywu     15604 15564  0 11:52 ?        00:00:00 phantom DSD.OshMonitor ClusterReadBigDataAndSaveToTab 15603 MSEVENTS.FALSE
dsadm    16822 17037  0 11:53 pts/0    00:00:00 grep 15564
[domain01:dsadm]ps -ef|grep 12431
sywu     12431 12430  0 11:02 ?        00:00:10 dsapi_slave 7 6 0 4
sywu     15564 12431  0 11:52 ?        00:00:00 phantom DSD.RUN ClusterReadBigDataAndSaveToTab 0/0/1/0/0/0/0/
dsadm    16826 17037  0 11:53 pts/0    00:00:00 grep 12431

每一个并行进程向相应的scratchdisk中写临时数据;

[domain01:dsadm]ls  /Data/scratch01
tsort50d0A7CB  tsort50db8yql  tsort50d_Dflj  tsort50dfY9VY  tsort50djuws6  tsort50dPpmTS  tsort50dTwSkn  tsort50dxaZhz
tsort50d0K6rw  tsort50dBD7Lr  tsort50dDl1hJ  tsort50dGM1PK  tsort50dk3CQP  tsort50dpS_7P  tsort50dtWx6t  tsort50dX@oqU
....
[domain01:dsadm]ls  /Data/scratch02
tsort40d0A7CB  tsort40dBD7Lr  tsort40ddrQKv  tsort40dgoGBU  tsort40dKj8K3  tsort40d__Rs8  tsort40duZ4Zu  tsort40dZ2z@z
tsort40d0K6rw  tsort40dbEMco  tsort40degDYO  tsort40dgVgZs  tsort40d@kl2X  tsort40dSAMWF  tsort40dVAwRI  tsort40dzpg0g
...
[domain01:dsadm]ls  /Data/scratch03
tsort90d0A7CB  tsort90dBD7Lr  tsort90ddrQKv  tsort90dgoGBU  tsort90dKj8K3  tsort90d__Rs8  tsort90duZ4Zu  tsort90dZ2z@z
tsort90d0K6rw  tsort90dbEMco  tsort90degDYO  tsort90dgVgZs  tsort90d@kl2X  tsort90dSAMWF  tsort90dVAwRI  tsort90dzpg0g
...
[domain01:dsadm]ls  /Data/scratch04
tsort70d0A7CB  tsort70dBD7Lr  tsort70ddrQKv  tsort70dgoGBU  tsort70dKj8K3  tsort70d__Rs8  tsort70duZ4Zu  tsort70dZ2z@z
tsort70d0K6rw  tsort70dbEMco  tsort70degDYO  tsort70dgVgZs  tsort70d@kl2X  tsort70dSAMWF  tsort70dVAwRI  tsort70dzpg0g
tsort70d_0oKX  tsort70dbo642  tsort70deP8o7  tsort70dH6oYi  tsort70dL9Gnu  tsort70dSG2rc  tsort70dVUr3y  tsort70dZrp8k
...

3.1 SMP Server配置文件

当系统运行在共享共享memory,多进程系统中,比如SMP server,假设系统有4个cpu,有4个分离的文件系统磁盘(/fdisk01,/fdisk02,/fdisk03,/fdisk04),为了更好的优化并行资源,创建如下的配置文件:

/* beging of config */
{
    node "node1"
    {
        fastname "domain01"
        pools ""
        resource disk "/fdisk01/disk" {}
        resource disk "/fdisk02/disk" {}
        resource disk "/fdisk03/disk" {}
        resource disk "/fdisk04/disk" {}
        resource scratchdisk "/fdisk01/scratch" {}
        resource scratchdisk "/fdisk02/scratch" {}
        resource scratchdisk "/fdisk03/scratch" {}
        resource scratchdisk "/fdisk04/scratch" {}
    }
    node "node2"
    {
        fastname "domain01"
        pools ""
        resource disk "/fdisk01/disk" {}
        resource disk "/fdisk02/disk" {}
        resource disk "/fdisk03/disk" {}
        resource disk "/fdisk04/disk" {}
        resource scratchdisk "/fdisk01/scratch" {}
        resource scratchdisk "/fdisk02/scratch" {}
        resource scratchdisk "/fdisk03/scratch" {}
        resource scratchdisk "/fdisk04/scratch" {}
    }

    node "node3"
    {
        fastname "domain01"
        pools ""
        resource disk "/fdisk01/disk" {}
        resource disk "/fdisk02/disk" {}
        resource disk "/fdisk03/disk" {}
        resource disk "/fdisk04/disk" {}
        resource scratchdisk "/fdisk01/scratch" {}
        resource scratchdisk "/fdisk02/scratch" {}
        resource scratchdisk "/fdisk03/scratch" {}
        resource scratchdisk "/fdisk04/scratch" {}
    }
    node "node4"
    {
        fastname "domain01"
        pools ""
        resource disk "/fdisk01/disk" {}
        resource disk "/fdisk02/disk" {}
        resource disk "/fdisk03/disk" {}
        resource disk "/fdisk04/disk" {}
        resource scratchdisk "/fdisk01/scratch" {}
        resource scratchdisk "/fdisk02/scratch" {}
        resource scratchdisk "/fdisk03/scratch" {}
        resource scratchdisk "/fdisk04/scratch" {}
    }
}/* end of entire config */

这样的配置适用于当job中包含比较复杂很难决定资源分配方式和stage需要较高的IO操作,ds计算指定的disk和scratchdisk,最大化的降低IO。

4 总结

很多情况下需要根据job的复杂程度、包含的stage以及数据量情况来创建相应的配置文件,不同的操作所需的系统、硬件资源不同,对于大数据的排序、保存到文件可能需要到较高的IO资源,对于运算、逻辑处理可能需要较高的CUP资源;创建配置文件时应综合考虑这些因素来创建;配置文件中的逻辑节点越多,可能提高并行作业效率,但同时它也增加了系统的负载。

–The end(2015-11-11)

版权声明:本文为lanston原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/lanston/p/datastage_using_configfile.html