hive入門環境啟動測試實戰
阿新 • • 發佈:2018-11-07
首先啟動hadoop(存放hive表資料),spark可以不用啟動
/usr/local/hadoop/sbin/start-all.sh
/usr/local/spark/sbin/start-all.sh
啟動mysql(metastore存hive元資料)
檢查hive配置more hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value> <description>JDBC connect string for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> <description>password to use against metastore database</description> </property> </configuration>
啟動hive
hive --service metastore
hive --service hiveserver2
測試
hive
show databases
create table test(a string, b int);
show tables;
desc test;
查詢mysql元資料資訊
mysql -uroot -phadoop hive
select TBL_ID, CREATE_TIME, DB_ID, OWNER, TBL_NAME,TBL_TYPE from TBLS;
查詢hadoop中test表儲存
http://10.0.3.101:50070/explorer.html#/user/hive/warehouse
hadoop fs -ls /user/hive/warehouse
hadoop fs -ls /user/hive/warehouse/test
hadoop fs -cat /user/hive/warehouse/test/000000_0