• 
    

    
    

      99热精品在线国产_美女午夜性视频免费_国产精品国产高清国产av_av欧美777_自拍偷自拍亚洲精品老妇_亚洲熟女精品中文字幕_www日本黄色视频网_国产精品野战在线观看 ?

      大數(shù)據(jù)Hadoop集群下Sqoop數(shù)據(jù)傳輸技術(shù)研究

      2024-05-23 08:37:16周少珂郭璇張振平付媛冰
      河南科技 2024年6期
      關(guān)鍵詞:大數(shù)據(jù)

      周少珂 郭璇 張振平 付媛冰

      摘 要:【目的】Hadoop系統(tǒng)是大數(shù)據(jù)分布式集群系統(tǒng),其開源的生態(tài)圈中有眾多功能組件,通過在大數(shù)據(jù)Hadoop集群系統(tǒng)上部署Sqoop組件,將本地關(guān)系型Mysql數(shù)據(jù)庫中的數(shù)據(jù)和Hive數(shù)據(jù)倉庫中存儲(chǔ)的數(shù)據(jù)進(jìn)行快速導(dǎo)入導(dǎo)出,進(jìn)一步研究數(shù)據(jù)傳輸性能。【方法】首先在企業(yè)服務(wù)器上部署配置Hadoop分布式集群系統(tǒng),其次在該集群上部署Sqoop組件并測(cè)試與Mysql數(shù)據(jù)庫和Hive數(shù)據(jù)倉庫的連通性,最后使用Sqoop技術(shù)測(cè)試本地Mysql數(shù)據(jù)庫和Hive數(shù)據(jù)倉庫之間的導(dǎo)入和導(dǎo)出?!窘Y(jié)果】通過Sqoop技術(shù)能夠更加便捷快速地從本地Mysql數(shù)據(jù)庫上傳到Hadoop集群系統(tǒng),與傳統(tǒng)方式下先將本地Mysql數(shù)據(jù)庫中數(shù)據(jù)導(dǎo)出TXT文檔格式后再使用Hive數(shù)據(jù)倉庫的Load數(shù)據(jù)批量加載功能相比,在時(shí)間和效率方面大為提升?!窘Y(jié)論】驗(yàn)證了Sqoop組件在Hadoop集群中部署運(yùn)行的正確性,為大數(shù)據(jù)技術(shù)學(xué)習(xí)者提供一定程度的參考借鑒。

      關(guān)鍵詞:大數(shù)據(jù);Hadoop;分布式集群;Sqoop

      中圖分類號(hào):TP311? ? ?文獻(xiàn)標(biāo)志碼:A? ? ?文章編號(hào):1003-5168(2024)06-0025-04

      DOI:10.19968/j.cnki.hnkj.1003-5168.2024.06.005

      Research on Sqoop Data Transmission Technology Based on Big Data Hadoop Cluster

      ZHOU Shaoke GUO Xuan ZHANG Zhenping FU Yuanbing

      (College of Information Science and Engineering, Henan Vocational College of Applied Technology, Zhengzhou 450042, China)

      Abstract:[Purposes] The Hadoop system is a big data distributed cluster system with numerous functional components in its open source ecosystem. By deploying the Sqoop component on the big data Hadoop cluster system, the data in the local relational MySQL database and the data stored in the Hive data warehouse can be quickly imported and exported, further studying the data transmission performance. [Methods] This article first deploys and configures the Hadoop distributed cluster system on the enterprise server, and then deploys the Sqoop component on the cluster and tests its connectivity with the MySQL database and Hive data warehouse. Finally, this paper uses Sqoop technology to test the import and export between the local MySQL database and Hive data warehouse. [Findings] Through Sqoop technology, it is more convenient and fast to upload data from the local MySQL database to the Hadoop cluster system. Compared to traditional methods of exporting data from the local MySQL database to TXT document format and then using the Hive data warehouse's Load data batch loading function, the technology greatly improves time and efficiency. [Conclusions] This paper verifies the correctness of deploying and running Sqoop components in Hadoop clusters, providing a certain degree of reference for big data technology learners.

      Keywords: big data; Hadoop; distributed clustering; Sqoop

      0 引言

      Hadoop起始于2002年Apache項(xiàng)目中的Nutch項(xiàng)目。開發(fā)者通過學(xué)習(xí)和借鑒Google的開源GFS、MapReduce、BigTable三篇論文,開發(fā)創(chuàng)建出Hadoop項(xiàng)目。隨著技術(shù)的發(fā)展,Hadoop版本已經(jīng)發(fā)展到Apache Hadoop 3.3.6[1]。

      目前,Hadoop生態(tài)圈發(fā)展日益完善,其中包括HDFS分布式文件系統(tǒng)、MapReduce計(jì)算模型、Zookeeper協(xié)調(diào)一致性服務(wù)、Hbase列式數(shù)據(jù)庫、Hive數(shù)據(jù)倉庫、Flume日志采集、Sqoop數(shù)據(jù)泵等眾多生態(tài)圈中的組件[2]。Sqoop組件功能是完成關(guān)系型(如Mysql、Oracle)和大數(shù)據(jù)集群型(如Hbase)數(shù)據(jù)庫、Hive數(shù)據(jù)倉庫、HDFS分布式文件系統(tǒng)之間數(shù)據(jù)導(dǎo)入導(dǎo)出的存儲(chǔ)[3]。

      1 Hadoop集群部署

      Hadoop項(xiàng)目整體包括底層的大數(shù)據(jù)分布式集群部署和上層的大數(shù)據(jù)應(yīng)用開發(fā),本研究主要針對(duì)底層大數(shù)據(jù)分布式集群部署進(jìn)行研究。在Hadoop分布式集群部署中可以分為三類:?jiǎn)螜C(jī)版Hadoop集群;偽分布式Hadoop集群;完全分布式Hadoop集群。其中完全分布式集群部署是真實(shí)集群環(huán)境,前兩類集群僅僅作為初學(xué)者進(jìn)行學(xué)習(xí)的參考。

      本研究使用三臺(tái)Linux系統(tǒng)進(jìn)行Hadoop分布式集群系統(tǒng)配置[4]。在運(yùn)行CentOS7.5發(fā)行版的三臺(tái)Linux系統(tǒng)服務(wù)器上進(jìn)行完全分布式Hadoop集群系統(tǒng)部署。

      首先,進(jìn)行分布式集群中的Java環(huán)境變量的基礎(chǔ)配置。由于Hadoop項(xiàng)目的底層環(huán)境為Java,因此需要在三臺(tái)服務(wù)器中的/etc/profile目錄下配置JDK1.8環(huán)境變量。在配置完畢后需要使用Source命令對(duì)文檔進(jìn)行刷新,使用Java -version命令查看JDK的具體版本信息是否正確。在配置部署前需將各主機(jī)防火墻進(jìn)行關(guān)閉,SeLinux功能禁用,并配置使用本地Yum軟件源,同時(shí)分別修改主機(jī)名為Hadoop01、Hadoop02、Hadoop03,其中Hadoop01為主節(jié)點(diǎn)(即NameNode節(jié)點(diǎn)),Hadoop02和Hadoop03為從節(jié)點(diǎn)(即DataNode節(jié)點(diǎn)),并修改主機(jī)名和IP地址的映射。

      其次,在三臺(tái)CentOS7.5系統(tǒng)服務(wù)器節(jié)點(diǎn)上配置六個(gè)文檔,分別為:hadoop-env.sh文檔;core-site.xml文檔;yarn-site.xml文檔;mapred-site.xml文檔;hdfs-site.xml文檔;master-slave文檔。該文件主要保存和記錄分布式集群數(shù)量和名稱,使集群成為統(tǒng)一運(yùn)行整體。該文件中需把所有DataNode數(shù)據(jù)節(jié)點(diǎn)的主機(jī)名添加至文件中,且每個(gè)DataNode數(shù)據(jù)節(jié)點(diǎn)名稱單獨(dú)占用一行記錄[5]。

      再次,對(duì)Hadoop分布式集群系統(tǒng)NameNode控制節(jié)點(diǎn)在Shell終端環(huán)境下進(jìn)行Hadoop namenode format格式化命令操作。在格式化節(jié)點(diǎn)過程中不要進(jìn)行多次操作,以免造成NameNode節(jié)點(diǎn)和DataNode節(jié)點(diǎn)不同步,影響系統(tǒng)的穩(wěn)定性,通過使用Start-all.sh命令啟動(dòng)集群。

      最后,Hadoop分布式集群系統(tǒng)運(yùn)行成功后,就可以隨機(jī)選擇任何一臺(tái)主機(jī)進(jìn)行測(cè)試,有兩種方式進(jìn)行測(cè)試。一種是瀏覽器Web界面登錄方式。使用瀏覽器輸入http://主節(jié)點(diǎn)IP地址(或域名):50070,進(jìn)入HDFS分布式文件系統(tǒng)界面,如圖1所示。另一種是通過Shell終端命令方式。輸入“JPS”“hadoop fs –ls / ”等命令。

      2 Sqoop配置部署

      Sqoop組件是Hadoop系統(tǒng)生態(tài)圈中的組件之一,也稱作“數(shù)據(jù)泵”。主要是本地關(guān)系型(如Mysql、Oracle)數(shù)據(jù)庫和大數(shù)據(jù)Hadoop集群中的非關(guān)系型(如Hbase)數(shù)據(jù)庫、Hive數(shù)據(jù)倉庫、HDFS分布式文件系統(tǒng)之間數(shù)據(jù)的導(dǎo)入導(dǎo)出,Sqoop組件技術(shù)更加方便數(shù)據(jù)之間傳輸?shù)母咝院捅憬菪?。在Hadoop分布式集群系統(tǒng)、Hive數(shù)據(jù)倉庫、Mysql關(guān)系型數(shù)據(jù)庫已正確完成部署后,本研究以Linux系統(tǒng)中Mysql本地?cái)?shù)據(jù)庫和Hadoop分布式集群中的Hive數(shù)據(jù)倉庫二者為研究對(duì)象,進(jìn)行數(shù)據(jù)間的傳輸測(cè)試,其Sqoop組件工作原理,如圖2所示。

      Sqoop組件是開源免費(fèi)的,可以在開源鏡像站中下載,本研究使用Sqoop-1.4.7.bin__hadoop-2.7.6.tar.gz壓縮包,Sqoop版本為1.4.7。為了避免操作權(quán)限的影響,Linux操作系統(tǒng)中使用root管理員權(quán)限身份操作,在Hadoop完全分布式集群(三臺(tái)服務(wù)器)運(yùn)行的基礎(chǔ)上,通過Hadoop01(即Master節(jié)點(diǎn))進(jìn)行Sqoop組件的安裝部署。

      ①上傳服務(wù)器Sqoop組件。使用將SecureCRT遠(yuǎn)程登錄軟件,將Sqoop壓縮包上傳至/root目錄下,并將/root/Sqoop-1.4.7.bin__hadoop-2.7.6.tar.gz壓縮包解壓到/usr/local/src目錄。將解壓后生成的Sqoop-1.4.7.bin__hadoop-2.7.6文件夾更名為Sqoop。

      ②修改并配置Sqoop環(huán)境。復(fù)制Sqoop-env-template.sh模板,并將模板重命名為Sqoop-env.sh。修改Sqoop-env.sh文件,添加Hdoop、Hbase、Hive等組件的安裝路徑。

      ④配置連接Mysql數(shù)據(jù)庫。為了使Sqoop能夠連接MySQL數(shù)據(jù)庫,需要將Mysql-connector-java-5.1.46.jar文件放入Sqoop的lib目錄中。該jar文件版本需要與MySQL數(shù)據(jù)庫的5.7版本相對(duì)應(yīng),否則Sqoop導(dǎo)入數(shù)據(jù)時(shí)會(huì)報(bào)錯(cuò)。

      ⑤測(cè)試Sqoop組件連接Mysql數(shù)據(jù)庫。在Master服務(wù)器節(jié)點(diǎn)上啟動(dòng)Hadoop分布式集群系統(tǒng),測(cè)試Sqoop組件是否能夠正常連接Mysql數(shù)據(jù)庫。使用“sqoop list-databases --connect jdbc:mysql://hadoop01:3306/ --username root -P Mysql數(shù)據(jù)庫密碼”命令,能夠查看到MySQL數(shù)據(jù)庫中的information_schema、hive、mysql、performance_schema、sys等數(shù)據(jù),說明Sqoop可以正常連接MySQL數(shù)據(jù)庫。

      ⑥測(cè)試Sqoop組件連接Hive數(shù)據(jù)倉庫。為使Sqoop能夠連接Hive,需要將Hive組件/usr/local/src/hive/lib目錄下的hive-common-2.0.0.jar放入Sqoop安裝路徑的lib目錄中,該jar包為內(nèi)部調(diào)用普通庫函數(shù)時(shí)所需要使用的包。

      通過以上六步的配置,完成了Hadoop分布式集群系統(tǒng)中Sqoop組件的安裝部署,并能夠使用Sqoop相關(guān)命令進(jìn)行本地Mysql數(shù)據(jù)庫和Hive數(shù)據(jù)倉庫的連接。其中Hive數(shù)據(jù)倉庫并非數(shù)據(jù)庫而是一種數(shù)據(jù)庫引擎,通過Hive將數(shù)據(jù)存儲(chǔ)在HDFS分布式文件系統(tǒng)中。

      3 Sqoop功能測(cè)試

      根據(jù)Sqoop組件功能,其測(cè)試包含兩個(gè)方面。一方面是,將本地Mysql數(shù)據(jù)庫中的數(shù)據(jù)進(jìn)行導(dǎo)出,通過Sqoop技術(shù)再次將該數(shù)據(jù)導(dǎo)入到Hive數(shù)據(jù)倉庫中。另一方面是,將Hive數(shù)據(jù)倉庫中的數(shù)據(jù)導(dǎo)出,通過Sqoop技術(shù)再次將該數(shù)據(jù)導(dǎo)入到本地Mysql數(shù)據(jù)庫中。測(cè)試完成后,通過實(shí)際的運(yùn)行結(jié)果,驗(yàn)證Sqoop配置的正確性和性能。

      ①創(chuàng)建Mysql數(shù)據(jù)庫和數(shù)據(jù)表的樣本數(shù)據(jù)。使用Root管理員權(quán)限身份登錄Linux本地系統(tǒng)的Mysql數(shù)據(jù)庫,創(chuàng)建Example數(shù)據(jù)庫和樣例Student表,該表格有Snumber學(xué)號(hào)主鍵列和Sname姓名列。“create table Student(Snumber char(9) primary key,Sname varchar(10));”并向該表格中插入三行詳細(xì)數(shù)據(jù)“insert into Student values(‘01,‘ZhangSan);”“insert into Student values(‘02,‘LiSi);”“insert into Student values(‘03,WangWu);”

      ②創(chuàng)建Hive數(shù)據(jù)倉庫中的Example數(shù)據(jù)庫和Student數(shù)據(jù)表。在運(yùn)行的Hadoop分布式集群系統(tǒng)中啟動(dòng)Hive數(shù)據(jù)倉庫并創(chuàng)建Example數(shù)據(jù)庫“hive> create database sample;”進(jìn)而創(chuàng)建Student數(shù)據(jù)表“hive> create table Student(Snumber STRING,Sname STRING) row format delimited fields terminated by ‘| stored as textfile;”此時(shí)Hive中的Student數(shù)據(jù)表是使用“|”進(jìn)行、列之間的分割,并最終以textfile文件格式進(jìn)行數(shù)據(jù)存儲(chǔ),此時(shí)Hive中的數(shù)據(jù)庫和表格格式已創(chuàng)建完成。

      ③將本地Mysql數(shù)據(jù)導(dǎo)出,導(dǎo)入Hive數(shù)據(jù)倉庫測(cè)試。本地Mysql數(shù)據(jù)庫中已創(chuàng)建數(shù)據(jù)庫和數(shù)據(jù)表,并插入部分行數(shù)據(jù),所以可以直接在Master服務(wù)器中使用“sqoop import--connectjdbc:mysql://master:3306/Example --username root --password Password123?。〝?shù)據(jù)庫密碼) --table student --fields-terminated-by ‘| --delete-target-dir --num-mappers 1 --hive-import --hive-database Example --hive-table Student”命令進(jìn)行測(cè)試。其中數(shù)據(jù)庫密碼設(shè)定符合密碼復(fù)雜度即可,在該命令底層運(yùn)行過程中會(huì)轉(zhuǎn)換成一個(gè)MapReduce計(jì)算模型的工作任務(wù),如圖3所示。

      ④將Hive數(shù)據(jù)倉庫導(dǎo)出,導(dǎo)入本地Mysql數(shù)據(jù)測(cè)試。由于Mysql數(shù)據(jù)庫中已插入部分?jǐn)?shù)據(jù),因此需要先刪除表格中的數(shù)據(jù),但無須刪除表格框架結(jié)構(gòu),使用命令“mysql>use Example; mysql>delete from Student;”在Master節(jié)點(diǎn)中使用“sqoop export --connect jdbc:mysql://master:3306/Example?useUnicode=true &characterEncoding=utf-8 --username root --password Password123!(數(shù)據(jù)庫密碼) --table Student --input-fieldsterminated-by ‘| --export-dir /user/hive/warehouse/Example.db/Student/*”命令。在從Hive導(dǎo)出數(shù)據(jù)過程中,底層需要轉(zhuǎn)換為MapReduce計(jì)算模型的程序進(jìn)行調(diào)用系統(tǒng)程序,因此是以MapReduce程序進(jìn)行運(yùn)行。Hive數(shù)據(jù)倉庫中的數(shù)據(jù)成功導(dǎo)入到本地Mysql數(shù)據(jù)庫中的過程,如圖4所示。

      4 結(jié)語

      Sqoop組件是Hadoop系統(tǒng)生態(tài)圈中的組件之一,其主要功能是進(jìn)行本地?cái)?shù)據(jù)和Hadoop分布式集群系統(tǒng)中數(shù)據(jù)間的傳輸。通過Sqoop技術(shù)能夠更加便捷、快速地從本地Mysql數(shù)據(jù)庫上傳到Hadoop集群系統(tǒng),與傳統(tǒng)方式下將本地Mysql數(shù)據(jù)庫中數(shù)據(jù)導(dǎo)出TXT文檔格式后,再使用Hive數(shù)據(jù)倉庫的Load數(shù)據(jù)批量加載功能相比,在時(shí)間和效率方面大為提升。下一步,可以在此基礎(chǔ)上運(yùn)用海量數(shù)據(jù),從使用Sqoop技術(shù)導(dǎo)入和Hive的Load批量加載兩個(gè)方面,將數(shù)據(jù)導(dǎo)入到Hive數(shù)據(jù)倉庫中進(jìn)行對(duì)比研究,并進(jìn)行性能優(yōu)化。

      參考文獻(xiàn):

      [1]劉曉莉,李滿,熊超,等.基于Hadoop搭建高可用數(shù)據(jù)倉庫的研究和實(shí)現(xiàn)[J].現(xiàn)代信息科技,2023,7(1):99-101.

      [2]李霄揚(yáng),朱恒.基于HHS的離線數(shù)據(jù)分析平臺(tái)的設(shè)計(jì)與實(shí)現(xiàn)[J].電腦知識(shí)與技術(shù),2023,19(10):75-77.

      [3]吳建.基于Linux的Hadoop集群搭建的探索與實(shí)現(xiàn)[J].物聯(lián)網(wǎng)技術(shù),2023,13(7):134-137,141.

      [4]王建軍,張英成,戰(zhàn)非,等.基于Sqoop的高校海量結(jié)構(gòu)化數(shù)據(jù)導(dǎo)入研究[J].無線互聯(lián)科技,2018,15(20):52-53.

      [5]周少珂,王雷,崔琳,等.大數(shù)據(jù)Hadoop技術(shù)完全分布式集群部署[J].工業(yè)控制計(jì)算機(jī),2021,34(8):101-103.

      猜你喜歡
      大數(shù)據(jù)
      大數(shù)據(jù)環(huán)境下基于移動(dòng)客戶端的傳統(tǒng)媒體轉(zhuǎn)型思路
      新聞世界(2016年10期)2016-10-11 20:13:53
      基于大數(shù)據(jù)背景下的智慧城市建設(shè)研究
      科技視界(2016年20期)2016-09-29 10:53:22
      數(shù)據(jù)+輿情:南方報(bào)業(yè)創(chuàng)新轉(zhuǎn)型提高服務(wù)能力的探索
      中國記者(2016年6期)2016-08-26 12:36:20
      沐川县| 江城| 凌云县| 清徐县| 襄樊市| 汤原县| 黎川县| 台北市| 商城县| 图木舒克市| 昌都县| 黄梅县| 吉木萨尔县| 曲水县| 新巴尔虎右旗| 晋宁县| 普兰店市| 鱼台县| 香格里拉县| 磐石市| 大足县| 比如县| 大丰市| 胶南市| 罗山县| 广西| 黄骅市| 辽阳县| 莱州市| 鹤壁市| 若羌县| 屏边| 大田县| 江源县| 涞水县| 台南县| 方山县| 海兴县| 潞城市| 萨嘎县| 常宁市|