配置hive-env.sh
vi hive-env.sh
HADOOP_HOME=/home/hadoop/hadoop
export HIVE_CONF_DIR=/home/hadoop/hive/conf
export HIVE_AUX_JARS_PATH=/home/hadoop/hive/lib
source hive-env.sh
修改hive-site.xml配置文件
把Hive的元数据存储到MySQL中
vi conf/hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_metadata?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>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
create database hive_metadata;
grant all on hive_metadata.* to hive@‘%‘ identified by ‘hive‘;
grant all on hive_metadata.* to hive@localhost identified by ‘hive‘;
ALTER DATABASE hive_metadata CHARACTER SET latin1;
手动上传mysql的jdbc库到hive/lib
ls /home/hadoop/hive/lib
mysql-connector-java-5.1.22-bin.jar
启动hive
#启动metastore服务
hive --service metastore
Starting Hive Metastore Server
#启动hiveserver服务
hive --service hiveserver
Starting Hive Thrift Server
#启动hive客户端 hive shell
Logging initialized using configuration in file:/root/hive-0.9.0/conf/hive-log4j.properties
Hive history file=/tmp/root/hive_job_log_root_201211141845_1864939641.txt