04 flume將資料匯入到Hbase

2021-10-03 22:50:23 字數 1808 閱讀 2244

我們已經了解了使用flume監聽埠以及檔案內容,本節將展示使用flume匯入資料到hbase。

# 進到hbase啟動目錄

cd /root/hbase-1.2.6/bin

# 啟動hbase服務

./start-hbase.sh

# 登入到hbase客戶端

./hbase shell

# 在hbase命令列建立乙個表

hbase(main):001:0> create 't2','f2'

a1.sources = r1 

a1.sinks = k1

a1.channels = c1 # describe/configure the source

a1.sources.r1.type = exec

a1.sources.r1.command = tail -f /root/hbase.txt

a1.sources.r1.channels = c1 # describe the sink

a1.sinks.k1.type = logger

a1.sinks.k1.type = hbase

# 與hbase中建立的表名相同

a1.sinks.k1.table = t2

# 與hbase中建立的表的列簇相同

a1.sinks.k1.columnfamily = f2

a1.sinks.k1.serializer = org.apache.flume.sink.hbase.regexhbaseeventserializer

a1.sinks.k1.channel = memorychannel # use a channel which buffers events in memory

a1.channels.c1.type = memory

a1.channels.c1.capacity = 1000

a1.channels.c1.transactioncapacity = 100 # bind the source and sink to the channel

a1.sources.r1.channels = c1

a1.sinks.k1.channel = c1

# 如有jar包已經存在,選擇y予以覆蓋

cp /root/hbase-1.2.6/lib/* /root/apache-flume-1.8.0-bin/lib/

# 進入flume的啟動目錄

cd /root/apache-flume-1.8.0-bin/bin

# 啟動flume

./flume-ng agent -c ../conf -f ../conf/flume-conf.properties -n a1 -dflume.root.logger=info,console

# 建立flume監聽的檔案

touch /root/hbase.txt

# 向hbase.txt中寫入字串

echo 'iamzhangli'>>/root/hbase.txt

echo 'jiangsuwanhe'>>/root/hbase.txt

# 登入到hbase客戶端

./hbase shell

# 檢視t2表,我們會看到剛才加入到hbase.txt中的資料已經進入hbase

hbase(main):001:0> scan 't2'

以上就是flume將資料匯入hbase的過程。

檔案通過flume匯入到kafka

a1 agent flume三大元件 source channel sink a1.sources f1 a1.channels c1 a1.sinks k1 檔案 a1.sources.f1.type spooldir a1.sources.f1.channels c1 將users.csv檔案備...

通過flume把oracle資料匯入到kafka

版本flume 1.6 kafka2.11 第二步 我用的是oracle所以,就把oracle的jdbc包放到flume的lib目錄下。我放的是ojdbc5.jar 第三步 配置flume的conf配置檔案。vi sql kafka.conf 具體配置如下 agenttest.channels ch...

將資料匯入到Oracle中

1.create table people age int,id int 2.建立資料檔案peopledate.txt.資料為 20,1 30,2 3.建立命令檔案 loaddata.ctl 內容為 sqlldr userid dbname dbpasswd control loaddata.ctl...