ApacheのアクセスログをSQL*LoaderでOracleにロード

| コメント(0) | トラックバック(0)

ログファイル等をOracleを使って適当に分析したいときなんかに便利っぽいのでメモ。

適当にテーブルを作成(ちゃんとしたい場合は仕様を調べる)

SQL> create table apache_access_log (
  2    ip_address     char(20)     ,
  3    user_inf       char(20)     ,
  4    user_id        char(20)     ,
  5    req_date       char(60)     ,
  6    request        varchar2(512),
  7    status_cd      char(10)     ,
  8    res_size       char(10)     ,
  9    referer        varchar2(256),
 10    user_agent     varchar2(256)
 11  )
 12 /

SQL*Loader 制御ファイル(apache_access_log.ctl)の作成

-- appache access logfile load sample control file
load data                            -- 新しくデータロードが開始される
infile  'access_log'                 -- ロードするデータが入っているファイル名
badfile 'access_log.bad'             -- 拒否レコードが書き込まれるファイル名
discardfile 'access_log.dsc'         -- 廃棄レコードが書き込まれるファイル名
insert                               -- すでにデータが存在する場合のオプション APPEND,REPLACE,TRUNCATE
into table exam.apache_access_log    -- 
(  ip_address   position(*) char terminated by whitespace                 
 , user_inf     position(*) char terminated by whitespace
 , user_id      position(*) char terminated by whitespace  
 , req_date     position(*) char enclosed by '[' and ']'         
 , request      position(*) char enclosed by '"' and '"'
 , status_cd    position(*) char terminated by whitespace
 , res_size     position(*) char terminated by whitespace
 , referer      position(*) char enclosed by '"' and '"'
 , user_agent   position(*) char enclosed by '"' and '"'
)

実行

$sqlldr userid/passwd apache_access_log.ctl 

SQL*Loader: Release 10.2.0.1.0 - Production on Sat Jul 11 22:05:04 2009

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Commit point reached - logical record count 64
Commit point reached - logical record count 128
:

取り込まれた

ora_sqlldr02

もう少し細かいメモ /tips/wiki.cgi?page=Oracle+Database10g+SQL*Loader

トラックバック(0)

トラックバックURL: http://typea.info/mt/mt-tb.cgi/140

コメントする



このブログ記事について

このページは、pirotoが2009年7月11日 14:19に書いたブログ記事です。

ひとつ前のブログ記事は「mixiアプリ Twitter API 編 (検索してみる)」です。

次のブログ記事は「ネクスト・ソサエティ ~ これからどうやって生きていこうかしら」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。

ウェブページ

OpenID対応しています OpenIDについて
Powered by Movable Type 5.02