一、解压hive并创建软连接
[hadoop@hadoop ~]$ tar -xvf ~/software/hive-1.1.0-cdh5.16.2.tar.gz -C ~/app/
[hadoop@hadoop ~]$ ln -s ~/app/hive-1.1.0-cdh5.16.2/ ~/app/hive
二、配置文件
# 参数配置参考:https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties
[hadoop@hadoop app]$ cd ~/app/hive
[hadoop@hadoop hive]$ cd conf/
# 修改hive-env.sh
[hadoop@hadoop conf]$ cp hive-env.sh.template hive-env.sh
[hadoop@hadoop conf]$ vim hive-env.sh
# 显式配置hadoop的home
HADOOP_HOME=$HADOOP_HOME
export HADOOP_HEAPSIZE=1024 # 生产上面这个参数是要调大的,1个G是不够的
# 编辑hive-site.xml,这个配置文件默认是没有提供模板的,所以要自己创建
[hadoop@hadoop conf]$ vim hive-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&useSSL=false</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>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
<description>打印当前hive库名</description>
</property>
<property>
<name>hive.cli.print.header</name>
<value>true</value>
<description>打印当前hive表字段名</description>
</property>
</configuration>
三、添加hive环境变量
[hadoop@hadoop hive]$ echo -e '# HIVE ENV\nexport HIVE_HOME=/home/hadoop/app/hive\nexport HIVE_CONF_DIR=$HIVE_HOME/conf\nexport PATH=$HIVE_HOME/bin:$PATH' >> ~/.bashrc
[hadoop@hadoop hive]$ source ~/.bashrc
四、上传mysql驱动包
# 将mysql-connector-java-5.1.47.jar包上传到/home/hadoop/software/目录下
[hadoop@hadoop hive]$ cd
[hadoop@hadoop ~]$ cp ~/lib/mysql-connector-java-5.1.47.jar ~/app/hive/lib/