create database hive;
grant all on hive.* to hive@'%' identified by 'hive';
grant all on hive.* to hive@'localhost' identified by 'hive';
flush privileges;
二、开始安装hive
1、解压
[root@master ~]# tar xf apache-hive-1.2.2-bin.tar.gz -C /opt/
2、修改环境变量
hive> show databases;
OK
default
Time taken: 0.907 seconds, Fetched: 1 row(s)
hive --service metastore
出现此提示说明安装成功
3、创建表
hive> CREATE TABLE csv_t1(index_code string,name string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",", #以逗号为分隔符
"quoteChar" = "'", #以单引号为分隔符
"escapeChar" = "\\") #以双斜杠为分隔符
STORED AS TEXTFILE;
4、导入数据
hive> load data local inpath "/usr/local/test.csv" into csv_t1;
四、报错
1、mysql编码不是latin1
FAILED: Execution Error, return code 1 from
org.apache.Hadoop.hive.ql.exec.DDLTask. MetaException
(message:javax.jdo.JDODataStoreException: An exception was
thrown while adding/validating class(es) : Specified key was too
long; max key length is 767 bytes
com.MySQL.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Specified key was too long; max key length is 767 bytes
解决办法
mysql > alter database hive character set latin1;
2、READ-COMMITTED需要把bin-log以mixed方式来记录
否则进入hive,会如下错误
FAILED: Error in metadata: javax.jdo.JDOException: Couldnt
obtain a new sequence (unique id) : Binary logging not possible.
Message: Transaction level 'READ-COMMITTED' in InnoDB is not
safe for binlog mode 'STATEMENT'
解决办法