您好,登錄后才能下訂單哦!
這篇文章主要講解了“從oracle到hdfs如何初始化數(shù)據(jù)”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“從oracle到hdfs如何初始化數(shù)據(jù)”吧!
### oracle GoldenGate for BigData 部分
### 本章節(jié)重點(diǎn)描述: 如何初始化數(shù)據(jù),從oracle 到 hdfs
解壓OGG軟件
# chown htjs:htjs 123010_ggs_Adapters_Linux_x64.zip
# mv 123010_ggs_Adapters_Linux_x64.zip /home/htjs/
# su - htjs
$ unzip 123010_ggs_Adapters_Linux_x64.zip -d /ogg/oggbd
$ cd /ogg/oggbd
$ tar -xf ggs_Adapters_Linux_x64.tar
$ ./ggsci
啟動mgr
GGSCI (node1) 1>
create subdirs
edit params mgr
port 7839
start manager
exit
hdfs配置文件
$ cp /ogg/oggbd/AdapterExamples/big-data/hdfs/* /ogg/oggbd/dirprm/
$ vi /ogg/oggbd/dirprm/hdfs.props
...這個目錄前面已經(jīng)創(chuàng)建
gg.handler.hdfs.rootFilePath=/ogg1
...這個hadoop的驅(qū)動目錄需要修改
gg.classpath=/usr/hadoop/share/hadoop/common/*:/usr/hadoop/share/hadoop/common/lib/*:/usr/hadoop/share/hadoop/hdfs/*:/usr/hadoop/share/hadoop/hdfs/lib/*:/usr/hadoop/etc/hadoop/:
irhdfs.prm 參數(shù)文件
$ cat irhdfs.prm
--passive REPLICAT for initial load irhdfs
-- Trail file for this example is located in "dirdat/initld"
-- Command to run REPLICAT:
-- ./replicat paramfile dirprm/irhdfs.prm reportfile dirrpt/ini_rhdfs.rpt
SPECIALRUN
END RUNTIME
EXTFILE /ogg/oggbd/dirdat/initld
--DDLERROR default discard
setenv HADOOP_COMMON_LIB_NATIVE_DIR=/usr/hadoop/lib/native
DDL include all
TARGETDB LIBFILE libggjava.so SET property=dirprm/hdfs.props
REPORTCOUNT EVERY 1 MINUTES, RATE
GROUPTRANSOPS 10000
MAP ggtest.tt, TARGET bdtest.tt;
這個時候,需要去源端10.10.13.53服務(wù)器上,啟動ogg,
將ggtest的tt表的初始化數(shù)據(jù),推給本地/ogg/oggbd/dirdat
檢查源端參數(shù)文件 ini_ext.prm
[crmdb2:oracle] cat ini_ext.prm
SOURCEISTABLE
userid ogg@spark,password AACAAAAAAAAAAAHAYBGFCDZCJHWCEIHH, BLOWFISH, ENCRYPTKEY DEFAULT
--RMTHOSTOPTIONS
RMTHOST slave03, MGRPORT 7839 (對應(yīng)hosts文件的 10.3.105.41 slave03)
RMTFILE /ogg/oggbd/dirdat/initld, MEGABYTES 2, PURGE
--DDL include objname ggtest.*
TABLE ggtest.tt;
或者源端先生成到自己的dirdat目錄,然后復(fù)制給目標(biāo)端
[crmdb2:oracle] vi ini_ext.prm
"ini_ext.prm" 8 lines, 251 characters
SOURCEISTABLE
userid ogg@spark,password AACAAAAAAAAAAAHAYBGFCDZCJHWCEIHH, BLOWFISH, ENCRYPTKEY DEFAULT
--RMTHOSTOPTIONS
RMTHOST crmdb2, MGRPORT 7829
RMTFILE /ogg/oggora/dirdat/initld, MEGABYTES 2, PURGE
--DDL include objname ggtest.*
TABLE ggtest.tt;
./extract paramfile dirprm/ini_ext.prm reportfile dirrpt/ini_ext.rpt
目標(biāo)端文件放到dirdat目錄下
[root@node1 ~]# chown htjs:htjs initld
[root@node1 ~]# mv initld /ogg/oggbd/dirdat/
$ ./replicat paramfile dirprm/irhdfs.prm reportfile dirrpt/initld.rpt
檢查導(dǎo)入結(jié)果
[htjs@node1 oggbd]$ hdfs dfs -ls /ogg1
Found 2 items
-rw-r--r-- 3 htjs supergroup 0 2017-07-21 10:43 /ogg1/README.txt
drwxr-xr-x - htjs supergroup 0 2017-07-21 13:16 /ogg1/bdtest.tt 新建的目錄
[htjs@node1 oggbd]$ hdfs dfs -ls /ogg1/bdtest.tt 目錄下的文件
Found 1 items
-rw-r--r-- 3 htjs supergroup 13826 2017-07-21 13:16 /ogg1/bdtest.tt/bdtest.tt_2017-07-21_13-15-58.773.txt
hdfs dfs -tail /ogg1/bdtest.tt/bdtest.tt_2017-07-21_13-15-58.773.txt
創(chuàng)建一個外部表,來查詢數(shù)據(jù)。
hive> create database bdtest;
hive> CREATE EXTERNAL TABLE BDTEST.tt
(
owner string,
table_name string,
tablespace_name string,
cluster_name string,
iot_name string,
status string,
pct_free string,
pct_used string,
ini_trans string,
max_trans string,
initial_extent string,
next_extent string,
min_extents string,
max_extents string,
pct_increase string,
freelists string,
freelist_groups string,
logging string,
backed_up string,
num_rows string,
blocks string,
empty_blocks string,
avg_space string,
chain_cnt string,
avg_row_len string,
avg_space_freelist_blocks string,
num_freelist_blocks string,
degree string,
instances string,
cache string,
table_lock string,
sample_size string,
last_analyzed string,
partitioned VARCHAR(3),
iot_type VARCHAR(12),
temporary VARCHAR(1),
secondary VARCHAR(1),
nested VARCHAR(3),
buffer_pool VARCHAR(7),
flash_cache VARCHAR(7),
cell_flash_cache VARCHAR(7),
row_movement VARCHAR(8),
global_stats VARCHAR(3),
user_stats VARCHAR(3),
duration VARCHAR(15),
skip_corrupt VARCHAR(8),
monitoring VARCHAR(3),
cluster_owner VARCHAR(30),
dependencies VARCHAR(8),
compression VARCHAR(8),
compress_for VARCHAR(12),
dropped VARCHAR(3),
read_only VARCHAR(3),
segment_created VARCHAR(3),
result_cache VARCHAR(7)
)
stored as textfile location '/ogg1/bdtest.tt';
hive> select * from bdtest.tt;
初始化完成,接下來可以啟動復(fù)制進(jìn)程,開始同步數(shù)據(jù)了。
將原來10.3.254.53 mongoDB環(huán)境中的/ogg/oggbd/dirdat/in000XXX 的文件,
復(fù)制到10.3.105.41:/ogg/oggbd/dirdat
原來是導(dǎo)入到mongoDB中,這次導(dǎo)入到hdfs中。
添加目標(biāo)端的replicat進(jìn)程,讀取in000XXX,導(dǎo)入到hdfs
cat repfils.prm
REPLICAT REPFILS
-- Trail file for this example is located in "AdapterExamples/trail" directory
-- Command to add REPLICAT
-- add replicat repfils, exttrail AdapterExamples/trail/tr
TARGETDB LIBFILE libggjava.so SET property=dirprm/hdfs.props
REPORTCOUNT EVERY 1 MINUTES, RATE
GROUPTRANSOPS 10000
MAP ggtest.*, TARGET bdtest.*;
add replicat repfils, exttrail /ogg/oggbd/dirdat/in
hive> create table bdtest.yth_client_userinfo(
id VARCHAR(32),
qyid VARCHAR(32),
khsh VARCHAR(32),
dlzh VARCHAR(32),
cps VARCHAR(1024),
khshs VARCHAR(1024),
clientver VARCHAR(32),
createtime string,
clientip VARCHAR(100),
browser VARCHAR(32),
os VARCHAR(32),
memory VARCHAR(32),
clientid VARCHAR(100)
)
stored as textfile location '/ogg1/bdtest.yth_client_userinfo';
ogg 配置完畢。下一章節(jié) 增量數(shù)據(jù)從oracle同步到hdfs
感謝各位的閱讀,以上就是“從oracle到hdfs如何初始化數(shù)據(jù)”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對從oracle到hdfs如何初始化數(shù)據(jù)這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。