數據合併,相當於數據庫中的merge
行列轉換,需要將某些數據轉換成行,或者是將行轉換成列
參照完整性檢查,對於數據中的參照完整性,入庫前需要進行關聯等方式檢查其參照完整性
唯一性檢查,對數據進行去重操作
3.4.3 Load
就是將數據入庫,如果前面的處理都做了,就可以直接入庫了。入庫的時候需要考濾:
更新入庫,對數據庫中的記錄進行更新
插入,就是將數據直接入庫
刷新,將表中的數據清空,然後入庫
部分刷新,將表中的部分數據清除,然後入庫
由於性能等方面的需要,入庫前後,可能需要做一些處理,如索引臨時失效,主外鍵約束臨時失效等
3.5 過期文件處理
接口文件或者是ETL中間處理生成的文件會越積越多,久而久之,再大的文件系統也會撐爆,所以就得對文件進行處理了。接口文件或者有些中間生成的文件,過期之後,有些需要歸檔,以供不時之需,有些就可以直接刪了(這個我喜歡)。
這部分的處理最好寫個統一的程序,對所有過期的文件進行處理,當需要過期的數據時,也方便取回。
3.6 過期數據處理
同理,數據也有一個生命周期,當絕大多數都用不到時,就需要對它進行處理了,否則性能,管理,存儲都會是一個大問題。對於數據量很大的表,就是delete掉那些數據耗費的時間也是很驚人的了。還好,各個數據庫廠商都提供了分區表這個東西,detach表分區還是相當快的。當然,將表分區,還得考濾管理,維護,性能方面的問題。充分利用數據庫提供的大數據量的操作方式,將過期數據進行歸檔刪除。
做此操作時,盡量將此表的其他相關操作都停掉,避免產生死鎖或者嚴重的鎖等待。當然,這個也是一個程序實現好了。
第4章 ETL實現
4.1 總體實現
設計完了,那實現就開始了。設計時可以不關心具體用什麼產品,什麼技術,實現時就很得關心這些東西的優劣了。
現在得根據設計時的方式,創建ETL接口文件、臨時文件、中間文件、程序、日誌等的存放方式; DS JOB中用到的參數的存放,傳遞等等這些問題。再對需要的程序和DS的東東進行開發。
Job要聯接數據庫,一般都是通過數據庫客戶端的方式,這樣,需要在在Engine下的dsenv文件中配置數據庫客戶端的聯接方式,同時在DS用戶(默認是dsadm)的.profile文件中進行配置。
另外,Scratch目錄存放DS進行運算時自己生成的臨時文件,如果文件很大,進行排序等操作時此目錄會佔用很大的空間。Datasets存放DS Data Sets Stage生成的文件。所以這兩個目錄需要特別注意。
DS JOB中用到的參數一般有三種方式:一種是在DS Administrator中定義,在JOB中調用;另一種方式是在參數文件或者參數表中定義,用程序調用,賦給相應的JOB;第三種是將兩者混合使用,基本固定不變的參數(如ETL根路徑、數據庫用戶名、密碼)在DS Administrator中設置,經常變化的參數(如接口時間)在參數文件或者參數表中定義。
DS Administrator中定義的參數如下

4.2 調度
調度的複雜程度,決定了調度的方式。
對於調度比較簡單的,可以用Sequence Job將相關JOB串聯起來,不同Sequence Job間的依賴,可以用消息文件或者數據庫記錄的方式,最後直接在Director中配置調度時間。而對於需要記錄執行情況日誌的,則可以再做一層通用的Job,在此Job的Job Control中,用basic寫通用的方式調度其下的E T L Job,並將其記錄日誌,參數就是Job的名稱和時間等。其實就是此類Job調用E T L Job,然後再用Sequence Job調用他們。
而對於比較複雜的,就得單獨開發獨立的程序了。可以在配置表中將不同JOB的執行時間,依賴條件,優先級,順序亂序執行等信息配置進去,寫程序(Shell, Python, Java等)根據不同的情況,按照不同的方式執行,調用DS提供的接口dsJob對JOB進行控制,並將重要的步驟記錄到日誌表中。而對於重傳等操作,可以通過更改日誌表中的狀態來執行。配置的JOB可以是E T L Job,也可以是Sequence Job。
4.3 Parallel Job VS Server Job
E T L用到的Job有Server Job, Parallel Job, Mainframe Job(專供大型機上用的),一般情況下就是Server Job, Parallel Job了。從一類Job轉到另一類Job,跟從一個開發工具轉到另一個開發工具一樣,讓人感到很陌生。項目中是用Server Job合適,還是Parallel Job合適?以下是他們之間的一個比較(直接從網上copy的):
1) The basic difference between server and parallel Jobs is the degree of parallelism. Server Job Stages do not have in built partitoning and parallelism mechanism for extracting and loading data between different Stages.
• All you can do to enhance the speed and perormance in server Jobs is to enable inter process row buffering through the administrator. This helps Stages to exchange data as soon as it is available in the link.
• You could use IPC Stage too which helps one passive Stage read data from another as soon as data is available. In other words, Stages do not have to wait for the entire set of records to be read first and then transferred to the next Stage. Link partitioner and link collector Stages can be used to achieve a certain degree of partitioning paralellism.
• All of the above features which have to be explored in server Jobs are built in dataStage Px.
2) The Px engine runs on a multiprocessor system and takes full advantage of the processing nodes defined in the configuration file. Both SMP and MMP architecture is supported by dataStage Px.
3) Px takes advantage of both pipeline parallelism and partitoning paralellism. Pipeline parallelism means that as soon as data is available between Stages( in pipes or links), it can be exchanged between them without waiting for the entire record set to be read. Partitioning parallelism means that entire record set is partitioned into small sets and processed on different nodes(logical processors). For example if there are 100 records, then if there are 4 logical nodes then each node would process 25 records each. This enhances the speed at which loading takes place to an amazing degree. Imagine situations where billions of records have to be loaded daily. This is where dataStage PX comes as a boon for ETL process and surpasses all other ETL tools in the market.
4) In parallel we have Dataset which acts as the intermediate data storage in the linked list, it is the best storage option it stores the data in dataStage internal format.
5) In parallel we can choose to display OSH , which gives information about the how Job works.
6) In Parallel Transformer there is no reference link possibility, in server Stage reference could be given to transformer. Parallel Stage can use both basic
以下文章點擊率最高
Loading…