又重新安裝Hive,記錄一下吧: hadoop早已經裝上了。 cdh5的hive下載地址: http://archive.cloudera.com/cdh5/cdh/5/ 下載文件:hive-1.1.0-cdh5.10.0.tar.gz 操作系統版本:CentOS CentOS Linux rele ...
又重新安裝Hive,記錄一下吧:
hadoop早已經裝上了。
cdh5的hive下載地址:
http://archive.cloudera.com/cdh5/cdh/5/
下載文件:hive-1.1.0-cdh5.10.0.tar.gz
操作系統版本:CentOS
cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
安裝MariaDB庫
略
上傳並解壓安裝文件:
tar -xzvf hive-1.1.0-cdh5.10.0.tar
拷貝jdbc包到hive的lib目錄下:
mysql-connector-java-5.1.39-bin.jar
新建配置文件:hive-site.xml
<configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://node11:3306/hive?createDatabaseIfNotExist=true</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>root</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>root</value> </property> </configuration>
修改配置文件:cp hive-env.sh.template hive-env.sh
HADOOP_HOME=/home/hadoop/app/hadoop-2.6.0-cdh5.10.0
HIVE_CONF_DIR=/home/hadoop/app/hive-1.1.0-cdh5.10.0/conf
運行 hive
bin/hive
創建表:
create table name(id int, name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
load data local inpath '/home/hadoop/files/nameinfo.txt' into table name;
載入數據:
load data local inpath '/home/hadoop/files/nameinfo.txt' into table name;
查詢表
hive> select *from name; OK 1 Lily 2 Andy 3 Tom Time taken: 0.086 seconds, Fetched: 3 row(s)
文件內容:
1 Lily 2 Andy 3 Tom