又重新安装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 ' ';
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