数据转移-从MySQL到Hive
轉(zhuǎn)載:?https://blog.csdn.net/qq_34100655/article/details/81033022
-
- 簡介
- 打開Hive
- 任務(wù)描述
- 解決思路
- 技術(shù)點(diǎn)
簡介
Hive是Hadoop生態(tài)中非常重要的一環(huán),可以作為數(shù)據(jù)倉庫存儲(chǔ)極大量的數(shù)據(jù);另外,還可以實(shí)現(xiàn)與MySQL、NoSQL等傳統(tǒng)數(shù)據(jù)庫,HBase等大數(shù)據(jù)控件之間的數(shù)據(jù)ETL。在我的日常工作中,將使用Hive的經(jīng)驗(yàn)總結(jié)如下。
打開Hive
Hive從屬于Hadoop生態(tài)的一環(huán),一般安裝在Linux服務(wù)器上,我司也不例外。由于環(huán)境早已配置好了,這里只講述hive的使用,不講述其安裝配置。
1.打開Xshell軟件,建立個(gè)人Windows PC機(jī)與Linux服務(wù)器的遠(yuǎn)程連接;
2.在界面中輸入su hdfs進(jìn)入操作者模式,再輸入hive,從Linux中進(jìn)入Hive內(nèi)部,啟動(dòng)Hive的代碼如下:
[root@name01-test ~]# su hdfs [hdfs@name01-test root]$ hive Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/jars/spark-assembly-1.6.0-cdh5.15.0-hadoop2.6.0-cdh5.15.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/jars/spark-assembly-1.6.0-cdh5.15.0-hadoop2.6.0-cdh5.15.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/jars/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/jars/spark-assembly-1.6.0-cdh5.15.0-hadoop2.6.0-cdh5.15.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]Logging initialized using configuration in jar:file:/opt/cloudera/parcels/CDH-5.15.0-1.cdh5.15.0.p0.21/jars/hive-common-1.1.0-cdh5.15.0.jar!/hive-log4j.properties WARNING: Hive CLI is deprecated and migration to Beeline is recommended. hive> [hdfs@name01-test root]$- ?
注意:這里只有第一行的[root@name01-test ~]# su hdfs中的su hdfs和第二行的hive是自己手動(dòng)輸入的,下面的大段代碼都是系統(tǒng)默認(rèn)給出的,不用管。接下來,在hive> [hdfs@name01-test root]$后面敲出Hive SQL即可;
注意:這里進(jìn)入hive的代碼,不能直接輸入hive;因?yàn)槲疫B接服務(wù)器的賬號(hào)是root,而當(dāng)hadoop集群加上權(quán)限管理后,即使是linux的root用戶也不能擁有最高權(quán)限了,root用戶很多數(shù)據(jù)庫都進(jìn)去不了了。因?yàn)閔dfs的管理員是hdfs,因此,只能以su dhfs的方式進(jìn)去;
3.Hive QL簡稱HQL,語法與MySQL幾乎完全一樣。所以說,搞數(shù)據(jù)開發(fā),MySQL是基石,非常之重要;
任務(wù)描述
昨天小組組長給了一個(gè)新手任務(wù):?
我的本地電腦描述為PC-A,遠(yuǎn)程電腦PC-B上有個(gè)MySQL數(shù)據(jù)庫,hadoop集群部署在測試服務(wù)器PC-C上?,F(xiàn)在,需要把PC-B上的一些table導(dǎo)入到PC-C的Hive數(shù)據(jù)倉庫中。怎么辦?
解決思路
技術(shù)點(diǎn)
總結(jié)
以上是生活随笔為你收集整理的数据转移-从MySQL到Hive的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mkimage工具讲解
- 下一篇: linux cmake编译源码,linu