列式存儲infobright

一、數據庫安裝


安裝java

#查看默認路徑 rpm -qpl infobright-4.5.0-4-x86_64-eval.rpm
rpm -ivh --relocate /usr/local = /data/server/ infobright-4.5.0-4-x86_64- eval .rpm


設置權限mysql

GRANT ALL PRIVILEGES ON *.* TO 'root' @ '192.168.%' IDENTIFIED BY 'password' WITH GRANT OPTION ;
flush privileges ;


編輯配置文件,修改數據文件路徑、默認表引擎 編碼sql

vim /etc/my-ib.cnf 數據庫

port            = 3337
basedir= /data/server/infobright
datadir = /data/data/infobright
log-error = /data/data/infobright/bh .err
 
default-storage-engine=MyISAM
#collation_server=latin1_bin
#character_set_server=latin1
collation_server=utf8_general_ci
character_set_server=utf8


啓動數據庫vim

/etc/init .d /mysqld-ib start

#/etc/init.d/mysqld-ib stopbash


二、數據導入


要求爲標準csv格式,經過load data導入ide


LOAD DATA INFILE '/data/tmp/01/temp.csv'
INTO TABLE log_epg
FIELDS
TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
;



三、數據分析——示例1


 

文件格式csv,如下兩種格式合法編碼

/data/tmp/rwdata/0209/0151.txtspa

"015159014000001","0C:C6:55:24:9F:97"code

"015159014000002" , "0C:C6:55:24:9F:98"
"015159014000003" , "0C:C6:55:24:9F:99"
"015159014000004" , "0C:C6:55:24:9F:9A"
"015159014000005" , "0C:C6:55:24:9F:9B"
"015159014000006" , "0C:C6:55:24:9F:9C"
"015159014000007" , "0C:C6:55:24:9F:9D"
"015159014000008" , "0C:C6:55:24:9F:9E"
"015159014000009" , "0C:C6:55:24:9F:9F"
"015159014000010" , "0C:C6:55:24:9F:A0"
"015159014000011" , "0C:C6:55:24:9F:A1"  


/data/tmp/rwdata/0209/aaamac.csv

010121011011501,0C:C6:55:1E:BC:B7

010121011011502 ,0C:C6: 55 :1E:BC:B8
010121011011503 ,0C:C6: 55 :1E:BC:B9
010121011011504 ,0C:C6: 55 :1E:BC:BA
010121011011505 ,0C:C6: 55 :1E:BC:BB
010121011011506 ,0C:C6: 55 :1E:BC:BC
010121011011507 ,0C:C6: 55 :1E:BC:BD
010121011011508 ,0C:C6: 55 :1E:BC:BE



若是有非標準字符,須要進行預處理

#sed -i "s/|/,/g" 0151.txt
 
"015159014000001" | "0C:C6:55:24:9F:97"
"015159014000002" | "0C:C6:55:24:9F:98"
"015159014000003" | "0C:C6:55:24:9F:99"
"015159014000004" | "0C:C6:55:24:9F:9A"
"015159014000005" | "0C:C6:55:24:9F:9B"


表建立

use rwdata
CREATE TABLE `t0151` (
   `icntvid` varchar (255) DEFAULT '' ,
   `mac` varchar (255) DEFAULT ''
) ENGINE=BRIGHTHOUSE DEFAULT CHARSET=utf8;
 
CREATE TABLE `aaamac` (
   `icntvid` varchar (255) DEFAULT '' ,
   `mac` varchar (255) DEFAULT ''
) ENGINE=BRIGHTHOUSE DEFAULT CHARSET=utf8;


數據導入

set @bh_dataformat = 'txt_variable' ;
 
LOAD DATA INFILE '/data/tmp/rwdata/0209/aaamac.csv'
INTO TABLE aaamac
FIELDS
TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
;
 
LOAD DATA INFILE '/data/tmp/rwdata/0209/0151.txt '
INTO TABLE t0151
FIELDS
TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
;


查詢

SELECT t0151.*,aaamac.mac AS aaa_mac FROM t0151,aaamac WHERE t0151.icntvid=aaamac.icntvid AND t0151.mac!=aaamac.mac


確認無誤後,將查詢結果生成表,而後導出

CREATE TABLE data_result AS SELECT t0151.*,aaamac.mac AS aaa_mac FROM t0151,aaamac WHERE t0151.icntvid=aaamac.icntvid AND t0151.mac!=aaamac

相關文章
相關標籤/搜索