您好,登錄后才能下訂單哦!
這篇文章主要講解了“從oracle到hdfs如何初始化數據”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“從oracle到hdfs如何初始化數據”吧!
### oracle GoldenGate for BigData 部分
### 本章節重點描述: 如何初始化數據,從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
...這個目錄前面已經創建
gg.handler.hdfs.rootFilePath=/ogg1
...這個hadoop的驅動目錄需要修改
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 參數文件
$ 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服務器上,啟動ogg,
將ggtest的tt表的初始化數據,推給本地/ogg/oggbd/dirdat
檢查源端參數文件 ini_ext.prm
[crmdb2:oracle] cat ini_ext.prm
SOURCEISTABLE
userid ogg@spark,password AACAAAAAAAAAAAHAYBGFCDZCJHWCEIHH, BLOWFISH, ENCRYPTKEY DEFAULT
--RMTHOSTOPTIONS
RMTHOST slave03, MGRPORT 7839 (對應hosts文件的 10.3.105.41 slave03)
RMTFILE /ogg/oggbd/dirdat/initld, MEGABYTES 2, PURGE
--DDL include objname ggtest.*
TABLE ggtest.tt;
或者源端先生成到自己的dirdat目錄,然后復制給目標端
[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
目標端文件放到dirdat目錄下
[root@node1 ~]# chown htjs:htjs initld
[root@node1 ~]# mv initld /ogg/oggbd/dirdat/
$ ./replicat paramfile dirprm/irhdfs.prm reportfile dirrpt/initld.rpt
檢查導入結果
[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
創建一個外部表,來查詢數據。
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;
初始化完成,接下來可以啟動復制進程,開始同步數據了。
將原來10.3.254.53 mongoDB環境中的/ogg/oggbd/dirdat/in000XXX 的文件,
復制到10.3.105.41:/ogg/oggbd/dirdat
原來是導入到mongoDB中,這次導入到hdfs中。
添加目標端的replicat進程,讀取in000XXX,導入到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 配置完畢。下一章節 增量數據從oracle同步到hdfs
感謝各位的閱讀,以上就是“從oracle到hdfs如何初始化數據”的內容了,經過本文的學習后,相信大家對從oracle到hdfs如何初始化數據這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。