[aone@localhost bin]$ cd hive-0.9.0/
[aone@localhost hive-0.9.0]$ ls
bin conf docs
examples lib
LICENSE NOTICE
README.txt RELEASE_NOTES.txt
scripts src
[aone@localhost hive-0.9.0]$ cd conf
[aone@localhost conf]$ ls
hive-default.xml.template
hive-env.sh.template
hive-exec-log4j.properties.template
hive-log4j.properties.template
如果不加入hive-site.xml和hive-env.sh,而是就用默认的也可以使用hive,但用的就是jdbc:derby:;databaseName=metastore_db;
如果想让hive连接至mysql就要更改配置
[aone@localhost conf]$ cp hive-default.xml.template
hive-site.xml
[aone@localhost conf]$ cp hive-env.sh.template hive-env.sh
[aone@localhost conf]$ vi hive-env.sh
.....
# Set HADOOP_HOME to point to a specific hadoop install
directory
HADOOP_HOME=${HADOOP_HOME} #写成环境变量也是可以的?(经验证load,create,drop都没有问题)
.....
[aone@localhost
conf]$ vi hive-site.xml
........
javax.jdo.option.ConnectionURL
jdbc:mysql://localhost:3306/hive_meta?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=latin1
JDBC connect string for a JDBC metastore
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
Driver class name for a JDBC metastore
..........
javax.jdo.option.ConnectionUserName
hive
username to use against metastore database
javax.jdo.option.ConnectionPassword
hive
password to use against metastore database
............
hive.stats.dbclass
jdbc:mysql
The default database that stores temporary hive
statistics.
hive.stats.jdbcdriver
com.mysql.jdbc.Driver
The JDBC driver for the database that stores
temporary hive statistics.
hive.stats.dbconnectionstring
jdbc:mysql://localhost:3306/hive_stats?useUnicode=true&characterEncoding=utf8&user=hive&password=hive&createDatabaseIfNotExist=true
The default connection string for the database
that stores temporary hive statistics.
改完配置文件后,将mysql-connector-java-*.jar拷贝到
hive/lib
[aone@localhost conf]$ hive
Logging initialized using configuration in
file:/home/aone/bin/hive-0.9.0/conf/hive-log4j.properties
Hive history
file=/tmp/aone/hive_job_log_aone_201305040912_1960068976.txt
hive> show tables;
OK
Time taken: 2.248 seconds
原创博文,如要转载请注明出处:
http://blog.sina.com.cn/s/blog_ac9e44210101ke25.html