大數據(Hive的MetaStore切換及其Hive的語法細節)
阿新 • • 發佈:2019-01-26
ant bin 自啟 tor focus sql命令 cli explore .sql
MetaStore
1. MetaStore在Hive中是非常重要的一個概念,通過MetaStoreHive存儲HDFS與表的對應關系,MetaStore通過RDB進行數據的存儲.
2. MetaStore默認是通過Derby數據庫,進行元數據存儲的.
3. 如果用Derby充當默認的MetaStore,Hive只能以一個Client進行訪問
把默認的Derby切換成其他的RDB(MySQL)
-
切換的步驟
1. 安裝MySQL數據庫 yum install -y mysql-server service mysqld start #啟動mysql服務 chkconfig mysqld on #自啟動 修改root用戶密碼
Hive的語法細節
-
Hive相關的配置文件
hive-default.xml ? hive-site.xml <!--顯示數據庫名--> <property> <name>hive.cli.print.current.db</name> <value>true</value> </property> <!--顯示查詢表的列名--> <property> <name>hive.cli.print.header</name> <value>true</value> </property> 也可以通過shell或者hive命令行修改 bin/hive --hiveconf hive.cli.print.header false ? hive>set hive.cli.print.header hive>set hive.cli.print.header=true
?
-
Hive的啟動參數
#啟動 1. bin/hive #啟動hive時,修改hive的配置項 2. bin/hive --hiveconf hive.cli.print.header false #查看幫助文檔 3. bin/hive -help 查看hive的幫助信息 #啟動hive 同時指定數據庫 4. bin/hive --database baizhi_140 #啟動hive 同時執行命令 5. bin/hive -e ‘show databases‘ bin/hive --database baizhi_140 -e ‘show tables‘ >:覆蓋原來文件 >>:追加到源文件 bin/hive --database baizhi_140 -e ‘select * from t_user‘ >> /root/result #啟動hive,同時執行命令文件(sql命令放在sql文件裏) 6. bin/hive -f /opt/datas/hive.sql bin/hive --database baizhi_140 -f /root/hive.sql >> /root/result
-
數據庫
-
表
-
導入數據
-
導出數據
-
大數據(Hive的MetaStore切換及其Hive的語法細節)